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.

simple scanning and advertising data

Hi,

I am planning to have 10 devices that based on the simpleBLEPeripheral projects, I need to use them mainly as broadcasters to broadcast every one its own data, but to be connectable!

and in the other hand I will have a smartphone which will listen (scan maybe is the right expression) to all of them and to use the packets that the 10 peripherals are transmitting as active and realtime data that I want the smartphone as receiver (observer but to be able to select one of the 10 peripherals which are connectable and to connect to it to have a special conversation and in the same tome for the central to keep getting the advertisement data from the other 9 peripherals to get and display the data).

is it right plan tha I did? can I do that with the BLE?

based on the simpleBLEPeripheral and Central projects, when the peripheral is transmitting the advertData packet, where do the simpleBLECentral get the data? I need to go ther to copy the content of the AdvData to a local array! I am trying to find that place in the code so I ask you for a help please!

and then, I see with the sniffer also that the scanRspData data is sent from the Peripheral after that the Central sent to it ADV_SCAN_REQ! it made me doubt about the way I need to send the data! is this last packet for scan request and respond is used only when we need to make a connection?

just I am worry about that if I can send the data in the advertData and not the scanRspData packet for the central so the central can read the data and copy to a local array!

Thanks.

  • Hello. Note that much of this information is included in the relevant sections of the software developer's guide (www.ti.com/.../swru393). If you haven't seen this, I would recommend reading through it.

    Yes, this is a common use case for BLE. The scan response data is essentially extra advertising data. It is not related to forming connections and you do not have to transmit scan response data.

    Advertisement data will be forwarded to the simpleBLECentral application task via a GAP_DEVICE_DISCOVERY_EVENT to the central event callback (i.e. SimpleBLECentral_processRoleEvent() in the simpleBLECentral project) function. See Appendix III.3.1 of the SDG for more information.
  • Thanks ;)
    That helps.
  • but now I am looking to the SimpleBLECentral_processStackMsg callback, it contains only:
    GAP_MSG_EVENT
    GATT_MSG_EVENT
    HCI_GAP_EVENT_EVENT

    while the GAP_DEVICE_DISCOVERY_EVENT you mentioned is in SimpleBLECentral_processRoleEvent

    yesterday I tried to catch the coming advertisement data exactly here but it comes to here in the breakpoint only after finishind scanning period!

    I need that the scanning keeps working all the time without stop and only catching the advertisement data from all the 10 peripherals... maybe once a month I will need to select one of the advertisers to make a connection for several minutes but most of the time I neet to update the Central by real time data from the 10 peripherals!
    so can I define the central to keep scanning? then where can I find the comming data immediatly when it comes from the stack to the application?

    As I saied I tried in the GAP_DEVICE_DISCOVERY_EVENT but it comes here only after the default 4 seconds for scanning...

    Thanks.
  • You are correct. The scanning mechanism is designed to only report discovered devices after the scanning period is over.

    I would recommend using a shorter scanning period to receive the discovered device information quicker and continuously restarting scanning when this occurs. The downtime between scans here should not pose a problem.
  • So you think immediately (let it take 1ms) that the scan will be finished and immediately I can restart the scan?
    and at this time I can copy the scanned data to a local arrays to deal with them in parallel to the scanning time?!

    but I am worry about missing a lot of packets!

    OK again my plan is to advertise a real time data from every one of the 10 peripherals, every one is advertising every 20 ms (but I see in the sniffer that it advertise every 20 or 21 or 28 or 30 ms! is the advertiser really not accurate with the 20 ms ? )

    so every one is advertising in its own time which make them advertise at the same time in some probability!
    do the advertisers are transmitting every time the same packet in the 3 frequencies consequentially?
    and does the scanner at this time is listening on one of these 3 frequencies?
    ans so if I set the advertisert to transmitt every 20 ms (New data that I want to catch them all) what is the best time to stop the scan? 10 ms which is the half of 20? or 15ms? what is the minimum time for scanning?!

    but if I put the central in Observer mode! (I am not professional so I am asking) would it be the same? so I need so scan and stop the scan to read scanned packets?
    If the observer role behaves other way so I can keep scanning while getting event to my application every time I have received a full new advertisement packet maybe I can use it, and then when I want to connect to one of the advertisers I already have its peer address..?!

    sorry about the long message!

    Thanks.
  • You would need to profile this to find a suitable advertising time that will provide responses quick enough while not missing too many responses. The processing time should be very small so I don't think you will miss many advertisements.

    I would recommend reading through the spec to get the low-level advertising and scanning details. Some notes::
    - there is a pseudorandom jitter added to each advertising interval
    - each advertising event will only occur on one channel. The next advertising event will then occur on a different channel.
    - each scanning interval, the central is only scanning on one channel. The next scanning interval will occur on a different channel.

    It will not be possible for you to catch all of the advertisements due to RF interference and timing / channel mismatches. In general, your use case does not seem possible. You are going to have to accept that some advertisements will be missed.

    If you need guaranteed communication, it would make sense to establish a connection to the peripheral devices.
  • Thanks,

    A small question:

    So when I am advertising every 20 ms, would the scanner get the packet every 20 * 3(channels) = 60 ms because the advertiser is transmitting on 3 different channels while the scanner is scanning only on one channel?

    or that the advertiser is advertising within 20 ms on the 3 channels so the scanner will get it every 20 ms and not every 60ms?

    Thanks.

  • An advertising interval of 20 ms means that the advertisement will be sent on all three channels every 20 ms. That is, this will occur every 20 ms:

    Please read through the relevant sections of the spec for more information.

    Also note that duplicate received advertisement packets are filtered out at a lower layer of the stack so you will only receive one of each advertisement report in the application when advertising finishes.

  • Thanks!
    now the advertisement side is obvious for me!

    Please the last question that can make it clear about "scanning"
    do the scan stays at same frequency every scan period, and when scan stops then renew the scan it will move to another frequency (rolling between the 3 different frequencies that used to advertise will be used also for scan, so I have the same probability almost anyways to receive the packets)?

    Thanks.
  • Scanning occurs on one channel for the entire scanning period. On the next scan period, scanning will occur on the next channel.