First prepare the bluetooth folder by downloading Bluetooth LE stacks and headers:
./drivers/bluetooth/download_ble_stack.sh
If the Bluetooth stacks has been downloaded, compile the target with the following command:
make BOARD=pca10040 SD=s132
The **make sd** will trigger a flash of the bluetooth stack before that application is flashed. Note that **make sd** will perform a full erase of the chip, which could cause 3rd party bootloaders to also be wiped.
make BOARD=pca10040 SD=s132 sd
Note: further tuning of features to include in bluetooth or even setting up the device to use REPL over Bluetooth can be configured in the `bluetooth_conf.h`.
note: On Linux it might be required to link SEGGER's `libjlinkarm.so` inside nrfjprog's folder.
## PyOCD/OpenOCD Targets
Install the necessary tools to flash and debug using OpenOCD:
sudo apt-get install openocd
sudo pip install pyOCD
## Bluetooth LE REPL
The port also implements a BLE REPL driver. This feature is disabled by default, as it will deactivate the UART REPL when activated. As some of the nRF devices only have one UART, using the BLE REPL free's the UART instance such that it can be used as a general UART peripheral not bound to REPL.
The configuration can be enabled by editing the `bluetooth_conf.h` and set `MICROPY_PY_BLE_NUS` to 1.
When enabled you have different options to test it:
* [NUS Console for Linux](https://github.com/tralamazza/nus_console) (recommended)
WebBluetooth mode can also be configured by editing `bluetooth_conf.h` and set `BLUETOOTH_WEBBLUETOOTH_REPL` to 1. This will alternate advertisement between Eddystone URL and regular connectable advertisement. The Eddystone URL will point the phone or PC to download [WebBluetooth REPL](https://aykevl.nl/apps/nus/) (experimental), which subsequently can be used to connect to the Bluetooth REPL from the PC or Phone browser.