Projects:Badge/BPP
BPP
Badge P[garbled] Protocol
https://github.com/SHA2017-badge/bpp
It's essentially a protocol encapsulating multiple streams, sent over UDP over a WiFi network, so clients can pick it up and decode it without having to connect to the network or transmit anything.
Sleeping
bpp sleep behaves like this: The server sends out data in cycles. A cycle lasts a time that is settable in the server, for example 5 minutes. During the cycle, the server will send out small packets indication how long it still takes until the next cycle starts.
If bpp boots at a random time, it's not sure what to do with the data it receives, so it waits for one of the packets indicating when the next cycle starts. If that takes a few seconds, it'll just stay awake, if not, it goes into deep sleep for the indicated time.
Now, when it wakes up again, it should be at the start of a cycle. This is where all the important information is sent: what sectors got updated, what sectors are still the same, what sectors will be sent this cycle etc: that info is called the catalog. Bpp will use this to decide if it should stay awake or go to sleep: if there is no data it needs (because it is up-to-date, or because the data it needs won't be sent this cycle) it will again sleep and set the wakeup time for the start of the next cycle.
If it does need the information, it will stay awake, grab the data and write it to flash. If during the cycle it figures out it doesn't need any more information (because it's up to date or because the rest of the data isn't interesting), it'll go to sleep, but it's also possible it'll stay awake up to the next catalog. So it can in theory be true that bpp keeps the badge active for a bunch of cycles.