13 Replies Latest reply on Feb 18, 2016 2:24 PM by userc_19497

    no or unkomplete ADV in hello_client

      I tried the connection between my hello_client-application and a smartphone,

      but there is a strange problem:

       

      The application is sending ADV with the default name of the device.

      But if the device is running, there are no more ADVs received by my phone.

      It seems like the ADVs are only sent while the create-function is called.

      After it, there are no more ADVs.

       

      After that, I tried to set the ADV-Data like I did on other devices (no hello_clients)

      like this:

       

           // Fill GATT-DB
           // Device name
           memset(db_name.pdu, 0x00, (size_t)HELLO_CLIENT_NAME_LENGTH_U8);
           (void)snprintf(macString, sizeof(macString) ,"%02X%02X%02X%02X%02X%02X", macAddr[5], macAddr[4], macAddr[3], macAddr[2], macAddr[1], macAddr[0]);
           (void)snprintf((char *)db_name.pdu, (size_t)HELLO_CLIENT_NAME_LENGTH_U8,"%s_%s", HELLO_CLIENT_DEVICE_NAME, macString);
           db_name.len = HELLO_CLIENT_NAME_LENGTH_U8;
           /*@-compdef@*/
           (void)bleprofile_WriteHandle(0x0016, &db_name);
           /*@=compdef@*/
      
           // advertise first vendor specific service
           if (sizeof(hello_client_uuid_main_service) == 16) {
                // total length should be less than 31 bytes
                BLE_ADV_FIELD adv[3];
                BLE_ADV_FIELD scr[1];
      
                /*@-usedef@*/
                // flags
                adv[0].len     = 1 + 1;
                adv[0].val     = ADV_FLAGS;
                adv[0].data[0] = (UINT8)(LE_LIMITED_DISCOVERABLE | BR_EDR_NOT_SUPPORTED);
      
                adv[1].len     = 16 + 1;
                adv[1].val     = ADV_SERVICE_UUID128_COMP;
                memcpy(adv[1].data, &hello_client_uuid_main_service[0], 16);
      
                // Tx power level
                adv[2].len     = TX_POWER_LEN+1;
                adv[2].val     = ADV_TX_POWER_LEVEL;
                adv[2].data[0] = bleprofile_p_cfg->tx_power_level;
      
                // name
                scr[0].len      = HELLO_CLIENT_NAME_LENGTH_U8 + 1;
                scr[0].val      = ADV_LOCAL_NAME_COMP;
                memcpy(scr[0].data, (char *)db_name.pdu, (size_t)(scr[0].len - 1));
                /*@=usedef@*/
      
                bleprofile_GenerateADVData(adv, 3);
                bleprofile_GenerateScanRspData(scr, 1);
           }
      

       

      With that changes, ADV will be sent all the time, but there is no name visible.

      WICED Smart Explerer is showning the MAC-Address and in the lower line "Device name not available"

      nRF Master Control Panel is showing as name "n/a" and also the MAC-Address.

      Also the device-name is still visible while starting. After the application is running, the name is lost.

       

      My application is scanning and advertising at the same time, but even if i stop scanning, this won't change anything.

       

      Is there something else called after the create-function?

      Is there something else interferring to the ADV-Data?

       

      I'm using the 920736S (the module)

      with SDK 2.2.1 on Ubuntu.

        • 1. Re: no or unkomplete ADV in hello_client

          Hello. Did you make any changes in the hello_client that you are running other than the code snippet that you included?

           

          What is the smartphone you are using? iOS or Android?

          If you are using Android, I have seen behaviors where the Android device will stop receiving advertisements after the first one is received even when the advertisements are being sent out. I have no idea why this happens. My only guess is that this happens because of how the stack on those Android devices are implemented. However this behavior is only seen in some Android devices. Android devices with most recent hardware and Android version seems to behave fine.

           

          As for as your code, you are not really changing it so that ADV will be sent all the time. You are changing the advertisement packet payloads (ie. what you are advertising).

           

          In hello_client, the advertisement starts because of the following function call in the create function:

          bleprofile_Discoverable(HIGH_UNDIRECTED_DISCOVERABLE, NULL);

           

          Then if you set hello_client idling, it should keep advertising, because it makes the same function call in the timer_callback function.

           

          If you want your app to receive a callback when the advertisement stops, then you can register a callback function for this event in the create function:

          bleprofile_regAppEvtHandler(BLECM_APP_EVT_ADV_TIMEOUT, advertisement_stopped_callback)

          where the last parameter is your defined function.

           

          Does this help? Please let us know.

          Thanks.

           

          James

          • 2. Re: no or unkomplete ADV in hello_client

            Hi James,

             

            Thank you for your quick response.

             

            Of course there are a lot of other changes in my application.

            I'm using ADC and manage handles of connected slaves.

            On some slavles I configure to receive notification/indication,

            on other slaves I'm writing data.

            I think I could append the create-function if you want to have a look on it.

             

            What is the smartphone you are using? iOS or Android?

            I'm using Android 4.4.2 for testing.

            But I'm running two sensors, one with the changed ADV-Data and one without.

            Both with different MAC-Addresses.

            The phone is receiving the ADV from the sensor with the changed ADV-Data, but it won't show ADV from the other one.

            Perhaps I could start one of the other devices with correct ADV-Data to check if the phone is able to receive that, but I don't think it's a problem of the phone.

             

            I'm using the advertisement_stopped_callback to restart the ADVs.

            As I mentioned above, if I add that snipped, the application is advertising all the time.

            But it seams there is no device-name in the ADV.

             

            I compared the ADV-Data from my hello_client app with another application based on the hello_sensor application (with the nRF Master Control Panel as it shows that information).

            I noticed that the 'Type' of hello_client is 'UNKNOWN', on hello_sensor it is 'BLE only'

            The Flags are the same (LimitedDiscoverable, BrEdrNotSupported)

            The UUIDs are of course different.

            Tx Power Level is shown twice in the hello_client, but only once on the hello_sensor application.

            Instead of the second Power Level there is the Complete Local Name shown of the hello_sensor application.

             

            I removed blecen_Scan(NO_SCAN) (this is done later),

            now the advertisements start after the first timeout (advertisement stopped callback was called).

            Still without the name, but now there are no advertisements the first 300 seconds after the boot.

            Do you know why?

            • 3. Re: no or unkomplete ADV in hello_client

              Hello.

               

              I use both iOS(iphone 5) and Android(nexus 7,9 with Android version 5.1.1).

               

              So to reiterate your problem, you have two peripherals advertising and you want to see both advertisements from your phone, but you only see one of them on your phone. Is that correct? It would help me if you can reiterate your problem again.

               

              Which app are you using on your phone? WICED Smart Explorer? Do your peripherals both have your modified hello_client app?

              Can you confirm your peripherals are both advertising when your problem occurs by checking the debug traces?

               

              With the default hello_client and hello_app, these are the results (I used BLE Scanner app in Android):

              The first advertisement packet is hello_client's

              and the second advertisement packet is from hello_sensor.

              So right now, I'm not sure what the problem is.

               

              As for you code snippet and the advertisement packet not having the local name in the advertisement packet, it's true, but I think that's fine. Your phone should still be able to see the name of the device, because you are also adding scan response packet with the device name.

               

              James

              • 4. Re: no or unkomplete ADV in hello_client

                Hi James,

                 

                Here you can see a screenshot of both devices. The lamp is sensor, the unknown device is the hello_client.

                bothDevices.png

                Detailed Information about the Lamp:

                lamp_info.png

                lamp_raw_info.png

                Also Information about the hello_client:

                hello_client_info.png

                hello_client_raw_info.png

                The screenshots are from my Note 4 with nRF Master Control Panel,

                But it's the same result as on a second S4 Mini with nRF Master Control Panel and WICED Smart Explorer. I also tested other apps but all with the same result. No name of the hello_client, but showing the name of the other devices (hello_sensor).

                • 5. Re: no or unkomplete ADV in hello_client

                  It seems like the modified hello_client is changing the advertisement packet not according to your original code snippet.

                   

                  Would be able to upload your hello_client file?

                  You can email me if that's more comfortable for you.

                   

                  James

                  • 6. Re: no or unkomplete ADV in hello_client
                    MichaelF_56

                    You can email what userc_19497 is asking for to communities-list@broadcom.com and I will make sure it gets to him.

                     

                    Reference this thread (insert a link in the email).

                    • 7. Re: no or unkomplete ADV in hello_client
                      MichaelF_56

                      I forwarded the example you sent me over to userc_19497

                      • 8. Re: no or unkomplete ADV in hello_client

                        Hi userc_19497

                         

                        Have you checked my sample application?

                        I now tested the application with WICED 2.2.2, but there is also no ADV after start.

                        After ADV timedout and restart, I can see ADV, but without name.

                        • 9. Re: no or unkomplete ADV in hello_client

                          Sorry it took so~ long to get back to you on this, but we are now able to see the device name.

                          There seems to be some bug in the stack firmware; that’s the code didn’t work.

                          The work-around for it is to generate the scan rsp data before the advertisement data.

                           

                          I.E. call this function:

                            bleprofile_GenerateScanRspData(scr, 1);

                          before:

                             bleprofile_GenerateADVData(adv, 3);

                           

                          After making that change, I was able to see the device name.

                          Please let me know if this fixes your problem.

                          Again, sorry it took so long.

                           

                          James

                          • 10. Re: no or unkomplete ADV in hello_client

                            Hi James,

                             

                            Thanks a lot.

                            After I changed the order of the two functions I now can see also the name of the device :-)

                            • 11. Re: no or unkomplete ADV in hello_client

                              Hi userc_19497,

                               

                              Now the name is visible,

                              but the ADV-Data are not correct anymore!

                               

                              I only changed the order of the two functions. The data should be the same on both devices (but not the MAC!)

                               

                              Here are some screenshots:

                              ADV_no_name.png

                              ADV without the name

                               

                              ADV_with_name.png

                              ADV with the name

                               

                              Flags_ADV_no_name.png

                              Flags without the name

                               

                              Flags_ADV_with_name.png

                              Flags with the name

                               

                              Info_ADV_no_name.png

                              Data without the name

                               

                              Info_ADV_with_name.png

                              Data with the name

                               

                              Raw_Data_no_name.png

                              Raw Data without the name

                               

                              Raw_Data_with_name.png

                              Raw Data with the name

                               

                              As you can see I have not the name, but no UUID, also the Flags are not correct anymore.

                               

                              So I need another solution.

                              • 12. Re: no or unkomplete ADV in hello_client

                                Hi userc_19497

                                 

                                After two weeks:

                                New updates about this problem?

                                Will it be fixed in the next SDK? Or a patch for the problem?

                                 

                                At the moment I'm still without a working device name, but the UUID is more important.

                                • 13. Re: no or unkomplete ADV in hello_client

                                  Hello. I'm so sorry it took really long time to get back to you again.

                                  I've really been looking into this issue for awhile though:p

                                   

                                  Good news. I now can change both adv and scanrsp data packets correctly.

                                  I still don't know what the root cause is, but in order to generate right packets, you need to limit the max number of connections.

                                  In the create function, you are calling blecm_ConMuxInit with argument equal to 7.

                                  For some reason that number is screwing with the generation of the adv and scanrsp packets.

                                  It seems to work fine with the argument equal to 4 (the same number used in hello_client); anything higher than that will not generate correct packets.

                                   

                                  I'll ask the developers why this is happening and get back to you.

                                  Thank you for being patient with us.

                                   

                                  James