13 Replies Latest reply on Dec 22, 2014 6:02 PM by hachc_2137126

    Advertising during connection

    jora_1327726

      I'm not able to keep advertisements going while a connection is up.  Debug suggest that advertisements are being shut off by the stack.  From my connection_up callback:

       

      16:52:55 - connection_up: ac220b4088d0 h=64

      16:52:55 - Tx buffer = 15

      16:52:55 -

      16:52:55 - blecm evt handler:

      16:52:55 - 0e04010a200c

      16:52:55   Connection is UP.

      16:52:55   profile idle timer stop

      16:52:55   connUp

      16:52:55   noAdv

      16:52:55   BLE_idleconn:timer(0)

       

      This is after commenting out the line that explicitly stops advertisements. I also tried enabling via bleprofile_Discoverable in the same spot with no success.  Debug showed  BLE_low_un_adv:timer(0) but nothing was picked up on my scans.  Ideas?

       

       

      void my_connection_up(void)

      {

          isss_hs_connection_handle = (UINT16)emconinfo_getConnHandle();

          UINT8 *bda = (UINT8 *)emconninfo_getPeerPubAddr();

       

          // Save address of the connected device and print it out.

          memcpy(isss_hs_remote_addr, bda, sizeof(isss_hs_remote_addr));

       

          ble_trace3("connection_up: %08x%04x h=%d",

                      (isss_hs_remote_addr[5] << 24) + (isss_hs_remote_addr[4] << 16) +

                      (isss_hs_remote_addr[3] << 8) + isss_hs_remote_addr[2],

                      (isss_hs_remote_addr[1] << 8) + isss_hs_remote_addr[0],

                      isss_hs_connection_handle);

       

          // Prepare generated code for connection - write persistent values from __HOSTINFO to GATT DB

          __on_connection_up();

       

          // ToDo: Write custom persistent values into GATT database using functions

          // changed_<service_name>_<char_name>() generated by smart disigner

       

          // If device supports a single connection, stop advertising

          //bleprofile_Discoverable(NO_DISCOVERABLE, NULL);

       

         //This didn't work.

         //bleprofile_Discoverable(LOW_UNDIRECTED_DISCOVERABLE, NULL);

       

          // If security is required for every connection following function will start bonding or

          // will setup encryption.  No indications or notifications should be sent until

          // encryption is not done.

          if (bleprofile_p_cfg->encr_required & SECURITY_REQUEST)

          {

              if (emconninfo_deviceBonded())

              {

                  ble_trace0("device bonded");

              }

              else

              {

                  ble_trace0("device not bonded");

                  lesmp_sendSecurityRequest();

              }

          }

      }

       

      2.1.1 SDK/BCM20736

        • 1. Re: Advertising during connection
          MichaelF_56

          I'll ask one of the developers to comment on the issue.

          • 2. Re: Advertising during connection
            VictorZ_46

            When connection is up you can restart the advertisement using

              bleprofile_Discoverable(LOW_UNDIRECTED_DISCOVERABLE, NULL);

              blecm_setAdvDuringConnEnable(TRUE);

            1 of 1 people found this helpful
            • 3. Re: Advertising during connection
              jora_1327726

              I could have sworn this worked when I put it in...  For some reason I'm once again not seeing advertisements when connected.  Is there anything I can query to help figure out why the stack isn't sending them out?

               

              bleprofile_GetDiscoverable() is returning 3 (LOW_UNDIRECTED_DISCOVERABLE) at the end of connection_up()

              • 4. Re: Advertising during connection
                VictorZ_46

                Do you have APP_PATCHES_AND_LIBS += central_role_patches.a included in your make. 

                1 of 1 people found this helpful
                • 5. Re: Advertising during connection
                  jora_1327726

                  VictorZ_46

                  I do now.  Still no dice.  I am configured as a peripheral though, so I don't see how central patches will help.

                  • 6. Re: Advertising during connection
                    kilian.timmler@exelonix.com

                    Hi,

                     

                    I'm just trying to achieve the same. Since  it dawned on me that blecen is needed, I tried to get hello_client to send advertisments if I connect with gattool to it. I achieved this by changing part of the hello_client_connection_up() callback:

                    ....

                    if (hello_client.num_slaves < HELLO_CLIENT_MAX_SLAVES)

                        {

                          // if we are not connected to the master enable advertisements

                          if (!hello_client.handle_to_master)

                            {

                              ble_trace0("Adv during conn enable");

                              bleprofile_Discoverable(LOW_UNDIRECTED_DISCOVERABLE, NULL );

                              blecm_setAdvDuringConnEnable(TRUE);

                            }

                          else

                            {

                              ble_trace0("Adv during conn disable");

                     

                              // added advertisments here too

                              bleprofile_Discoverable(LOW_UNDIRECTED_DISCOVERABLE, NULL );

                              blecm_setAdvDuringConnEnable(TRUE);

                     

                    //            blecm_setAdvDuringConnEnable(FALSE);

                            }

                    //        blecen_Scan(LOW_SCAN);

                        }

                     

                    Verifying with SmartRF shows advertisments coming from the hello_client device while gatttool has a connection open to it.

                     

                    Regards,

                     

                    Kilian

                    1 of 1 people found this helpful
                    • 7. Re: Advertising during connection
                      VictorZ_46

                      I am sorry for the confusion, but central functionality should not be required for advertisements during connection.  Meanwhile the advertisements during connection means that the second connection as a slave may be created.  So you need to tell stack that scatternet is allowed.  I modified hello_sensor to add in the create

                       

                      blecm_setAdvDuringConnEnable(TRUE);

                       

                      blecm_enablescatternet();

                      and changed in the connection_up

                      bleprofile_Discoverable(NO_DISCOVERABLE, NULL);

                      to

                      bleprofile_Discoverable(LOW_UNDIRECTED_DISCOVERABLE, NULL);

                      seems to work.

                      1 of 1 people found this helpful
                      • 8. Re: Advertising during connection
                        jora_1327726

                        VictorZ_46

                         

                        I'm doing the same thing but I'm not seeing advertisements.  I'm trying to get a little help in figuring out *why*.  When I check, the stack is reporting that it's in LOW_UNDIRECTED_DISCOVERABLE mode but when I connect (via gatttool as well) I no longer see advertisements.

                         

                           bleprofile_Discoverable(LOW_UNDIRECTED_DISCOVERABLE, NULL );

                           blecm_setAdvDuringConnEnable(TRUE);

                         

                            ble_trace1("ADV Disc: %d", bleprofile_GetDiscoverable());

                        • 9. Re: Advertising during connection
                          jora_1327726

                          Enabling scatternet seems to have done the trick.  Going back and forth with and without it confirms it.

                           

                          I'm not sure why I thought this was working before.  Is there a possibility that I could have seen adverts during a connection without it at some point?

                          • 10. Re: Advertising during connection
                            VictorZ_46

                            Not likely.  You might have seen the adverts if connection has failed.

                            • 11. Re: Advertising during connection
                              jora_1327726

                              Ok, I'll buy that. I did have some bad ptr accesses a while back that were causing occasional disconnects.  Thanks for the help!

                              • 12. Re: Advertising during connection
                                kilian.timmler@exelonix.com

                                Just for completeness sake, in the connection up callback I was able to use

                                 

                                  blecm_setAdvEnable(0);

                                  blecm_setAdvParam(interval,

                                                      _ADV_ADV_INDIRECT,

                                                      _ADV_PUBLIC_ADDRESS,

                                                      _ADV_ADV_CHANNEL_MAP_MASK,

                                                      _ADV_ADV_FILTER_POLICY_WHITE_LIST_NOT_USED,

                                                      _ADV_PUBLIC_ADDRESS,

                                                      NULL);

                                  blecm_setAdvEnable(1);

                                 

                                to start advertisments again, which makes me totally happy.

                                • 13. Re: Advertising during connection
                                  hachc_2137126

                                  Hi, victorz

                                   

                                    Should this function 'blecm_setAdvDuringConnEnable' to be called in every event of connection up?

                                    Or can it be just called once in 'Create' function?