For the Body Sensor project, I needed to change the default service UUID that a BlendMicro board was advertising. If you are here, it probably means you also want to get this done. I hope you will find this tutorial useful.
The Bluetooth Low Energy(BLE) connection will be established between an Intel Edison board (central device) and a BlendMicro peripheral.
- First things first! Install the required software:
On the BlendMicro side you will need :
- Arduino IDE 1.6.4 http://www.arduino.cc/en/Main/Software
- Add-on Package https://github.com/RedBearLab/Blend
-
- Nordic nRF8001 SDK for Arduino https://github.com/NordicSemiconductor/ble-sdk-arduino
- RBL nRF8001 Library https://github.com/RedBearLab/nRF8001
Install the Arduino IDE.
Extract your downloads and copy the Hardware folder from the Add-On package in your Arduino folder.
Copy the BLE folder from the nRF8001 SDK in the Libraries folder.
Do the same for the nRF8001 Library.
In the end your folders should look like this:
For programming the Intel Edison I am using:
-
- Intel IoT XDK https://software.intel.com/en-us/html5/xdk-iot
- On top of Yocto, the Linux distribution running on the Edison (Release 2.0 from https://software.intel.com/en-us/iot/hardware/edison/downloads), Noble must be installed.
-
- Noble is a node.js library for BLE central devices and here’s how you can configure it: https://www.npmjs.com/package/noble
Make sure you have Bluetooth working on your Edison. You may find the new Bluetooth Guide from Intel useful.
2. Edison code
Now that we have all the tools, we can proceed with writing the code for the Edison.Our aim is to discover the BlendMicro and to printout the advertising service UUID.
var noble = require('noble');
var devices = new Array();
noble.startScanning();
console.log('Try to find BLE devices...');
noble.on('discover', function (peripheral) {
peripheral.connect(function (error) {
if (error) {
console.log(error);
} else {
devices.push(peripheral);
}
});
console.log(peripheral.advertisement.localName);
console.log(peripheral.address);
});
setTimeout(function () {
console.log("Stop discovery \n");
noble.stopScanning();
reportDevices(devices);
}, 10000);
var reportDevices = function (listOfDevices) {
for (var idx in listOfDevices) {
console.log(' ' + idx + ' uuid: ' + listOfDevices[idx].advertisement.localName);
console.log("\tLE: " + listOfDevices[idx]);
console.log('\tConnected to peripheral: ' + listOfDevices[idx].uuid);
}
}
Next, we load the "SimpleChat" example from the RBL_nRF8001 library on the BlendMicro.
When running the code on the Edison, we can see that by default the BlendMicro advertises service 180b.
3. Using nRFgo Studio
- Load your RBL_nRF8001.xml file (under C:\Users\uc-office\Documents\Arduino\libraries\RBL_nRF8001) into the nRFgo.
Check what service is being advertised. You will find this information in the GAP Settings tab, under Service Solicitation and Local Services.
-
- Change UUID base from 180b to 180a, click OK and go to File -> Save
Now your .xml file is updated.
-
- Generate the files used by RBL_nRF8001 library. Select the same destination folder where RBL_nRF8001.xml file is found.
The following files will be generated:
-
- Rename services.h to RBL_services.h and save the old one under a different name
-
- Upload the SimpleChat example again and when finished, RESET the BlendMicro board (!!! Don’t forget this step)
Now the service UUID should be updated to 180a:
Thanks for reading!