This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Device ID as advertising name

Hello,

I am trying to develop a product on a large scale. I need the last 4 digits of DEVICEADDR[0] as the advertising name for uniqueness. But I am not able to get it working. Please kindly help with this.

Thankyou.

Parents
  • Hello,

    I need the last 4 digits of DEVICEADDR[0] as the advertising name for uniqueness. But I am not able to get it working. Please kindly help with this.

    What have you done to implement this, and what unexpected behavior are you seeing?
    If you could share some code, that would be very helpful to have a look at.

    To achieve this you will have to append the digits to the end of your device name c-string, before supplying it as part of the advertising data.
    You may append the digits to your device name by for example using snprintf or any other c-string concatication function.

    Best regards,
    Karl 

  • we have tried using snprintf but it didn't work. Instead the device didn't show any name while advertising.

      unsigned char str_1[10];
      str_1[0] = (NRF_FICR->DEVICEADDR[0] & 0xF);
      str_1[1] = ((NRF_FICR->DEVICEADDR[0] >> 4) & 0xF);
      str_1[2] = ((NRF_FICR->DEVICEADDR[0] >> 8) & 0xF);
      str_1[3] = ((NRF_FICR->DEVICEADDR[0] >> 12) & 0xF);

      snprintf(LddGapParams.pDeviceName, "%c%c%c%c%x%x', str_1[0], str_1[1], str_1[2], str_1[3]);

      err_code = sd_ble_gap_device_name_set(&sec_mode,
                                   (const uint8_t *)LpGapStruc->pDeviceName, size);


      APP_ERROR_CHECK(err_code);

Reply
  • we have tried using snprintf but it didn't work. Instead the device didn't show any name while advertising.

      unsigned char str_1[10];
      str_1[0] = (NRF_FICR->DEVICEADDR[0] & 0xF);
      str_1[1] = ((NRF_FICR->DEVICEADDR[0] >> 4) & 0xF);
      str_1[2] = ((NRF_FICR->DEVICEADDR[0] >> 8) & 0xF);
      str_1[3] = ((NRF_FICR->DEVICEADDR[0] >> 12) & 0xF);

      snprintf(LddGapParams.pDeviceName, "%c%c%c%c%x%x', str_1[0], str_1[1], str_1[2], str_1[3]);

      err_code = sd_ble_gap_device_name_set(&sec_mode,
                                   (const uint8_t *)LpGapStruc->pDeviceName, size);


      APP_ERROR_CHECK(err_code);

Children
Related