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

ble_app_eddystone adding and configuration slots

Hi, 

I am currently working on testing eddystone on nRF52. I have used the ble_app_eddystone example as a starting point. I have looked into the example and trying to configure multiple slots for UID, URL and TLM. In nrf_ble_es.c file we have function adv_slots_init that initialize the slots. I am trying to follow on that implementation to add additional slot for UID but it is not working. 
But, It is working when I have a single slot instead of two, it is either UID or URL that will work depending on which is called last (see code). 

On nRF beacon for Eddystone app I'm able to configure the slots and it works fine. I have debugged that the configure of slots on the app actually calls the same function which is used in initializing slots, so there shouldn't be a difference.

So this code will have UID advertisement since UID is the last to be initialized. 

static void adv_slots_init(void)
{
    uint8_t default_frame_data[DEFAULT_FRAME_LENGTH] = DEFAULT_FRAME_DATA;
    uint8_t UID_Frame_Data[UID_FRAME_LENGTH] = UID_FRAME_DATA;

    //Slot 0 URL
    es_slot_t default_adv_slot = {.slot_no             = 0,
                                  .radio_tx_pwr        = DEFAULT_FRAME_TX_POWER,
                                  .adv_frame.type      = DEFAULT_FRAME_TYPE,
                                  .adv_frame.length    = DEFAULT_FRAME_LENGTH,
                                  .adv_custom_tx_power = false,
                                  .configured          = true};

    memcpy(&default_adv_slot.adv_frame.frame, default_frame_data, DEFAULT_FRAME_LENGTH);
    es_slots_init(&default_adv_slot);

    //Slot 1 UID
    es_slot_t UID_adv_slot = {.slot_no                 = 1,
                                  .radio_tx_pwr        = DEFAULT_FRAME_TX_POWER,
                                  .adv_frame.type      = UID_FRAME_TYPE,
                                  .adv_frame.length    = UID_FRAME_LENGTH,
                                  .adv_custom_tx_power = false,
                                  .configured          = true};

    memcpy(&UID_adv_slot.adv_frame.frame, UID_Frame_Data, UID_FRAME_LENGTH) ;

    es_slots_init(&UID_adv_slot);


}


Would appreciate any help! 
Thank you! 

Best Regards,
Hamza

Parents
  • Ok I solved it. The example does slot init for slot number 0 always. Compare the following code with the one given in the example; 
    This is the solution: 

    void es_slots_init(const es_slot_t * p_default_slot)
    {
        ret_code_t       err_code;
        uint8_t slot_no = p_default_slot->slot_no;
        es_flash_flags_t flash_flags = {{0}};
    
        es_slot_reg_init(&m_reg);
    
        m_eid_loaded_from_flash = false;
    
        // Read the flash flags to see if there are any previously stored slot configs
        err_code = es_flash_access_flags(&flash_flags, ES_FLASH_ACCESS_READ);
    
        if (err_code == FDS_ERR_NOT_FOUND)
        {
            // Factory reset or initial boot, load default data
            memcpy(&m_reg.slots[slot_no], p_default_slot, sizeof(*p_default_slot));
            es_slot_reg_update_slot_list_info_on_add(&m_reg, slot_no, p_default_slot->adv_frame.type, true);
        }
    
        else
        {
            APP_ERROR_CHECK(err_code);
    
            for (uint32_t i = 0; i < APP_MAX_ADV_SLOTS; ++i)
            {
                if (!flash_flags.slot_is_empty[i])
                {
                    load_slot_from_flash(i);
                }
            }
        }
    }
    


    Maybe someone from nRF can confirm this approach to be correct? 

    Regards,
    Hamza

Reply
  • Ok I solved it. The example does slot init for slot number 0 always. Compare the following code with the one given in the example; 
    This is the solution: 

    void es_slots_init(const es_slot_t * p_default_slot)
    {
        ret_code_t       err_code;
        uint8_t slot_no = p_default_slot->slot_no;
        es_flash_flags_t flash_flags = {{0}};
    
        es_slot_reg_init(&m_reg);
    
        m_eid_loaded_from_flash = false;
    
        // Read the flash flags to see if there are any previously stored slot configs
        err_code = es_flash_access_flags(&flash_flags, ES_FLASH_ACCESS_READ);
    
        if (err_code == FDS_ERR_NOT_FOUND)
        {
            // Factory reset or initial boot, load default data
            memcpy(&m_reg.slots[slot_no], p_default_slot, sizeof(*p_default_slot));
            es_slot_reg_update_slot_list_info_on_add(&m_reg, slot_no, p_default_slot->adv_frame.type, true);
        }
    
        else
        {
            APP_ERROR_CHECK(err_code);
    
            for (uint32_t i = 0; i < APP_MAX_ADV_SLOTS; ++i)
            {
                if (!flash_flags.slot_is_empty[i])
                {
                    load_slot_from_flash(i);
                }
            }
        }
    }
    


    Maybe someone from nRF can confirm this approach to be correct? 

    Regards,
    Hamza

Children
Related