2 Replies Latest reply on Jun 25, 2015 11:07 AM by userc_3671

    Peripheral sending non-connectable advertisements when connected

      Hi,

       

      I am trying to set up the peripheral to continue sending advertisements after it is connected to a central. I would like other centrals to know that the peripheral is around but currently connected to another central. (I'm also planning to change the advertisement data slightly to reflect when this peripheral expects to be done with its current connection).

       

      However, I'm unable to get the peripheral to advertize in such a way that it doesn't accept a second connection. I essentially want BLE 4.0 behavior, not BLE 4.1 behavior. That is, only one connection from a peripheral to a central. Here is what I've tried:

       

       

      void app_connection_up(void)

      {

      // Other code snipped

      blecm_setAdvDuringConnEnable( TRUE );

      blecm_disableConMux(); // If I take this line out, there is no difference in behavior

      blecm_enablescatternet(); // If I take this line out, it doesn't advertise after the connection is up

      bleprofile_Discoverable( LOW_UNDIRECTED_DISCOVERABLE, 0x00 );

      }

       

      However, I either able to:

      (a) Advertise after connecting, but then it will connect to other centrals too

      (b) Not advertise after connecting at all (if I take the enablescatternet() call out).

       

      I'm developing on OS X with SDK version 2.2.0 (still waiting for 2.2.1 on OS X).

       

      Any pointers on what I can do to get the desired behavior? Greatly appreciate any assistance!

       

      Regards,

       

      Arvind

        • 1. Re: Peripheral sending non-connectable advertisements when connected
          JacobT_81

          I was able to achieve non-connectable advertisements while in connection in hello_sensor by patching some mybeacon code into the connection_up function.  Take a close look at mybeacon to really understand what's going on and you should be able to easily apply it to your code.

           

          To get it to work, I went into the connection_up function, removed "bleprofile_Discoverable(NO_DISCOVERABLE, NULL);" and patched it with:

           

          blecm_startAdv(

                          HCIULP_ADV_NONCONNECTABLE_EVENT,                // non-connectable undirected advertisement

                          160,                                            // adv interval 100 msec

                          HCIULP_ADV_CHANNEL_MAP_MASK,                    // all channels

                          HCIULP_PUBLIC_ADDRESS,                          // int advAdrType,

                          HCIULP_ADV_FILTER_POLICY_WHITE_LIST_NOT_USED,  // int advFilterPolicy,

                          HCIULP_PUBLIC_ADDRESS,                          // int initiatorAdrType,

                          NULL);                                          // UINT8* initiatorAdr

           

          While defining at the top:

                         #define    HCIULP_ADV_NONCONNECTABLE_EVENT                                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_PUBLIC_ADDRESS                                          0x00

                         #define    HCIULP_ADV_FILTER_POLICY_WHITE_LIST_NOT_USED                    0x00 // white list not used

           

          Jacob

          • 2. Re: Peripheral sending non-connectable advertisements when connected

            Yes, this works, thanks!

             

            There is a post regarding the use of the blecm_startAdv() function:

             

            Re: Connectable vs. nonconnectable Advertisements.

             

            In this post, ArvindS_76 says something about not using blecm_startAdv with the bleprofile_Discoverable(), and it left me confused enough to not try it:

             

            " The other thing to keep in mind is that bleprofile_Discoverable() uses this in its state machine. So if you use blecm_startAdv(), don't use bleprofile_Discoverable() ."

             

            However, in my code, and I suspect in your modified hello_sensor too, both these functions are being used in different places. So I'm not sure what is meant by the comment above. I wonder if I should just use blecm_startAdv() exclusively in my code to prevent any odd behavior later?

             

            I will be great if someone in the know can clarify the dependencies between the blecm_* functions and the bleprofile_* functions. It will be good to document this API properly.

             

            Anyway, thanks again!