Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

Client BLEService does not detect 128 bit Custom UUID
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Client BLEService does not detect 128 bit Custom UUID

by jaja_adf on Tue Apr 06, 2021 6:19 am

Hi,
- I'm working with Adafruit Feather nRF52840 to make client that connect to multiple server and then streming data to my client !
- I succeeded to compile Centrale_custom_hrm / Custom_hrm arduino example with two Adafruit Feather nRF52840 board, all the example use SIG UUID with 16bit.
- I try to change code to use custom UUID with 128bit for Centrale_custom_hrm example , i can compile it without error, but the central didn't detect advertising of the server, i use android application to emulate Server GAT, i show you below my code :


Centrale_custom_hrm :

Code: Select all | TOGGLE FULL SIZE
#include <bluefruit.h>

/* Xsens Service Definitions
 * Heart Rate Monitor Service:  0x180D
 * Heart Rate Measurement Char: 0x2A37 (Mandatory)
 * Body Sensor Location Char:   0x2A38 (Optional)
 */
const uint8_t UUID128_SVC_XSENS[] =
{
    0x80, 0x70, 0x80, 0x70, 0x80, 0x00, 0x00, 0x80,
    0x00, 0x10, 0x00, 0x00, 0xF0, 0xFF, 0x00, 0x00
};

const uint8_t UUID128_CHR_XSENS[] =
{
    0x80, 0x70, 0x80, 0x70, 0x80, 0x00, 0x00, 0x80,
    0x00, 0x10, 0x00, 0x00, 0xF1, 0xFF, 0x00, 0x00
};

BLEClientService        xsens_svc(UUID128_SVC_XSENS);
BLEClientCharacteristic xsens_chr(UUID128_CHR_XSENS);


//BLEClientService        hrms(UUID16_SVC_HEART_RATE);
//BLEClientCharacteristic hrmc(UUID16_CHR_HEART_RATE_MEASUREMENT);
//BLEClientCharacteristic bslc(UUID16_CHR_BODY_SENSOR_LOCATION);

void setup()
{
  Serial.begin(115200);
  while ( !Serial ) delay(10);

  Bluefruit.begin(0, 1);
  Bluefruit.setName("Central");
  // Initialize HRM client
  //hrms.begin();
  xsens_svc.begin();
  xsens_chr.setNotifyCallback(hrm_notify_callback);
  xsens_chr.begin();
  Bluefruit.setConnLedInterval(250);

  Bluefruit.Central.setDisconnectCallback(disconnect_callback);
  Bluefruit.Central.setConnectCallback(connect_callback);


  Bluefruit.Scanner.setRxCallback(scan_callback);
  Bluefruit.Scanner.restartOnDisconnect(true);
  Bluefruit.Scanner.setInterval(160, 80); // in unit of 0.625 ms
  Bluefruit.Scanner.filterUuid(xsens_svc.uuid);
  Bluefruit.Scanner.useActiveScan(false);
  Bluefruit.Scanner.start(0);
}

void loop()
{
  // do nothing
}

void scan_callback(ble_gap_evt_adv_report_t* report)
{
  Bluefruit.Central.connect(report);
}


void connect_callback(uint16_t conn_handle)
{
  Serial.println("Connected");
  Serial.print("Discovering HRM Service ... ");

  // If HRM is not found, disconnect and return
  if ( !xsens_svc.discover(conn_handle) )
  {
    Serial.println("Found NONE");

    // disconnect since we couldn't find HRM service
    Bluefruit.disconnect(conn_handle);

    return;
  }

  // Once HRM service is found, we continue to discover its characteristic
  Serial.println("Found it");
 
  Serial.print("Discovering Measurement characteristic ... ");
  if ( !hrmc.discover() )
  {
    // Measurement chr is mandatory, if it is not found (valid), then disconnect
    Serial.println("not found !!!"); 
    Serial.println("Measurement characteristic is mandatory but not found");
    Bluefruit.disconnect(conn_handle);
    return;
  }
  Serial.println("Found it");

  // Reaching here means we are ready to go, let's enable notification on measurement chr
  if ( xsens_chr.enableNotify() )
  {
    Serial.println("Ready to receive HRM Measurement value");
  }else
  {
    Serial.println("Couldn't enable notify for HRM Measurement. Increase DEBUG LEVEL for troubleshooting");
  }
}

void disconnect_callback(uint16_t conn_handle, uint8_t reason)
{
  (void) conn_handle;
  (void) reason;

  Serial.print("Disconnected, reason = 0x"); Serial.println(reason, HEX);
}

void hrm_notify_callback(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len)
{
  Serial.print("HRM Measurement: ");

  if ( data[0] & bit(0) )
  {
    uint16_t value;
    memcpy(&value, data+1, 2);

    Serial.println(value);
  }
  else
  {
    Serial.println(data[1]);
  }
}

 



I Maybe miss somthing when i cutomised the UUID, Can some one help me with this ? thanks.

Bests regards,

JAJA
Attachments
BLE SERVER.jpg
BLE SERVER.jpg (103.7 KiB) Viewed 55 times

jaja_adf
 
Posts: 2
Joined: Thu Oct 03, 2019 4:07 am

Please be positive and constructive with your questions and comments.