This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

beacon advertise interval

hello Nordic

i am working with nrf52832, sdk 6.0, softdevice s132 v7.0

i read around the forum that i can advertise a beacon packet every 20 ms 

but in the ble_app_beacon example the interval for the advertisement is written to be minimum 100ms ?? so where did that 20 ms go ?

however, since i don't know how to change the data of the message while advertising i put a timer handler that stops the advertise, update the data and start it again.

i put the timer to go every 50 ms and the advertisement interval every 50 ms i put a pin toggle every time i receive a ble from the address i am filtering..

1. the time is not fixed, maybe some messages are lost or maybe not sent, i don't know 

2. the intervals are larger then 50 ms .. more to the 100 ms  when they are sometimes fixed 

can you advice on this matter ?

i need to be sending changeable data in a beacon at list 30 times in one second

best regards

Ziv

  • Hello again Ziv,

    I am terribly sorry for my late reply - I have been out of office for some time now. My apologies.

    ziv123 said:
    preferably at least 2 times for each message

    This depends on what environment you are in - how much noise / interference you will have, and the distance between units, line-of-sight etc.
    If it is important that as many advertisements as possible is received, then you should transfer the advertising more than just 2 times.

    ziv123 said:
    i know that in theory i can broadcast every 20ms and that should be enough but from checking in the scope on the pin toggle i saw it was less stable in those intervals (we discussed this already i think) 

    Please tell me what you mean that it is less stable in those intervals.

    ziv123 said:
    what about whitelist ? does it work better, if i want all units to read only from a certain address ? if so, how is it done on both sides ?

    No, the whitelist does nothing to improve environment noise - it only determines which units may establish a connection with the device. If you want your units to only read from a certain address you should add a filter, and then use the filter match event to process the received data, instead of the advertising report.
    When you are using filters you will still see the non-filtered advertisements in the advertisement reports, which is why you should use filters to filter out only the ones of interest.

    ziv123 said:
    It is not clear to me if i can use the dongle nrf52840 as it is without programing it

    I am not sure what you mean by this - the dongle will need to be programmed in order to perform any function. You will need to program the dongle with the connectivity firmware, as described in the readme, to use the pc-ble-driver I referenced in my last reply. Please see the "Programming Connectivity HEX files" section of the github readme.

    ziv123 said:

    so, anyway, at the moment i am starting to work on writing a python app that will identify one of this usbs and send serial data to it (for haps there is already a written code for that in the softdevice for the nrf52840 dongle, i don't know) 

    so any advice on that matter will be helpful and maybe i would make a better decision on where to invest until the dongles arrive :)

    Have you received your dongles yet? It sounds to me like the pc-ble-driver directly is what you are looking to use here. If I understand you correctly that you would like to write the application in python, please instead have a look at the pc-ble-driver-py.
    If you follow the readme to setup your dongles, you may then access the softdevice API directly using the driver.

    ziv123 said:

    but now, i also need to transfer data back from the 150 units to the device connected to the pc, and that seams to be a little bit more complicated .. 

    can you advice on that matter? what are the options, cons and prunes ?

    This is a major change to the project, as I had understood it. It is definitely more complicated to create a all-to-one network.
    How much data is being transferred, and how often does it need to be transferred? You might have to look into either establishing connections to different groups of devices, or look into using the mesh network structure to resolve this - based on the answers to my question above.

    Could you also tell me how these 150 peripheral devices are arranged, in regards to distance between each other? Are they all evenly spread out over an area, or concentrated in groups located some distance from the central device?

    Looking forward to resolving these issues together!
    Once again I apologize for my late response.

    Best regards,
    Karl

    Best regards,
    Karl

  • Hi Karl

    Glad to read all is well.

    In the meantime I actually been working on a different project and just returned to this one again a few days ago Blush so its ok .. but anyway I have started working with the Laird BL654 dongle (its easier to start, just plug to the pc and connect via serial port) the plane is to work with AT command, though I am not sure yet that I can do all what I need without programing it and if I need to program it and AT commands will not be sufficient then maybe I will go back to the nrf52840 dongle (I have both dongles with me).

    Since in the second stage I need to be receiving status from the 100 (or 50 , not decided yet) field units then, I don't think the beacon idea will work though maybe I can use beacon and then do some pairing with the 100/50 units for the status (don't know the frequency of status returns yet as well)

    I was thinking of using kind of a tree structure where the pc through the dongle sends data to 10 middle units and each of this middle units communicates with 10 different field units, send data and receive status which is then transmitted back to the dongle and the pc.

    Questions:

    1. I don't know how exactly I maintain connection with 10 specific units (to avoid 2 middle units connecting with same field unit), is it by hard coded mac addresses or is there a different way to maintain pairing with specific units. (maybe it’s a basic question but I am still green with all the Gatt Gap and how Bluetooth and ble actually work when working with multiple connections)
    2. I don't know if AT commands alone can set the dongle to send a serial message whenever a ble of status is received since I believe it's an a-synchronic event, so if you have an idea about that I would love to read ?
    3. Also, if you think there is a better solution then the tree structure ?

    I was suggested to work with mesh but I don't need the units to talk to each other and I think there will be a lot of latency in a mesh .. maybe I am wrong.

     

    Anyway, One other issue I am thinking of is that I don't have an energy issue, all the units are constantly connected to a power supply, all units are moving in a range of 2 meter square. So maybe its better to work with Bluetooth and not ble but all the examples and posts are related to ble so I don't know if there is enough data and support on Bluetooth, what would you suggest ?

    one last thing, if you can suggest examples for the tree structure or bluetooth or if you suggest something else :)

    (i have sdk 16.0, the field units are nrf52832 working with s132 NINA boards) 

    Best regards

    Ziv

  • Hello Ziv,

    Thank you for your patience and understanding.

    ziv123 said:
    I have started working with the Laird BL654 dongle (its easier to start, just plug to the pc and connect via serial port) the plane is to work with AT command, though I am not sure yet that I can do all what I need without programing it and if I need to program it and AT commands will not be sufficient then maybe I will go back to the nrf52840 dongle (I have both dongles with me).

    I understand, thank you for letting me know. Just to be sure, when you say AT commands are you in fact referring to the SoftDevice's API through the connectivity firmware on the dongles?

    ziv123 said:
    Since in the second stage I need to be receiving status from the 100 (or 50 , not decided yet) field units then, I don't think the beacon idea will work though maybe I can use beacon and then do some pairing with the 100/50 units for the status (don't know the frequency of status returns yet as well)

    Without knowing the size of the data that needs to be transmitted, and the frequency of the transmits ( along with the number of devices and the importance of receiving every message) it is very hard to make any recommendations here. However, I too think that the beacon idea might wane when I now know more about your project.

    ziv123 said:
    I was thinking of using kind of a tree structure where the pc through the dongle sends data to 10 middle units and each of this middle units communicates with 10 different field units, send data and receive status which is then transmitted back to the dongle and the pc.

    Yes, this might very well work. Again, the performance will depend on the size of the transfers, and their frequency, but I was thinking the same thing when you described your setup in your previous comment.

    ziv123 said:
    I don't know how exactly I maintain connection with 10 specific units (to avoid 2 middle units connecting with same field unit), is it by hard coded mac addresses or is there a different way to maintain pairing with specific units.

    You can use a whitelist to ensure that the devices only connects to certain other devices.

    ziv123 said:
    (maybe it’s a basic question but I am still green with all the Gatt Gap and how Bluetooth and ble actually work when working with multiple connections)

    No problem at all, just ask if there is something you think is unclear or if you have any questions :) 

    ziv123 said:
    I don't know if AT commands alone can set the dongle to send a serial message whenever a ble of status is received since I believe it's an a-synchronic event, so if you have an idea about that I would love to read ?

    I will need to know the clarification about your meaning of AT commands from my previous question to answer this precisely, but you may program you dongle to perform a certain action when it receives a notification, if that is what you are asking.

    ziv123 said:
    Also, if you think there is a better solution then the tree structure ?

    Since you are not interested in using mesh due to the latency, then it sounds like the proposed tree-structure might be a good fit for your project. You could for example use something like the experimental relay examples between the leafs and the central device.

    ziv123 said:
    One other issue I am thinking of is that I don't have an energy issue

    On the contrary, this does not sound like an issue at all! This is usually a massive constraints for projects, so it is good that you do not have to deal with it.

    ziv123 said:
    So maybe its better to work with Bluetooth and not ble but all the examples and posts are related to ble so I don't know if there is enough data and support on Bluetooth, what would you suggest ?

    By this, do you mean Bluetooth classic? I would not image that Bluetooth classic could be a fitting option for your project, but I personally do not have a lot of experience working with Bluetooth classic.
    Just in case, I will also mention that none of our product use Bluetooth Classic - they are all BLE.
    With the information you have provided about the project it sounds like a good fit for BLE.

    ziv123 said:
    one last thing, if you can suggest examples for the tree structure or bluetooth or if you suggest something else :)

     I would recommend taking a look at the experimental relay example, and see if you think this could be used as the relay between your tree leafs and the central unit.

    As mentioned, it is hard for me to be more precise in my answers without knowing more about the size and frequency of the communication between the leafs and the central. It would also be helpful to know the importance of receiving every message from the central and peripherals.

    Looking forward to resolving this together!

    Best regards,
    Karl

  • hi Karl

    i am jumping a little bit from one question to another, sorry for that but i finely talked with directly with the client and i have some questions:

    1. if i work with a beacon, what's the safe interval in which a 31 byte message can be transfered, how much time for receiving and how much time till the next time i can send the message? same wuestion for a 255 byte of data message ? 

    i read somewhere that i can send a message every 20 ms but when i checked it with a scope it was not very stable.. i think we talked about it before actually but i am not sure.. need to look

    2. if want to create a connection with lets say 20 units, how much time from when the message is advertised till connection is established with a unit and how much time from a data message is sent to the ACK received from the field unit ? also, how much time from data message sent to the field unit till i can send the next data message to that unit

    i would also like to understand if possible what is the meaning of nrf52840 maintaining 20 connections.. does it mean it keeps a live connection with all 20 units how much time will it take to send a message to all units ?

    one more thing, if i use a different device with larger antenna will it help to get more stable and sure communication, how will it benefit the communication with the units ? 

    one more, can a device be in a scan mode for beacon from other device and advertise its own beacon at the same time ? or do i have to stop advertising -> go to scan and then back to advertise ?

    best regards

    Ziv

  • Hello Ziv,

    ziv123 said:
    i am jumping a little bit from one question to another, sorry for that but i finely talked with directly with the client and i have some questions

    No problem. However, in order to keep the forum tidy I would ask that you create a new ticket if you should have any followup questions to this comment, since the questions now have diverged from the original "beacon advertising interval" ticket questions.

    ziv123 said:
    1. if i work with a beacon, what's the safe interval in which a 31 byte message can be transfered, how much time for receiving and how much time till the next time i can send the message? same wuestion for a 255 byte of data message ? 

    The minimum advertising interval that you may configure is as mentioned 20 ms. In addition, there will be added a random 0 - 10 ms delay on top of this, which means that the worst case if 30 ms between every advertisement. These requirements are the same for the 255 byte message ( assuming you are referring to extended advertising here ).
    To see how long time different sized payloads take to transfer, please have a look at our online power profiler for the nrf52 series.
    As you can see from the online power profiler a non-connectable advertisement of 31 bytes will take 376 us to complete for each advertising channel.

    ziv123 said:
    i read somewhere that i can send a message every 20 ms but when i checked it with a scope it was not very stable.. i think we talked about it before actually but i am not sure.. need to look

    Yes, we have already spoken about this. The reason why this is not stable is the 0 - 10 ms randomly added delay. The delay is part of the BLE specification and can not be omitted.

    ziv123 said:

    2. if want to create a connection with lets say 20 units, how much time from when the message is advertised till connection is established with a unit and how much time from a data message is sent to the ACK received from the field unit ? also, how much time from data message sent to the field unit till i can send the next data message to that unit

    i would also like to understand if possible what is the meaning of nrf52840 maintaining 20 connections.. does it mean it keeps a live connection with all 20 units how much time will it take to send a message to all units ?



    You may indeed hold up to 20 concurrent connections. Please see this ticket for more detail.
    You can use the online power profiler to see how long each transfer will take, depending on the size of the transmission.
    The time till first ACK from an advertisement is hard to estimate precisely since it depends on a lot of factors, but please see this ticket for a discussion of the time to establish a connection.

    ziv123 said:
    one more thing, if i use a different device with larger antenna will it help to get more stable and sure communication, how will it benefit the communication with the units ? 

    A larger / higher power antenna will decrease the chance of packet loss, which in turn may speed up data transfer.
    The necessity of this will depend on the environment / conditions your devices are in. If there is a lot of obstacles and interference, etc.

    ziv123 said:
    one more, can a device be in a scan mode for beacon from other device and advertise its own beacon at the same time ? or do i have to stop advertising -> go to scan and then back to advertise ?

    Are you asking if a device can alternate between being a central and a peripheral?
    If so, the answer is yes. This is demonstrated in the experimental multirole examples in the SDK that I mentioned earlier.

    Best regards,
    Karl

Related