All posts

Sigfox callbacks explained, and the mistakes that lose data

By Foxwatch · callbacks, integration

Sigfox backendYour endpointPOST https://…200 OK"device": "1A2B3C""data": "00e75a01""seqNumber": 1042

Sigfox doesn’t wait for you to fetch messages. When a device sends an uplink, the Sigfox backend pushes it to you through a callback: an HTTP request to a URL you configure on the device type. Get the callback right and every message lands in your system within seconds. Get it wrong and messages disappear without much fuss.

What a callback is

A callback is set on a device type, so it applies to every device of that type. The most common kind is a custom HTTP callback for uplink data. You choose:

  • the URL to call, which should always be https,
  • the method and content type, usually a POST with a JSON body,
  • the body, built from variables the backend fills in for each message.

The variables you’ll almost always want are the device ID ({device}), the message time ({time}), the payload ({data}) and the sequence number ({seqNumber}). Add the signal variables your contract includes, such as RSSI and the number of base stations that heard the message, if you want to understand coverage later.

The mistakes that lose data

Not including the sequence number. Without it you can’t tell whether a message never arrived or the device simply didn’t send one. With it, a gap in the numbers shows exactly what was lost.

Doing slow work before replying. The backend waits for your endpoint to respond. If your handler decodes, stores, checks alert rules and sends emails before it answers, a slow day can push it past the backend’s timeout and the delivery counts as failed. Store the raw message, reply straight away, and do the rest afterwards.

Treating every request as new. Network hiccups can deliver the same message twice. Use the device ID and sequence number to recognise duplicates, so you don’t store one reading twice or fire one alert twice.

Only one device type configured. Callbacks belong to the device type. When a new device type is added to the account, it has no callbacks until someone sets them up, and that type’s messages go nowhere.

Not watching for callback errors. The Sigfox backend records failed callbacks, but nobody gets told. Check the error log regularly, or better, alert on it.

Keep the raw payload

However good your decoding is, store the original hex payload next to the decoded values. When you find a decoding bug six months from now, the raw payload is the only way to fix the history.

When you connect a Sigfox account to Foxwatch, it sets up the uplink callbacks for you and keeps track of which device types have them. Messages are stored as received, raw payload included, so decoded readings can always be rebuilt from the original data.

Foxwatch keeps your Sigfox devices and their history, decodes their payloads and tells you when something needs attention. Try it on your own Sigfox account.