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

Advertisement lost 1 byte

Hi guys,

I am using nrf52840 with sdk15.2 and have been experiencing some strange issue. After mobile phone connection to the device i lost 1 byte in advertisement or saying differently my device is advertising 1 byte less.

I am using sdk command

ble_advdata_encode
. Have you ever experienced this kind of issue? Is there something that could trim the data?

Here is my wrapped adv function:

ret_code_t nordic_advertiser_adv_set(uint16_t companyId, uint8_t *data, uint16_t len) {
    ret_code_t err_code;
    ble_advdata_t advdata;
    ble_advdata_service_data_t service_data;

    memset(&advdata, 0, sizeof(advdata));
    advdata.name_type = BLE_ADVDATA_NO_NAME;
    advdata.include_appearance = false;
    advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;

    service_data.service_uuid = companyId;
    service_data.data.p_data = data;
    service_data.data.size = len;

    advdata.p_service_data_array = &service_data;
    advdata.service_data_count = 1;

    if (adv_params.primary_phy == BLE_GAP_PHY_CODED) {

        err_code = ble_advdata_encode(&advdata, m_phy_data.adv_data.p_data, &m_enc_phy_len);
        if (err_code != NRF_SUCCESS) {
            return (err_code);
        }
        return (sd_ble_gap_adv_set_configure(&m_adv_handle, &m_phy_data, NULL));
    }

    err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
    if (err_code != NRF_SUCCESS) {
        return (err_code);
    }

    return (sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, NULL));
}

Thanks

Parents
  • Hi. 

    This sounds strange. 

    Are you seeing this when connecting your phone to the device, and then restarting the advertisement while connected to the device?

    Or are you connecting to the device, then disconnecting before seeing this misbehaviour of the advertisement?

    Best regards, 
    Joakim

  • On connect advertisement stops by SDK so i start it again. This is when i see this misbehaviour. I will give more details tomorow.

  • I think i know what the problem is.

    I have a custom packet with size od 31 bytes and ibeacon packet with size of 30 bytes. On every radio notification i call my nordic_advertiser_adv_set function and change between these two packets. For some reason after starting the advertisement the first packet that is advertised is the size that will stay until the next start. So it seemed to me that 1 byte was lost in my custom packet but when i looked more deeply i saw that when my custom packet was 31 bytes the ibeacon packet had also 31 bytes. I do not remember that i had that issue in SDK 14.2.

    Is that a known issue that i can't change the packet size live without stopping the advertisement? Do you have any suggestions?

Reply
  • I think i know what the problem is.

    I have a custom packet with size od 31 bytes and ibeacon packet with size of 30 bytes. On every radio notification i call my nordic_advertiser_adv_set function and change between these two packets. For some reason after starting the advertisement the first packet that is advertised is the size that will stay until the next start. So it seemed to me that 1 byte was lost in my custom packet but when i looked more deeply i saw that when my custom packet was 31 bytes the ibeacon packet had also 31 bytes. I do not remember that i had that issue in SDK 14.2.

    Is that a known issue that i can't change the packet size live without stopping the advertisement? Do you have any suggestions?

Children
Related