Arduino Forum

Products => Arduino 101 => Topic started by: evanhjalmar on Feb 03, 2016, 01:46 am

Title: Object Transfer method
Post by: evanhjalmar on Feb 03, 2016, 01:46 am
Trying to understand how to use each of the services defined here:

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 :
Code: [Select]

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

BLECharacteristic heartRateChar

Can anyone provide an example on how to define these services?
Title: Re: Object Transfer method
Post by: drmpf on Feb 03, 2016, 01:54 am
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 for the current, non-BLE app and designer
Title: Re: Object Transfer method
Post by: drmpf on Feb 03, 2016, 02:02 am
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

Title: Re: Object Transfer method
Post by: Goood on May 15, 2019, 09:00 am
Hi !

How to use txCharacteristic in this case ?