Go Down

Topic: Object Transfer method (Read 2057 times) previous topic - next topic


Feb 03, 2016, 01:46 am Last Edit: Feb 07, 2016, 05:44 pm by evanhjalmar
Trying to understand how to use each of the services defined here: https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx

I noticed that all the bluetooth heart rate demos are including the service & a characteristic but the naming conventions seem very different from the methods defined on Bluetooth.org :
Code: [Select]

BLEService heartRateService("180D"); // BLE Heart Rate Service

BLECharacteristic heartRateChar

Can anyone provide an example on how to define these services?


Here is a definition of Nordic's UART service

// ====  create Nordic UART service =========
BLEService               uartService          = BLEService("6E400001B5A3F393E0A9E50E24DCCA9E");
// create characteristic
BLECharacteristic    txCharacteristic = BLECharacteristic("6E400003B5A3F393E0A9E50E24DCCA9E", BLENotify , 20); // == RX on central (android app)
BLECharacteristic    rxCharacteristic = BLECharacteristic("6E400002B5A3F393E0A9E50E24DCCA9E", BLEWriteWithoutResponse, 20);  // == TX on central (android app)
void blePeripheralConnectHandler(BLECentral& central) {
  // central connected event handler

void blePeripheralDisconnectHandler(BLECentral& central) {
  // central disconnected event handler

void rxCharacteristicWritten(BLECentral& central, BLECharacteristic& characteristic)  {
  int len = characteristic.valueLength();
  const unsigned char *data = characteristic.value();
  parserCmd = parser.parse((const byte*)data, len);

I am putting the finishing touches on a code generator Android app (pfodDesigner) that will generate custom menus for Arduino101 and other BLE cards and connect with pfodApp to display those menus and allow the user to operate buttons, sliders, sub-menus and log and plot data

see www.pfod.com.au for the current, non-BLE app and designer


You also need in the setup() {

 // set advertised local name and service UUID
 blePeripheral.setLocalName("101 BLE");

 // add service and characteristic

 // assign event handlers for connected, disconnected to peripheral
 blePeripheral.setEventHandler(BLEConnected, blePeripheralConnectHandler);
 blePeripheral.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);

 // assign event handlers for characteristic
 rxCharacteristic.setEventHandler(BLEWritten, rxCharacteristicWritten);

 // begin initialization



Hi !

How to use txCharacteristic in this case ?

Go Up