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

beacon advertise interval

hello Nordic

i am working with nrf52832, sdk 6.0, softdevice s132 v7.0

i read around the forum that i can advertise a beacon packet every 20 ms 

but in the ble_app_beacon example the interval for the advertisement is written to be minimum 100ms ?? so where did that 20 ms go ?

however, since i don't know how to change the data of the message while advertising i put a timer handler that stops the advertise, update the data and start it again.

i put the timer to go every 50 ms and the advertisement interval every 50 ms i put a pin toggle every time i receive a ble from the address i am filtering..

1. the time is not fixed, maybe some messages are lost or maybe not sent, i don't know 

2. the intervals are larger then 50 ms .. more to the 100 ms  when they are sometimes fixed 

can you advice on this matter ?

i need to be sending changeable data in a beacon at list 30 times in one second

best regards

Ziv

Parents
  • Hello Ziv,

    i read around the forum that i can advertise a beacon packet every 20 ms 

    but in the ble_app_beacon example the interval for the advertisement is written to be minimum 100ms ?? so where did that 20 ms go ?

    I am not sure I follow your train of thoughts here - the lowest possible advertising interval is indeed 20 ms, but the beacon example provided in the SDK uses an advertising interval of between 100 and 200 ms, this is correct.
    The reason for this is that beacons do not usually transfer a whole lot of data, and as such it is more power efficient to not advertise with the lowest possible interval. You may of course change this in your own application, to use the 20 ms advertising interval.

    however, since i don't know how to change the data of the message while advertising i put a timer handler that stops the advertise, update the data and start it again.

    If you are using the advertising module you may instead use the _advdata_update function.
    However, the _advdata_update function has a known issue, which requires that you have two adv_data instances that you alternate between passing to update and updating.
    That is to say: you may not pass a single advdata instance to advertising start, update the same advdata instance and then provide it as the argument to _advdata_update.
    Instead, you will have to have two advdata instances, where you pass one as the argument to the _advdata_update function, and then you may update the other advdata instance, before calling _advdata_update again with the most recently updated(not currently in use) advdata instance.

    1. the time is not fixed, maybe some messages are lost or maybe not sent, i don't know 

    Advertisements are transfers without acknowledgments, and they may indeed be lost sometimes - there are no retransmissions because there is never any acknowledgements. This can happen more often if the devices are far apart, and if they are operating in a 2.4 GHz noisy environment. The time can not be completely fixed either, due to the random 10 ms delay that is added before every advertisement. This is part of the BLE specification and can not be removed.

    2. the intervals are larger then 50 ms .. more to the 100 ms  when they are sometimes fixed 

    Please elaborate on the exact timings you are seeing. How are you measuring this by the way, only the toggling pin, or do you also use the BLE Sniffer tool

    i need to be sending changeable data in a beacon at list 30 times in one second

    This is possible using beacon advertisements, since with a 20 ms advertising interval your worst case will be 30 ms between each advertisement, which again means that you will get more than 30 packets per second.
    However, you will need to keep in mind that advertisement packets may be lost. This is the biggest drawback of using advertisements to transfer data, and also what makes advertisement data transfer infeasible if you need to make sure every packet is received.
    In the latter case, you will need to establish a connection to ensure that every packet is received.

    Please let me know if anything still should be unclear,
     
    Best regards,
    Karl

  • hi Karl

    good to read from you 

    the thing i actually have to design is

    1. a software for 150 units that receive data (specific for each of them) from one broadcasting unit that is connected to a pc

    2. dLL for the beacon broadcasting gateway or dongle or whatever that is connected to the pc which is running some python app (will need some help with that later)

    regarding the first part:

    • I have no power saving issues since power will be given to all units all the time
    • I was going for broadcasting and beacon to avoid making connection with each unit which i think will take a lot of time on Acks and reconnecting with a different unit every time. I would have sent one big message to all units ,if it was possible, and maybe send it multiple times in a second just to make sure every unit got it.
    • So i was toggling myself between working on an extended beacon broadcast, to checking how much data i can transfer in the 31 byte message and how many times i can transfer it ,so that if one 31 byte message can contain data for 10 units, i have to see that i can send the message to all 150 units every one second
    You may of course change this in your own application, to use the 20 ms advertising interval.

    can i also control the scan interval, and if so how and is there some issues i need to take under consideration when doing that ?

    Instead, you will have to have two advdata instances, where you pass one as the argument to the _advdata_update function, and then you may update the other advdata instance, before calling _advdata_update again with the most recently updated(not currently in use) advdata instance.

    i could not find any _advdata_update function in the ble_advdata.h file. if or when i find the function you are referring to then do i need to stop the advertising and restart it like in the following code, and update in the middle or i can only update advdata in the timer handler and the broadcasting continue in its interval ?:

    sd_ble_gap_adv_stop(m_adv_handle);
        err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
        APP_ERROR_CHECK(err_code);
        err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
        APP_ERROR_CHECK(err_code);
        err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);
        APP_ERROR_CHECK(err_code);

    This can happen more often if the devices are far apart, and if they are operating in a 2.4 GHz noisy environment

    if i am using the ADDRESS FILTER:

        err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_ADDR_FILTER, m_target_periph_addr); // Ziv
        APP_ERROR_CHECK(err_code);
    
        // Setting filters for scanning.
        err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_ADDR_FILTER, false); // Ziv
        APP_ERROR_CHECK(err_code);

    does it change something regarding noises or every message from any device is received and read all the way anyway  and only then is filtered ?

    How are you measuring this by the way

    i toggle a pin in the case of ' NRF_BLE_SCAN_EVT_FILTER_MATCH '  in the ' scan_event_handler(...) '

    i look at the pin in the scope in a 50ms for each square 

    Regarding the second thing:

    if you can recommend a gateway or a device, gateway or other that connects to a pc via usb and comes with a convenient API so i can wrap it and supply the customer with an easy API for the data needed to be transferred to all the 150 units via bl, that would be great. 

    i read some about the nrf52840 dongle but someone wrote that it has a lot of over had regarding softdevice and serialization if i recall and actually recommend using a designated device (for us price of such device is not an issue)

    hope to read from you soon 

    best regards

    Ziv

  • Hello Ziv,

    ziv123 said:
    hopefully we can resolve this before the end of this week 

    Yes, hopefully we will resolve this before the weekend.

    ziv123 said:
    thanks, it compiles now 

    That it good. Are you experiencing any unexpected behavior since switching to the advertising module?

    ziv123 said:

    how ever, is there an example that uses the advertising library to get a better sense of needed configuration for the ble_advertising_t element ?

    if not, how should it be configured and will the 2 libraries work together ?

    Unfortunately no, none of the SDK examples currently use the advertising library - however, you could take a look at the "Usage" section of the library documentation to get started. You can also see the description of each config parameter here.
    Fortunately, the advdata structure and advertising module goes well together, there is no problem at all using both.

    ziv123 said:
    ... WELL i have tried to implement it but i see no change in the nrf scan app, and after looking some more to the function it's not clear to me why i need 2 instances since one is for scanned data and i am working with beacon 

    Could you confirm for me that you are working with SDK 16, or if you have upgraded to SDK 17 since we last spoke about it?
    If you are using SDK 17 then you do not need to have two advertising data structures, you can just work with a single one.
    You do not need to provide scan response data.

    ziv123 said:
    here my code, its a bit messy cause it's just to see its working , you can see the commented lines which do give change in data packets via nrf scan app

    Are you saying that the code as you have shared it does nothing to change the advertising data, except if you include the commented part at the end?
    The advdata_update function handles the necessary encoding and configuration as well, please take a look in the advertising library source code.

    ziv123 said:

    another thing, maybe i will open a new topic for that, regarding the nrf52840 dongle.. is it possible to program it to do the following via the nrf programmer (from the pc app):

    receive data via usb as uart and advertise it in a way that if no new data is arriving via uart the dongle keeps on advertising every 30ms (basically to receive data and update the advdata every time new data is received, or send each received mesage for several times in shortest intervals (30ms) unless new data arrives (also is it possible to program it to change some part of the data by itself each time it receives data from uart(meaning send the same data 10 times for instance, each time with one byte change in the data)

    that is instead of programming it via some development boards debugger ? 

    In short; yes, this is possible. You can either program the Dongle directly as you would have programmed a DK, or you can create a desktop application using the pc-ble-driver that controls the dongle. However, please open a new ticket for this subject if you require more information about this, as it is diverging from your initial ticket.

    Best regards,
    Karl

  • hi Karl

    Could you confirm for me that you are working with SDK 16

    yes, i checked the zip file i downloaded, and working with -> "nRF5_SDK_16.0.0_98a08e2.zip"

    Are you saying that the code as you have shared it does nothing to change the advertising data, except if you include the commented part at the end?

    YES, when using the commented lines instead of the advdata_update function then i see change in data in the nrf_connect_app on my cell phone. but when i am using the function as shown in the code i added i don't see a change in the data in the same app on my cell phone

    i will open a new topic on the dongle issue

    hope to read from you soon

    best regards

    Ziv

  • Hello again Ziv,

    ziv123 said:
    yes, i checked the zip file i downloaded, and working with -> "nRF5_SDK_16.0.0_98a08e2.zip"

    Great, thank you for confirming this.

    In SDK 16 you still need the two instances of the advertising struct, for the update function to work - as you have.
    The reason for this can be seen in the sd_ble_gap_adv_set_configure API reference.
    In SDK 17 this in handled by the advdata_update function internally.

    This might be a long-shot, but could you attempt to split the advdata buffers entirely?
    I do not know how they are initialized, so I say this to ensure that there are nothing shared between the buffers.

    ziv123 said:
    YES, when using the commented lines instead of the advdata_update function then i see change in data in the nrf_connect_app on my cell phone. but when i am using the function as shown in the code i added i don't see a change in the data in the same app on my cell phone

    Yes, I would expect the commented out lines to work on their own, as this is a sure-fire way of changing the advertising data.  

    ziv123 said:
    i will open a new topic on the dongle issue

    Great.

    Looking forward to resolving this issue together.

    Best regards,
    Karl

  • hi Karl 

    This might be a long-shot, but could you attempt to split the advdata buffers entirely?
    I do not know how they are initialized, so I say this to ensure that there are nothing shared between the buffers.

    what do you mean by split the advdata buffers entirely ? ??

    ble_advdata_t advdata[2];
    this is how they are first declaired

    static void advertising_init(void)
    {
        uint32_t      err_code;
        //ble_advdata_t advdata;
        uint8_t       flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
    
        //ble_advdata_manuf_data_t manuf_specific_data;
    
        manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER;
    
    #if defined(USE_UICR_FOR_MAJ_MIN_VALUES)
        // If USE_UICR_FOR_MAJ_MIN_VALUES is defined, the major and minor values will be read from the
        // UICR instead of using the default values. The major and minor values obtained from the UICR
        // are encoded into advertising data in big endian order (MSB First).
        // To set the UICR used by this example to a desired value, write to the address 0x10001080
        // using the nrfjprog tool. The command to be used is as follows.
        // nrfjprog --snr <Segger-chip-Serial-Number> --memwr 0x10001080 --val <your major/minor value>
        // For example, for a major value and minor value of 0xabcd and 0x0102 respectively, the
        // the following command should be used.
        // nrfjprog --snr <Segger-chip-Serial-Number> --memwr 0x10001080 --val 0xabcd0102
        uint16_t major_value = ((*(uint32_t *)UICR_ADDRESS) & 0xFFFF0000) >> 16;
        uint16_t minor_value = ((*(uint32_t *)UICR_ADDRESS) & 0x0000FFFF);
    
        uint8_t index = MAJ_VAL_OFFSET_IN_BEACON_INFO;
    
        m_beacon_info[index++] = MSB_16(major_value);
        m_beacon_info[index++] = LSB_16(major_value);
    
        m_beacon_info[index++] = MSB_16(minor_value);
        m_beacon_info[index++] = LSB_16(minor_value);
    #endif
    
    ///ziv addition:
      //  static uint8_t i = 4;
      //  if( i >= SET_VALUES_ARRAY )
      //  {
      //      i = 0;
      //  }
       // uint8_t idx = i++;
       m_beacon_info[12] = spin_angle[3];
       m_beacon_info[13] = (spin_direction[3] | speed[3]);
    
    // ziv addition end  
    
        manuf_specific_data.data.p_data = (uint8_t *) m_beacon_info;
        manuf_specific_data.data.size   = APP_BEACON_INFO_LENGTH;
    
        // Build and set advertising data.
        memset(&advdata[advdata_idx], 0, sizeof(advdata[advdata_idx]));
    
        advdata[advdata_idx].name_type             = BLE_ADVDATA_NO_NAME;//BLE_ADVDATA_SHORT_NAME;//BLE_ADVDATA_NO_NAME;
        advdata[advdata_idx].flags                 = flags;
        advdata[advdata_idx].p_manuf_specific_data = &manuf_specific_data;
    
        // Initialize advertising parameters (used when starting advertising).
        memset(&m_adv_params, 0, sizeof(m_adv_params));
    
        m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
        m_adv_params.p_peer_addr     = NULL;    // Undirected advertisement.
        m_adv_params.filter_policy   = BLE_GAP_ADV_FP_ANY;
        m_adv_params.interval        = NON_CONNECTABLE_ADV_INTERVAL;
        m_adv_params.duration        = 0;       // Never time out.
    
        err_code = ble_advdata_encode(&advdata[advdata_idx], m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
        APP_ERROR_CHECK(err_code);
    
        err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
        APP_ERROR_CHECK(err_code);
    }

    this is the advertising init func, in which i initiate only one of them, and after that, in the timer handler which i sent before i do this:

    advdata[advdata_next_idx] = advdata[advdata_idx];

    which to my understanding copies all the defines and configs of one instance to the other  (not sure it is semantically correct to say it but you understood i belive)

     

    best regards

    Ziv

  • Hello Ziv,

    ziv123 said:
    which to my understanding copies all the defines and configs of one instance to the other  (not sure it is semantically correct to say it but you understood i belive)

    This might be the issue here, I do not think this is correct.
    What you are doing here is creating a shallow copy of the advdata struct. So, you are in fact just using the same single buffer.
    If you would like to check this, please try to print out the value of the advdata[advdata_idx] and advdata[advdata_next_idx] pointers following this line of code and see what they point to.
    If you are to do your updates like this, please ensure that you are making a deep copy of the advdata struct.
    Do this, and see if you then are able to update your advertising data using the _advdata_update function. I look forward to hearing if this resolves your issue!

    Please see this stackoverflow thread for a detailed explanation on shallow vs deep copying.

    Best regards,
    Karl 

Reply
  • Hello Ziv,

    ziv123 said:
    which to my understanding copies all the defines and configs of one instance to the other  (not sure it is semantically correct to say it but you understood i belive)

    This might be the issue here, I do not think this is correct.
    What you are doing here is creating a shallow copy of the advdata struct. So, you are in fact just using the same single buffer.
    If you would like to check this, please try to print out the value of the advdata[advdata_idx] and advdata[advdata_next_idx] pointers following this line of code and see what they point to.
    If you are to do your updates like this, please ensure that you are making a deep copy of the advdata struct.
    Do this, and see if you then are able to update your advertising data using the _advdata_update function. I look forward to hearing if this resolves your issue!

    Please see this stackoverflow thread for a detailed explanation on shallow vs deep copying.

    Best regards,
    Karl 

Children
  • hi Karl

    it did not solve (unless i did something wrong.. here is my code for init advertising with setting the 2 instances:

        // Build and set advertising data.
        memset(&advdata[0], 0, sizeof(advdata[0]));
        memset(&advdata[1], 0, sizeof(advdata[1]));
    
        advdata[0].name_type        = BLE_ADVDATA_NO_NAME;//BLE_ADVDATA_SHORT_NAME;//BLE_ADVDATA_NO_NAME;
        advdata[1].name_type        = BLE_ADVDATA_NO_NAME;
        advdata[0].flags            = flags;
        advdata[1].flags            = flags;
        advdata[0].p_manuf_specific_data = &manuf_specific_data;
        advdata[1].p_manuf_specific_data = &manuf_specific_data;
    
        // Initialize advertising parameters (used when starting advertising).
        memset(&m_adv_params, 0, sizeof(m_adv_params));
    
        m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
        m_adv_params.p_peer_addr     = NULL;    // Undirected advertisement.
        m_adv_params.filter_policy   = BLE_GAP_ADV_FP_ANY;
        m_adv_params.interval        = NON_CONNECTABLE_ADV_INTERVAL;
        m_adv_params.duration        = 0;       // Never time out.
    
        err_code = ble_advdata_encode(&advdata[0], m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
        APP_ERROR_CHECK(err_code);
        err_code = ble_advdata_encode(&advdata[1], m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
        APP_ERROR_CHECK(err_code);
    
        err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
        APP_ERROR_CHECK(err_code);
    }

    and here is the code for the timer handler:

    static void data_update_timer_handler(void* p_context)
    {
        ret_code_t err_code;
    //    err_code = sd_ble_gap_adv_stop(m_adv_handle);
    //    APP_ERROR_CHECK(err_code);
    
        static uint8_t i = 0;
        if( i >= SET_VALUES_ARRAY )
        {
            i = 0;
        }
        uint8_t idx = i++;
        m_beacon_info[12] = spin_angle[idx];
        m_beacon_info[13] = (spin_direction[idx] | speed[idx]);
        NRF_LOG_INFO("%d",m_beacon_info[12]);
    
        manuf_specific_data.data.p_data = (uint8_t *) m_beacon_info;
        manuf_specific_data.data.size   = APP_BEACON_INFO_LENGTH;
    
        if(0 == advdata_idx ) advdata_idx = 1;
        else if( 1 == advdata_idx) advdata_idx = 0;
    
        advdata[advdata_idx].p_manuf_specific_data = &manuf_specific_data;
        
        ble_advertising_advdata_update(&ble_adv ,&advdata[advdata_idx], NULL /*&advdata[advdata_next_idx]*/);
        //advdata_idx = advdata_next_idx;
    
    //    sd_ble_gap_adv_stop(m_adv_handle);
    //    err_code = ble_advdata_encode(&advdata[advdata_idx], m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
    //    APP_ERROR_CHECK(err_code);
    //    err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
    //    APP_ERROR_CHECK(err_code);
    //    err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);
    //    APP_ERROR_CHECK(err_code);
    //    advdata_idx = advdata_next_idx;
    }

    it will be best if we would find out why this is not working but i wonder if it will not be easier to just download sdk 17, maybe there is such an example working in that sdk, of updating message data while advertising ?

    though i would prefer staying with sdk 16 for now and solv it but i am late on this project and pulled to other projects every few days so .. hopefuly you can help me with that

    best regards

    Ziv

  • Hello Ziv,

    Could you do an error check on the return value of the ble_advertising_advdata_update call?
    When you do not check the error code, you will not be made aware if the function fails - you should always check the returned error code.
    When checking the return value, are you getting any errors?
    Remember to define DEBUG in your preprocessor defines, to see the error output message in the log.

    Also, by calling ble_advdata_encode twice with the same destination you will override the data placed there by the first function upon return of the second function call.
    I would ask you to try this again, but this time - for simplicity - really differentiate the two buffers you are keeping. I.e separate them by name, to make things easier. Ideally, have zero overlap between the two namespaces and usage.

    ziv123 said:
    it will be best if we would find out why this is not working but i wonder if it will not be easier to just download sdk 17, maybe there is such an example working in that sdk, of updating message data while advertising ?

    There is unfortunately not such an example in the SDK 17, but using the _advdata_update function will be straight forward there - no need to keep two buffers.
    In essence, you can then just call the function with the updated advertising data, and have the new data begin advertising.
    You could modify the beacon example in SDK 17 to do this, to see for yourself how it is to use.

    ziv123 said:
    though i would prefer staying with sdk 16 for now and solv it but i am late on this project and pulled to other projects every few days so .. hopefuly you can help me with that

    I too hope that my above suggestions helps resolve this issue.

    Best regards,
    Karl

  • hi Karl 

    well it returns an error from here:

    if (p_advertising->initialized == false)
        {
            return NRF_ERROR_INVALID_STATE;
        }

    and indeed i did not initialize the :

    ble_advertising_t ble_adv;

    i asked about it before and then i didn't do it eventually.. but now after going over the links you sent, i am not sure what values should be in the second parameter of the init function:

    ble_advertising_init(&ble_adv, ???);

    may be you can help me understand the datasheet better ?

    best regards

    Ziv

  • Hello Ziv,

    ziv123 said:

    ble_advertising_init(&ble_adv, ???);

    may be you can help me understand the datasheet better ?

    The ble_advertising_init API Reference details what the second parameter must be, for the call to be successful. In essence, the second parameter is a ble_advertising_init_t struct, which contains all the information the module needs to start advertising, including config, event- and error-handler.

    Please let me know if there is anything in particular which is unclear in the documentation so I may explain.

    Best regards,
    Karl

  • hi Karl

    i guess i am doing something wrong cause the ble_advertising_init(..) falls in here:

     ret = sd_ble_gap_adv_set_configure(&p_advertising->adv_handle, NULL, &p_advertising->adv_params);
        VERIFY_SUCCESS(ret);
    

    the ret = 7, error, i can not find what goes in the sd_ble_gap_adv_set_configure(..) 

    also, it is not clear to me if i need to also use the 

    static void advertising_init(void) 

    and inside it call the ble_advertising_init(..) cause it seems there is and advdata initialization with in it

    anyway .. this is what i have tried

    static void advertising_init(void)
    {
        uint32_t      err_code;
        //ble_advdata_t advdata;
        uint8_t       flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
    
        //ble_adv_modes_config_t ble_adv_mode = true;
        //ble_advdata_manuf_data_t manuf_specific_data;
        ble_adv_init.config.ble_adv_fast_enabled = true;
    
        ble_adv_init.advdata.flags = flags;
        ble_adv_init.advdata.name_type = BLE_ADVDATA_NO_NAME;
        ble_adv_init.advdata.p_manuf_specific_data = &manuf_specific_data;
    
        //ble_adv_init.srdata = NULL;
        ble_adv_init.error_handler = NULL;
        ble_adv_init.evt_handler = NULL;
    
        ble_advertising_init(&ble_adv, &ble_adv_init);
        manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER;
    
    #if defined(USE_UICR_FOR_MAJ_MIN_VALUES)
        // If USE_UICR_FOR_MAJ_MIN_VALUES is defined, the major and minor values will be read from the
        // UICR instead of using the default values. The major and minor values obtained from the UICR
        // are encoded into advertising data in big endian order (MSB First).
        // To set the UICR used by this example to a desired value, write to the address 0x10001080
        // using the nrfjprog tool. The command to be used is as follows.
        // nrfjprog --snr <Segger-chip-Serial-Number> --memwr 0x10001080 --val <your major/minor value>
        // For example, for a major value and minor value of 0xabcd and 0x0102 respectively, the
        // the following command should be used.
        // nrfjprog --snr <Segger-chip-Serial-Number> --memwr 0x10001080 --val 0xabcd0102
        uint16_t major_value = ((*(uint32_t *)UICR_ADDRESS) & 0xFFFF0000) >> 16;
        uint16_t minor_value = ((*(uint32_t *)UICR_ADDRESS) & 0x0000FFFF);
    
        uint8_t index = MAJ_VAL_OFFSET_IN_BEACON_INFO;
    
        m_beacon_info[index++] = MSB_16(major_value);
        m_beacon_info[index++] = LSB_16(major_value);
    
        m_beacon_info[index++] = MSB_16(minor_value);
        m_beacon_info[index++] = LSB_16(minor_value);
    #endif
    
    ///ziv addition:
      //  static uint8_t i = 4;
      //  if( i >= SET_VALUES_ARRAY )
      //  {
      //      i = 0;
      //  }
       // uint8_t idx = i++;
       m_beacon_info[12] = spin_angle[3];
       m_beacon_info[13] = (spin_direction[3] | speed[3]);
    
    // ziv addition end  
    
        manuf_specific_data.data.p_data = (uint8_t *) m_beacon_info;
        manuf_specific_data.data.size   = APP_BEACON_INFO_LENGTH;
    
        // Build and set advertising data.
        memset(&advdata_1, 0, sizeof(advdata_1));
        memset(&advdata_2, 0, sizeof(advdata_2));
    
        advdata_1.name_type        = BLE_ADVDATA_NO_NAME;//BLE_ADVDATA_SHORT_NAME;//BLE_ADVDATA_NO_NAME;
        advdata_2.name_type        = BLE_ADVDATA_NO_NAME;
        advdata_1.flags            = flags;
        advdata_2.flags            = flags;
        advdata_1.p_manuf_specific_data = &manuf_specific_data;
        advdata_2.p_manuf_specific_data = &manuf_specific_data;
    
        // Initialize advertising parameters (used when starting advertising).
        memset(&m_adv_params, 0, sizeof(m_adv_params));
    
        m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
        m_adv_params.p_peer_addr     = NULL;    // Undirected advertisement.
        m_adv_params.filter_policy   = BLE_GAP_ADV_FP_ANY;
        m_adv_params.interval        = NON_CONNECTABLE_ADV_INTERVAL;
        m_adv_params.duration        = 0;       // Never time out.
    
        err_code = ble_advdata_encode(&advdata_1, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
        APP_ERROR_CHECK(err_code);
        err_code = ble_advdata_encode(&advdata_2, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
        APP_ERROR_CHECK(err_code);
    
        err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
        APP_ERROR_CHECK(err_code);
    }
    

    hope you can tell me what i am doing wrong ???

    best regards

    Ziv

Related