Extract Device name from Reflector in CS

deleted

Parents
  • Hi,

    The implementation assumes that the device name is null terminated ('\0'), so the logger continues printing from memory until it reaches the first zero byte. You can consider copying the name to another buffer:

    uint8_t device_name[BT_GAP_ADV_MAX_ADV_DATA_LEN] = {0};
    
    ...
    
    memcpy(device_name, reflector_name, MIN(len, (BT_GAP_ADV_MAX_ADV_DATA_LEN - 1)))
    
    

    Maybe you've seen it already, but just want to add that there is already a helper function named bt_data_parse() that can be used to find the device name from the advertisement packet.

    Best regards,

    Vidar

Reply
  • Hi,

    The implementation assumes that the device name is null terminated ('\0'), so the logger continues printing from memory until it reaches the first zero byte. You can consider copying the name to another buffer:

    uint8_t device_name[BT_GAP_ADV_MAX_ADV_DATA_LEN] = {0};
    
    ...
    
    memcpy(device_name, reflector_name, MIN(len, (BT_GAP_ADV_MAX_ADV_DATA_LEN - 1)))
    
    

    Maybe you've seen it already, but just want to add that there is already a helper function named bt_data_parse() that can be used to find the device name from the advertisement packet.

    Best regards,

    Vidar

Children
No Data
Related