<commit_before># WebThings Gateway by Mozilla

[![Build Status](https://github.com/mozilla-iot/gateway/workflows/Node.js%20application/badge.svg)](https://github.com/mozilla-iot/gateway/workflows/Node.js%20application)
[![codecov](https://codecov.io/gh/mozilla-iot/gateway/branch/master/graph/badge.svg)](https://codecov.io/gh/mozilla-iot/gateway)
[![dependencies](https://david-dm.org/mozilla-iot/gateway.svg)](https://david-dm.org/mozilla-iot/gateway)
[![devDependencies](https://david-dm.org/mozilla-iot/gateway/dev-status.svg)](https://david-dm.org/mozilla-iot/gateway?type=dev)
[![optionalDependencies](https://david-dm.org/mozilla-iot/gateway/optional-status.svg)](https://david-dm.org/mozilla-iot/gateway?type=optional)
[![license](https://img.shields.io/badge/license-MPL--2.0-blue.svg)](LICENSE)

Web of Things gateway.

If you have a Rasberry Pi, the easiest way to use the gateway is to [download and flash](http://iot.mozilla.org/gateway/) a pre-built software image from Mozilla to an SD card. Otherwise you can build it from source yourself (see below).

## Prerequisites for Building

### Install OS

(If you're just installing on your PC, you can skip this step).

If you're installing on a Raspberry Pi then you may need to set up the OS on the Raspberry Pi first. [See here](https://github.com/mozilla-iot/wiki/wiki/Setting-up-Raspberry-Pi) for instructions.

### Update Package Cache (Linux only)

Under Ubuntu/Debian Linux:
```
$ sudo apt update
```

Under Fedora Linux:
```
$ sudo dnf --refresh upgrade
```

### Install pkg-config

Under Ubuntu/Debian Linux:
```
$ sudo apt install pkg-config
```

Under Fedora Linux:
```
$ sudo dnf install pkgconfig
```

Under macOS:
```
$ brew install pkg-config
```

### Install curl (needed to install nvm)

Under Ubuntu/Debian Linux:
```
$ sudo apt install curl
```

Under Fedora Linux:
```
$ sudo dnf install curl
```

### Install nvm (Recommended)

nvm allows you to easily install different versions of node. To install nvm:

```
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
```

Reinitialize your terminal session.

```
$ . ~/.bashrc
```

### Install node (if you didn't use nvm)

(If you already installed node via nvm you can skip this step)

Follow the directions from [NodeJS](https://nodejs.org) to install on your platform.

### Set up Bluetooth permissions (Linux only)

The following is required in order to let node and python3 use the Bluetooth adapter.

```
$ sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)
$ sudo setcap cap_net_raw+eip $(eval readlink -f `which python3`)
```

### Install Bluetooth and BT Low Energy support libraries (Linux only)

The following are required in order to install the Python modules that support Bluetooth

Under Ubuntu/Debian Linux:
```
$ sudo apt install libboost-python-dev libboost-thread-dev libbluetooth-dev libglib2.0-dev
```

Under Fedora Linux:
```
$ sudo dnf install boost-python2-devel boost-python3-devel boost-devel bluez-libs-devel glib2-devel
```

### Install libusb and libudev (Linux only)

Under Ubuntu/Debian Linux:
```
$ sudo apt install libusb-1.0-0-dev libudev-dev
```

Under Fedora Linux:
```
$ sudo dnf install libudev-devel libusb1-devel
```

### Install autoconf

Under Ubuntu/Debian Linux:
```
$ sudo apt install autoconf
```

Under Fedora Linux:
```
$ sudo dnf install autoconf
```

Under macOS:
```
$ brew install autoconf
```

### Install libpng (Linux only)

Under x86-64 or x86 Ubuntu/Debian Linux:
```
$ sudo apt install libpng16-16
```

Under ARM Ubuntu/Debian Linux:
```
$ sudo apt install libpng-dev
```

Under Fedora Linux:
```
$ sudo dnf install libpng-devel
```

### Install git

You'll need git to checkout the repositories.

Under Ubuntu/Debian Linux:
```
$ sudo apt install git
```

Under Fedora Linux:
```
$ sudo dnf install git<commit_msg>Update README to include libffi. (#2219)<commit_after># WebThings Gateway by Mozilla

[![Build Status](https://github.com/mozilla-iot/gateway/workflows/Node.js%20application/badge.svg)](https://github.com/mozilla-iot/gateway/workflows/Node.js%20application)
[![codecov](https://codecov.io/gh/mozilla-iot/gateway/branch/master/graph/badge.svg)](https://codecov.io/gh/mozilla-iot/gateway)
[![dependencies](https://david-dm.org/mozilla-iot/gateway.svg)](https://david-dm.org/mozilla-iot/gateway)
[![devDependencies](https://david-dm.org/mozilla-iot/gateway/dev-status.svg)](https://david-dm.org/mozilla-iot/gateway?type=dev)
[![optionalDependencies](https://david-dm.org/mozilla-iot/gateway/optional-status.svg)](https://david-dm.org/mozilla-iot/gateway?type=optional)
[![license](https://img.shields.io/badge/license-MPL--2.0-blue.svg)](LICENSE)

Web of Things gateway.

If you have a Rasberry Pi, the easiest way to use the gateway is to [download and flash](http://iot.mozilla.org/gateway/) a pre-built software image from Mozilla to an SD card. Otherwise you can build it from source yourself (see below).

## Prerequisites for Building

### Install OS

(If you're just installing on your PC, you can skip this step).

If you're installing on a Raspberry Pi then you may need to set up the OS on the Raspberry Pi first. [See here](https://github.com/mozilla-iot/wiki/wiki/Setting-up-Raspberry-Pi) for instructions.

### Update Package Cache (Linux only)

Under Ubuntu/Debian Linux:
```
$ sudo apt update
```

Under Fedora Linux:
```
$ sudo dnf --refresh upgrade
```

### Install pkg-config

Under Ubuntu/Debian Linux:
```
$ sudo apt install pkg-config
```

Under Fedora Linux:
```
$ sudo dnf install pkgconfig
```

Under macOS:
```
$ brew install pkg-config
```

### Install curl (needed to install nvm)

Under Ubuntu/Debian Linux:
```
$ sudo apt install curl
```

Under Fedora Linux:
```
$ sudo dnf install curl
```

### Install nvm (Recommended)

nvm allows you to easily install different versions of node. To install nvm:

```
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
```

Reinitialize your terminal session.

```
$ . ~/.bashrc
```

### Install node (if you didn't use nvm)

(If you already installed node via nvm you can skip this step)

Follow the directions from [NodeJS](https://nodejs.org) to install on your platform.

### Set up Bluetooth permissions (Linux only)

The following is required in order to let node and python3 use the Bluetooth adapter.

```
$ sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)
$ sudo setcap cap_net_raw+eip $(eval readlink -f `which python3`)
```

### Install Bluetooth and BT Low Energy support libraries (Linux only)

The following are required in order to install the Python modules that support Bluetooth

Under Ubuntu/Debian Linux:
```
$ sudo apt install libboost-python-dev libboost-thread-dev libbluetooth-dev libglib2.0-dev
```

Under Fedora Linux:
```
$ sudo dnf install boost-python2-devel boost-python3-devel boost-devel bluez-libs-devel glib2-devel
```

### Install libusb and libudev (Linux only)

Under Ubuntu/Debian Linux:
```
$ sudo apt install libusb-1.0-0-dev libudev-dev
```

Under Fedora Linux:
```
$ sudo dnf install libudev-devel libusb1-devel
```

### Install autoconf

Under Ubuntu/Debian Linux:
```
$ sudo apt install autoconf
```

Under Fedora Linux:
```
$ sudo dnf install autoconf
```

Under macOS:
```
$ brew install autoconf
```

### Install libpng (Linux only)

Under x86-64 or x86 Ubuntu/Debian Linux:
```
$ sudo apt install libpng16-16
```

Under ARM Ubuntu/Debian Linux:
```
$ sudo apt install libpng-dev
```

Under Fedora Linux:
```
$ sudo dnf install libpng-devel
```

### Install libffi

Under Ubuntu/Debian Linux:
```
$ sudo apt install libffi-dev
```

Under Fedora Linux:
```
$ sudo dnf install libffi-devel
```

Under macOS:
```
$ brew install libffi
```

### Install git

You'll need git to checkout the repositories.

Under Ubuntu/Debian Linux:
```
$ sudo apt install git
```

Under Fedora Linux:
```
$ sudo dnf install git
{'fraction_non_alphanumeric': 0.1390644753476612, 'fraction_numerical': 0.00834386852085967, 'mean_word_length': 4.45210199862164, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 28, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2381908', 'n_tokens_mistral': 2888, 'n_tokens_neox': 2518, 'n_words': 797}