Please note: Friday June 18 is a holiday celebrating Juneteenth, please allow extra time for your order to arrive and plan accordingly.
0

Itsy bitsy nrf52
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Itsy bitsy nrf52

by natebc on Wed May 12, 2021 2:35 pm

I am trying to figure out a good way to scan for a specific device (HM-19 BLE module) and from the example sketches it appears I could use the following to look for a specific device with a UUID.

Code: Select all | TOGGLE FULL SIZE
// Custom UUID used to differentiate this device.
// Use any online UUID generator to generate a valid UUID.
// Note that the byte order is reversed ... CUSTOM_UUID
// below corresponds to the follow value:
// df67ff1a-718f-11e7-8cf7-a6006ad3dba0
const uint8_t CUSTOM_UUID[] =
{
    0xA0, 0xDB, 0xD3, 0x6A, 0x00, 0xA6, 0xF7, 0x8C,
    0xE7, 0x11, 0x8F, 0x71, 0x1A, 0xFF, 0x67, 0xDF
};

BLEUuid uuid = BLEUuid(CUSTOM_UUID);


And then in the setup function this will look for that specific uuid:
Code: Select all | TOGGLE FULL SIZE
Bluefruit.Scanner.filterUuid(uuid);           // Only invoke callback if the target UUID was found


But the problem I have is the UUID for the HM-19 is "0xFFE0" but this doesn't seem to be right as it is much too short to be a UUID.
I looked at the library and it didn't seem like i could sort by much else other than rssi and UUID.
Currently i am just matching the MAC address but i was hoping there might be a better way to approach this

Code: Select all | TOGGLE FULL SIZE
  uint8_t addr[6] = {177,204,161,241,52,164};
  int count = 0;
 
  for (int i = 0; i < 6;i++){
    if (addr[i] == report->peer_addr.addr[i]){
      count++;
    }
  }
  if (count == 6){
  }


Any suggestions on how I can find the longer UUID for this device?

natebc
 
Posts: 8
Joined: Wed May 12, 2021 2:21 pm

Re: Itsy bitsy nrf52

by adafruit_support_mike on Wed May 12, 2021 11:00 pm

UUIDs don't work for BLE. They aren't permanent. Having an always-on device transmitting a permanent ID to any listener is *way* too convenient for creepy-stalker purposes.

The most effective way to identify a device is to set the name it uses in its advertising field. The central device can read that before opening a data connection. You can use the combination of a standard prefix and a numeric suffix.

You also have the option to put custom information in the advertising packet's DATA field. Again, the central device can look for that before making a data connection.

adafruit_support_mike
 
Posts: 62799
Joined: Thu Feb 11, 2010 2:51 pm

Re: Itsy bitsy nrf52

by natebc on Thu May 13, 2021 7:13 pm

Thank you for the reply. That makes sense. I did find through the examples a better way than what I was using to find a device.

Code: Select all | TOGGLE FULL SIZE
uint8_t SENSORTAG_ADV_COMPLETE_LOCAL_NAME[] =           
 {0x53,0x45,0x45,0x4B,0x2D,0x30,0x31}; 

uint8_t buffer[BLE_GAP_ADV_SET_DATA_SIZE_MAX] = { 0 };
  if(Bluefruit.Scanner.parseReportByType(report, BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME, buffer, sizeof(buffer)))
  {
   Serial.println("Found Local Name");
   Serial.printf("%14s %s\n", "Local Name:", buffer);
  }



Just incase anybody else finds this thread wondering the same thing.

natebc
 
Posts: 8
Joined: Wed May 12, 2021 2:21 pm

Please be positive and constructive with your questions and comments.