This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BLE connect to slave without advertising

Other Parts Discussed in Thread: CC2540, CC2541

When the button is pressed on the Keyfob_slave, the device goes in advertising mode and connection between master and keyfob can be established. I am trying to automate this process, but something is missing ! I tried to trigger the key event "Hal_ProcessEvent( Hal_TaskID, HAL_KEY_EVENT)" then I tried to call Advert. directly osal_set_event( gapRole_TaskID, START_ADVERTISING_EVT).

Well, it does not seem to me that Keyfob go Advertising ?! 

Would also be possible to wake the Keyfob without advertising so that it just wait for GAP_LINK_ESTABLISHED_EVENT for some time. But it does not seem that the Keyfob one may connect to the Keyfob just by leaving POWER_SAVE mode.

Is this acheivable ?

  • Hello,

    To form a connection requires the keyfob to advertise.  The advertise packet will be seen by the master, and this will trigger the establish request.  The keyfob only has the RX on for a short period of time after each advertisement and this is when the keyfob would be looking for  an establish request.

     

    To turn on/off adv use - and this will add some checks for setting osal start_advertising_event.

    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &new_adv_enabled_status );  

     

    Br,

    -Greg

  • thank you for your reply.

    I set the keyfob timerEx to start Advertising for about 100ms every 10seconds, in BTool I could establish the connection with the keyfob. I noticed Tx is active for about 10ms at the beginning: 2ms with 28mA and 8ms with 9mA (I assume wakeup +  Tx), afterwards (2ms-28mA + 2ms-9mA). 

    Would it be also possible for keyfob to skip Tx-part and just scan for connection requests from the master ?

    In the master side, what is the max. Rx-scanning time needed to be able to synchronize frequency and start a connection ?

    In BTool, I set the min./max. connection interval to 6 (7.5ms), but then the connection between keyfob was lost. Are there some recommended settings for least power consumption ?

     

    BR,

    -Khalil

     

     

  • Hello,

    Note - the 28ma(tx) will come down below 19 if you uses DC/DC converter ref design. 8ma-->6ma. RX should be about 21ms without dc/dc.

    Would it be also possible for keyfob to skip Tx-part and just scan for connection requests from the master ? - No, the spec has this setup as a trigger mechanism.  TX rec by Master  will trigger ConnReq. The slave starts looking for the establishReq 160us after transmit is complete.

    The master side scan can be set (interval and length) . If you don't want to risk missing an advertisement set them equal to each other, and you will scan 100%.

    7.5ms may have issues if there is any data.  Try using 8.75ms.

    -Greg

     

     

     

  • Hello,

     

    Thanks for your the valuable information.  19mA is much better.

    160µs after transmit complete seems nice. I tried to find the shortest period after enabling advertising where the keyfob may be connectable.

    I noticed when advertising is enabled, there will be some delay before the first advertising packet begins (about 6ms). I searched in the firmwae if there is an adjustable advertising delay. I changed some configurations, but did not manage to reduce the delay. If I limit the period between enabling advertising and sleeping again to less than 8ms, the keyfob will not be reachable anymore.

    Are there some ideas to reduce the period to less than 8ms?

     

    br,

    khalil

  • The advertising has a built in 10ms randomness to prevent multiple devices from advertising at the same time.   If you want to save power (at peripheral) and have low latency, then you may want to stay in a connection and use slave latency to allow the peripheral to sleep - until it has data to send.

    Br, 

    -Greg

  • Hello,

    ahh, I see 10ms. I could see that the keyfob taks about 6-7ms to start advertising, advertising and scanning takes about 4-5ms.

    The application in which we want to use the CC2540 is up to 12 devices to with which one wish to establish communication. The master is not everyday there to keep a connection, the devices are not reachable to manually trigger the beginning of the communication, they work on battery and must provide a fair battery life time.

    There are several scenarios possible:

    - Each device act as a slave, wakes every 10s up, advertise once, and scan for a connection event then go back to sleep if no event exist.

    - Or, device wakes up, scan for master without advertising. If master exist advertise to be connectable, scan for connection event

    ... Is Master-Slave Role-Switch possible ?

    ... Can the master send a broadcast message ?

    in Volume 3, Part C, Section 11of the BT 4.0 specification -> "If the Length field is set to zero, then the Data field has zero octets. This shall only occur to allow an early termination of the Advertising or Scan Response data."

     I tried ... GAPRole_SetParameter( GAPROLE_ADVERT_DATA, 0 ,advertData); with advertData[1] = 0x00; but it did not make a difference ! 

    are there possibilities to optimize advertising ?

     

     

  • Comments inline

     

    - Each device act as slaves, wakes every 10s up, advertise once, and scan for a connection event then go back to sleep if no event exist. -

    [greg] - Should work, but you are wasting energy from the 11 which do no need to connect. 

    - Or, device wakes up, scan for master without advertising. If master exist advertise to be connectable, scan for connection event

    [greg] - slave can only broadcast or advertise and allow connection

    ... Is Master-Slave Role-Switch possible ?

    [greg] - This is planned, but not ready currently

    ... Can the master send a broadcast message ?

    [greg] - spec allows it, but we do not support yet, it is planned.

    After setting ADVERT DATA, try disabling and enabling advertising.  Is the master or slave device determining who will connect?

  • that's right, energy will be wasted for 11ms. Is there another "not-manual" way for the device to be connectable ?

    I set ADVERT DATA in initialization, advertising is enabled each 10s then disabled after 7ms(I suppose device completes 1 advertising cycle). But I did not notice difference in advertising length.

    I also tried decreasing TGAP_LIM_DISC_ADV_INT_MIN, it also did not make a difference when enabling advertising for more than 100ms ! Does it lie on the using your first version (ble 1.0) ?

    >>> Is the master or slave device determining who will connect? <<<

    well, the main idea is: we have 1 to 12 devices which work on battery and can not be triggered manually ... on the other end we have one device [I call it master] which has to:

    - detect which devices are there.

    - connect to the devices whenever user want it to connect.

    Goal --> get the connection with the cheapest power consumption on the (1 to 12) devices side, it does not really matter which is slave and which is master. I am to switch the roles and check the results.

    Master-Slave role switch would be interesting, is it planned the end of this year ?

     

    I updated IAR to version 7.60, I tried "SimpleBLEPeripheral" and "keyfob-demo" without periodic tasks like battery monitor, I noticed:

    - When advertising Tx-power goes up to 45mA !

    - When Idle, the device wakes up regularly ! in "keyfob-demo" it is noticed when swtiching advertising on for long than 20ms.

    are these due to some bug ?

     

  • Hi Greg, 

    I am trying to find out if after a central has established a connection with a peripheral, if for subsequent connections, we do not require the peripheral to be advertising. According to your answer above, the peripheral is required to advertise because this will be the trigger mechanism for the RX period to look for connection requests.

    Is this a TI BLE Stack or CC2540 requirement or limitation?

    I have spent hours looking at the BT Core 4.0 spec and can't find where this is a requirement, so I was wondering if this is just applicable to the TI BLE solution.

    Thanks, 
    Melissa

  • Hello,

    The peripheral always has to advertise first in order to get into a connection.

    1) Master scanning (one of 3 advertising channels)

    2) Peripheral advertises (ch1..ch2...c3..(at least 20ms)...ch1..ch2..ch3...)

    3) Master sends ConnectionRequest  160us after advertisement is received. 

    This is all according to BT spec. The advertiser doesn't look for a ConnectionRequest until a very specific time, 160us after advertisement is finished.

    BTW - we support master slave switch, and combo roles now. So orig poster may have other options now.

    Hope this helps. Good luck.

    BR,

    -Greg

  • Hi Greg,

    Thanks, this info helps. Two more questions:

    1. Does it also apply to re-connections? For example, on iOS the master does not need to scan again to obtain that same peripheral to re-connect during a session (at least at the app level). In this case, is this requirement to advertise in order to establish a connection only for the peripheral?

    2. Are there any aspects of this that I can modify on the peripheral time, for example, the 160us time after advertising for the RX of the connection request?

    Thanks,

    Meli

  • Hi Greg,

    Is this still true with the latest BLE SDK?  I am trying to enable a connection without the CC2541 advertising.  I would like to reduce the potential of a random person connecting with a previously bonded device.

    Thanks,

    -Rocky

  • @Greg and others: thanks for the informative post. I have been trying to find answers to something quite similar and this post answers it. 

    @Rocky: Believe you can use a Connectable Directed advertising packet to re-connect with your previously bonded device only. 

    Regards,

    Raj.