This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Notify is safe?

I'am using notify continues to send large amounts of data,i want to know that notify whether can guarantee package serial number not random sequence and ensure that each data to arrive.whether it's send logic is similar to UDP(In network communication).thanks!!!

Parents
  • No, there is no "package serial number":) The trick is on lower layer called Link Layer which in BLE is 100% safe meaning that:

    • Always keeps sequence of queued packets (only one is being transported and no other packet goes out until the previous is acknowledged by the peer).
    • Either packet is transported reliably (acked by peer) or repeated until link is lost (then it is considered lost;).

    However Notifications live on higher (G)ATT layer where nothing is guaranteed by the protocol until you use Identify (with explicit ACK on (G)ATT layer) or Write with Response in the opposite direction. So the fact that all Notifications come from BLE stack to your application and in correct order is good will of lower BLE stack. Luckily in real implementation all the stacks keep "good" behavior so all of us are using Notifications and rely on lower LL in order to have 100% proper sequencing and reliability. The problems happen in certain scenarios on certain buggy devices (e.g. some Android phones can miss delivery of few initial Notify packets if they come too early after LL establishment = before higher layers of that crappy architecture are ready to forward packets to APP layer on top).

    In the end it's up to you. If your requirements are really high in terms of reliability then you should include some sequence number into your custom protocol header (which lowers effective bandwidth on top of GATT). Otherwise you can be fine as all of us are.

Reply
  • No, there is no "package serial number":) The trick is on lower layer called Link Layer which in BLE is 100% safe meaning that:

    • Always keeps sequence of queued packets (only one is being transported and no other packet goes out until the previous is acknowledged by the peer).
    • Either packet is transported reliably (acked by peer) or repeated until link is lost (then it is considered lost;).

    However Notifications live on higher (G)ATT layer where nothing is guaranteed by the protocol until you use Identify (with explicit ACK on (G)ATT layer) or Write with Response in the opposite direction. So the fact that all Notifications come from BLE stack to your application and in correct order is good will of lower BLE stack. Luckily in real implementation all the stacks keep "good" behavior so all of us are using Notifications and rely on lower LL in order to have 100% proper sequencing and reliability. The problems happen in certain scenarios on certain buggy devices (e.g. some Android phones can miss delivery of few initial Notify packets if they come too early after LL establishment = before higher layers of that crappy architecture are ready to forward packets to APP layer on top).

    In the end it's up to you. If your requirements are really high in terms of reliability then you should include some sequence number into your custom protocol header (which lowers effective bandwidth on top of GATT). Otherwise you can be fine as all of us are.

Children
  • (no problem, just mark correct answers and close all your questions which are considered answered;)

  • if Link Layer which in BLE is 100% safe,why add indicate in ble.what different between notify and indicate,thx.

  • Because the fact that one layer is reliable deson't mean that higher layer must have all the properties. therefore you have Notify/Indentify for Server to Client (G)ATT communication (Notification is without explicit acknowledge while Notify has one round trip) and Write with and without Response for Client to Server communication. Note that using Identify and Write with Response dramatically lowers throughput over GATT because LL needs to wait for higher layers and typically cannot use multiple PDUs within one connection interval (so while with Notifications you can push typically up to 6x20B in one 30-50ms interval with Identification you will only send 20B per interval).

Related