6 Replies Latest reply on May 12, 2015 12:33 AM by userc_14409

    bleprofile_GenerateADVData in central role


      like in the hello_client example, i need to scan and advertise at the same time. So i call:




      bleprofile_Discoverable(HIGH_UNDIRECTED_DISCOVERABLE, NULL);


      That seems to work, i see the device advertising and scanning. But if i try to modify the advertising data with a call to the bleprofile_GenerateADVData, then something goes broken and the device does not advertise anymore.

      Is it possible to change the advertising data while in central role?


      Thank you.



        • 1. Re: bleprofile_GenerateADVData in central role

          In order to scan and advertise at the same time try using blecm_startAdv() and blecm_startScan() together, the stack will handle which one happens when.


          // HCIULP Advertising
          #define     HCIULP_ADV_SCAN_IND                              0x02
          #define     HCIULP_ADV_NONCONN_IND                           0x03
          #define     HCIULP_ADV_CHANNEL_37                            0x01
          #define     HCIULP_ADV_CHANNEL_38                            0x02
          #define     HCIULP_ADV_CHANNEL_39                            0x04
          #define     HCIULP_ADV_CHANNEL_MAP_MASK                      (HCIULP_ADV_CHANNEL_37 | HCIULP_ADV_CHANNEL_38 | HCIULP_ADV_CHANNEL_39)
          #define     HCIULP_ADV_FILTER_POLICY_WHITE_LIST_NOT_USED     0x00    // white list not used
          #define     HCIULP_ADV_FILTER_POLICY_WHITE_LIST_USED         0x01    // white list used


          // advType:           Type of advertisement.  0 : ADV_IND; 1 : ADV_DIRECT_IND; 2 : ADV_SCAN_IND; 3 : ADV_NONCONN_IND; others are invalid.
          // adcInterval:       Min and Max advertisement interval in BT slots. Min = 20mS; Max = 10.24s. Not valid for ADV_DIRECT_IND
          // advChannel:        Mask of channels to advertise (bitwise set to enable). 1 = Ch 37; 2 = Ch 38; 4 = Ch 39.
          // advAdrType:        Own address type. 0 : Public; 1 : Random device address; Others are reserved.
          // advFilterPolicy:   ADV filter policy. 0 : Allow scan and connect from any; 1 : Allow scan from whitelist, connect from any; 2 : Allow scan from any, connect from whitelist; 3 : Allow scan and connect from whitelist only.
          // initiatorAdrType:  Direct address type. 0 : Public; 1 : Random device address; Others are reserved.
          // initiatorAdr:      Address of the device to be connected when ADV_DIRECT_IND
          // Start advertisements
              HCIULP_ADV_SCAN_IND,                            // Non-connectable, scannable undirected advertisement
              160,                                            // Adv interval 160*0.625ms = 100ms
              HCIULP_ADV_CHANNEL_MAP_MASK,                    // All channels
              HCIULP_PUBLIC_ADDRESS,                          // int32 advAdrType,
              HCIULP_ADV_FILTER_POLICY_WHITE_LIST_NOT_USED,   // int32 advFilterPolicy,
              HCIULP_PUBLIC_ADDRESS,                          // int32 initiatorAdrType,
              NULL);                                          // uint8* initiatorAdr


          // scanType:          Type of scan.  0 : HCIULP_PASSIVE_SCAN = No SCAN_REQ packets shall be sent; 1 : HCIULP_ACTIVE_SCAN = SCAN_REQ packets may be sent.
          // scanInterval:      Time interval from when the Controller started its last LE scan until it begins the subsequent LE scan.
          // scanWindow:        The duration of the LE scan.
          // scanAdrType:       Own address type. 0 : Public; 1 : Random device address; Others are reserved.
          // scanFilterPolicy:  Scan filter policy.
          // filterDuplicates:  Filter duplicates.
          // Start scanning
              HCIULP_ACTIVE_SCAN,                             // Active scanning. SCAN_REQ packets may be sent.
              96,                                             // Scan interval 96*0.625ms = 60ms
              48,                                             // Scan duration 48*0.625ms = 30ms
              HCIULP_PUBLIC_ADDRESS,                          // int32 scanAdrType
              HCIULP_SCAN_FILTER_POLICY_WHITE_LIST_NOT_USED,  // int32 scanFilterPolicy
              HCIULP_SCAN_DUPLICATE_FILTER_ON);               // int32 filterDuplicates


          In order to modify your advertising data try bleprofile_notifyAdvPacketTransmissions(&update_adv_packet, 2500). This will register the function "update_adv_packet" to be called 2.5msec before and after and adv packet is sent. However in order to get his function to work you need to add "APP_PATCHES_AND_LIBS += additional_advertisement_control.a" to your makefile AND MAKE SURE YOU ARE USING SDK 2.2.1. There is a bug in SDK 2.2.0 that prevents bleprofile_notifyAdvPacketTransmissions from working. See the my_beacon example.

          • 2. Re: bleprofile_GenerateADVData in central role

            Hi, thank you for your answer. It is getting better, but there is still some issue. Now i can advertise and scan at the same time and i can set the advertising packet, but only the first time during the _create function. The callback registered with bleprofile_notifyAdvPacketTransmissions is not getting called. Attached my create function.


            • 3. Re: bleprofile_GenerateADVData in central role

              ok,if i change the advertising data with the function bleprofile_GenerateADVData, everything works. The callback is called. The problem seems to come out when i try to change the scan response data too, with a call to the bleprofile_GenerateScanRspData function, in the callback.

              • 4. Re: bleprofile_GenerateADVData in central role

                Its possible that the Scan Response data doesn't work with the bleprofile_notifyAdvPacketTransmissions() function, only advertising packets. I'm not too sure about this since I only just got the function working myself a few days ago and I haven't actually tried updating the SCR packet too.

                • 5. Re: bleprofile_GenerateADVData in central role

                  ok, for now i will not use the SCR packet. Thank you very much for your help.

                  • 6. Re: bleprofile_GenerateADVData in central role

                    No problem, I might get around to testing this myself sometime as it may come in handy in the future.