Skip to main content
For the complete documentation index, see llms.txt.

Hubble Network developer documentation: integrate Bluetooth devices with terrestrial and satellite connectivity.

Implementing a Hubble Scanner

How to build your own scanner, in firmware or software, that sends directly to Hubble's Gateway API.


Who This Is For​

This page is for the direct integration path. Your own firmware or software on the gateway scans and calls the Gateway API directly:

[Gateway] --> [Hubble Gateway API]

Each gateway registers with Hubble and gets its own identity and credentials. Before a gateway can register, it needs a Gateway Group ID specific to your organization. See Getting a Gateway Group ID.

On Linux, the reference application implements everything on this page. Run it, adapt it, or use it as a working example while you build your own.

This page covers how a scanner must behave: what to scan for, what metadata to attach, and how to handle authentication, batching, errors, and connectivity loss. It does not specify hardware, operating system, or connectivity (cellular, Wi-Fi, or Ethernet).

For each endpoint's request and response schema, see the Gateway API reference.


Before You Start​

You need:

  • A Hubble account and a Gateway Group ID. See Getting a Gateway Group ID.
  • Gateway hardware that can do BLE 4.0+ passive scanning.
  • Internet connectivity on the gateway.
  • A reliable time source on the gateway: NTP, GPS, or cellular network time.

Base URL​

Production: https://gw-api.hubble.com

All paths on this page are relative to this URL. TLS 1.2 or higher is required.

Terminology​

TermDefinition
GatewayA device that scans for Hubble BLE advertisements and forwards them to Hubble. Also called a scanner.
AdvertisementA BLE broadcast packet sent by a Hubble device.
PacketOne scanned BLE advertisement and its metadata.
Gateway Group IDAn identifier for your organization's gateway group. Sent in the X-Sdk-Key header, and only at registration.
Gateway IDA UUID the server assigns to one registered gateway (gatewayId).
Device tokenA short-lived Bearer token that authenticates a registered gateway's requests.
Refresh tokenA long-lived token that gets a new device token without registering again.
Batch IDA UUID the client generates. It is the idempotency key for an upload (batchId).

Register the Gateway​

On first launch, the gateway registers with PUT /api/v1/gateways (reference), authenticated with the X-Sdk-Key header set to your Gateway Group ID. The response contains:

  • gatewayId: the gateway's identity for all later calls
  • deviceToken and refreshToken
  • expiresInSeconds: the device token lifetime
  • config and commands, which may be empty. See Apply Server Config and Commands.

Choosing a deviceId​

deviceId must be stable and unique per physical device. Hubble uses the pair of deviceId and Gateway Group ID to identify a gateway, so:

  • If the same device registers again, for example after a factory reset that wiped its stored credentials, it gets the same gatewayId with fresh credentials.
  • If two devices send the same deviceId, they become one gateway. Do not derive deviceId from anything shared across units, such as a model number or a firmware build.

Good sources are a BLE MAC address, /etc/machine-id, or a serial number burned in at manufacture.

Describing the Device​

The registration body requires sentAtMillis, deviceId, type, manufacturer, model, and capabilities. A missing, null, or empty required field fails the request with 400 invalid_payload.

  • Set type to fixed for stationary installs, or mobile for gateways that move. Send the operating system in os (for example, linux) and its version in osVersion.
  • Send the hardware's manufacturer and model.
  • Send firmwareVersion for the gateway's own firmware. It is required unless type is mobile.
  • List what the gateway can do in capabilities, with at least one of ble_scan, location, push. If you include push, send a pushToken.
  • Send optional state when you have it: batteryLevel (omit or send null for mains-powered gateways), bleAdapterState, locale.

Storing Credentials​

Store these in non-volatile storage, so a restart does not register the gateway again:

  • gatewayId
  • deviceToken
  • refreshToken
  • The device token's expiry time, computed from expiresInSeconds
  • The most recent server config

Restrict access to the gateway process, for example with a file of mode 0600. Use hardware-backed secure storage where it is available. See Security Requirements.


Manage Tokens​

Send Authorization: Bearer {deviceToken} on every request after registration.

  • Refresh before expiry. Do not hard-code the token lifetime: read expiresInSeconds. Refresh shortly before the stored expiry with POST /api/v1/auth/refresh (reference). That request has no auth header, because the refresh token in the body is the proof of identity.
  • Persist the rotated pair right away. Each refresh returns a new refresh token and invalidates the old one. The server accepts the previous refresh token for a 60-second grace period, which covers a crash between receiving and saving the new pair. Write the new tokens to storage before you use them. The refresh response can also carry config and commands: apply them as described in Apply Server Config and Commands.
  • Handle expiry mid-request. If a request returns 401 with token_expired, refresh, then retry the original request once.
  • Re-register when credentials are no longer valid. If you get token_revoked, invalid_refresh_token, or gateway_not_found, discard the stored credentials and register again. Because registration is idempotent, the gateway gets back its old gatewayId.

Scan for Hubble Advertisements​

Use passive BLE scanning, with no scan requests and no connections. The gateway only listens. It never connects to or talks to Hubble devices.

Hubble does not set scan interval or scan window values. Tune them to your hardware and deployment to capture as many advertisements as you can.

Identifying a Hubble Advertisement​

An advertisement is a Hubble packet if it contains a Service Data – 16-bit UUID AD structure (AD type 0x16) for the Hubble Service UUID 0xFCA6 (on air: 0xA6 0xFC), with non-empty service data.

Discard advertisements that do not. Hubble devices usually also list 0xFCA6 in a 16-bit Service UUID list AD structure, but do not require that list: filter on the Service Data. For the full packet layout, see Advertising Packet.

Extracting the Payload​

Extract the bytes that come after the AD type and UUID in the Service Data AD structure:

Byte(s)Contents
0AD structure length
1AD type: Service Data (0x16)
2–3Hubble Service UUID (0xA6 0xFC, little-endian)
4+Hubble service data payload. Extract and forward these bytes.

The payload is 10 to 23 bytes, depending on whether the device adds a custom application payload.

Treat the payload as an opaque byte array. Do not parse, decrypt, interpret, or change it. Forward it exactly as you received it.


Build Each Packet​

Each scanned advertisement becomes one entry in a packet upload. For the full schema, see Upload BLE scan packets.

FieldWhat to send
deviceAddressThe broadcasting device's Bluetooth address as uppercase, colon-separated hex, for example AA:BB:CC:DD:EE:FF.
rssiReceived signal strength in dBm (a signed integer), as your radio measured it. Send 127 if you have no reading. Do not send 0: the server drops a packet with an RSSI of 0.
timestampMillisWhen the gateway received the advertisement, in epoch milliseconds.
serviceUuidfca6. A full 128-bit Bluetooth Base UUID (0000fca6-0000-1000-8000-00805f9b34fb) is also accepted.
serviceDataThe extracted payload, base64-encoded.
locationThe gateway's position at scan time. See Location.

Timestamps and Clock Skew​

All timestamps are epoch milliseconds. Every upload, registration, and heartbeat also carries sentAtMillis, the gateway's clock at send time. Hubble's backend compares sentAtMillis with its own receive time to detect and correct clock skew. That correction only works if the gateway clock is steady, so keep the gateway synced to a reliable time source.

The server drops, without telling the gateway, any packet whose timestamp is 0 or falls outside the accepted window after skew correction.

Location​

Each packet carries a location with WGS 84 coordinates.

  • Required: latitude, longitude, horizontalAccuracyMeters, timestampMillis
  • Optional: altitude, verticalAccuracyMeters, bearing, bearingAccuracyDegrees, speed, speedAccuracyMetersPerSecond

Guidance:

  • Reuse the last fix, with its real timestamp. If location fixes are intermittent, for example a stationary install with periodic GPS, attach the most recent fix and report when that fix was taken, not the current time.
  • Never send 0, 0 as a placeholder. The server reads a latitude or longitude of 0 as "no fix" and drops the packet.
  • Fixed installs: configure the surveyed position and a realistic accuracy.

Proof of presence is only as good as the scanner's location, so make it as accurate as you can.

Deduplication​

A Hubble device can repeat the same advertisement many times a second. Before you upload, merge repeated sightings of the same deviceAddress, serviceUuid, and serviceData within a short window, and keep the strongest RSSI. Use dedupWindowMs (or activeDedupWindowMs while the gateway is moving) from the server config when it is set.


Upload in Batches​

Upload packets with POST /api/v1/gateways/{gatewayId}/packets (reference).

Request Rules​

  • Content type. Every request body is JSON with Content-Type: application/json.
  • Compression. Send Content-Encoding: gzip for anything but small batches. 5000 packets are about 2.3 MB uncompressed.
  • batchId. Generate a new UUID for each batch. When you retry a batch, send it again with the same batchId: the server deduplicates by batchId per gateway for 24 hours. Never reuse a batchId for different content.
  • sentAtMillis. Set it when the request is sent, including on a retry.
  • Batch size and interval. Use the server's uploadBatchSize and uploadIntervalMs / activeUploadIntervalMs when they are set.

Batch Limits​

EndpointMax items per batchMax body (uncompressed)
Packets5000~4 MB
Logs200~1 MB
Locations500~1 MB

A batch over these limits fails with 400 invalid_payload. There is no separate error code for it, so stay under the limits on the client.

What the Server Validates​

Upload endpoints check authentication and schema, then queue the batch and return 202 Accepted. Processing happens later, after the response.

  • Whole-batch failure. If a required field is missing or null, the whole batch fails with 400 invalid_payload.
  • Silent per-item drops. If a field is present but unusable, the server drops that one packet and still accepts the batch. This covers an rssi of 0, a latitude or longitude of 0, and a timestamp that is 0 or out of range. Dropped packets are not reported back to the gateway, so validate on the client.

Standalone Locations​

If the gateway records location fixes separately from scans, for example continuous GPS tracking, you can also upload them with POST /api/v1/gateways/{gatewayId}/locations (reference). This endpoint is in addition to the per-packet location. It does not replace it.


Handle Errors and Retries​

Every non-2xx response has an ErrorResponse body with code, message, and retryable. Base the decision to retry on the retryable flag.

HTTPcodeWhat the gateway must do
400invalid_payloadMalformed body, missing required field, wrong Content-Type, or a batch or body that is too large. Do not resend the same payload. If the batch is oversized, split it. Otherwise, log it and drop the batch.
401invalid_sdk_keyThe Gateway Group ID is wrong or no longer valid. Stop registering and alert an operator. Do not retry in a loop.
401missing_tokenNo Bearer token was sent. Fix the request, refreshing or registering first if needed.
401token_expiredRefresh the device token, then retry the original request once.
401token_revokedDiscard credentials and register again.
401invalid_refresh_tokenDiscard credentials and register again.
403gateway_disabledAn administrator disabled this gateway. Stop uploading and alert an operator. Registering again is also refused, so do not loop.
404gateway_not_foundThe stored gatewayId is stale or does not match the token. Register again.
429rate_limitedBack off, then retry. Rate limits are per gatewayId.
503server_errorTemporary backend failure. If retryable is true, back off and retry.

Backoff​

The server never sends a Retry-After header or a wait time, so the client sets its own retry schedule. For retryable errors:

  • Start at a few seconds or more.
  • Double the delay after each consecutive failure of the same request.
  • Cap the delay. Five minutes is a reasonable ceiling.
  • Add random jitter, up to about 50% of the interval, so a fleet does not retry in lockstep.

Handle 429 and retryable 503 responses this way. Retry uploads with the same batchId.


Buffer Through Connectivity Loss​

If Hubble cannot be reached, buffer packets locally. When the connection returns, send them in chronological order. Because of the 24-hour batchId window, sending a batch that was already accepted again does no harm.

  • Buffer size. Hubble does not set a size, because it depends on your hardware. Buffer at least 1 hour of data at your expected scan volume.
  • When the buffer is full, drop the oldest packets first to make room for new ones.

Delivery is best effort. Guaranteed delivery is not required, but buffering should be reasonable.


Send Heartbeats​

A heartbeat is a periodic PUT /api/v1/gateways/{gatewayId} (reference) with the same body as registration. A heartbeat does three things:

  1. Lets Hubble tell a working gateway in a quiet area from one that is offline.
  2. Updates device state, such as battery level, BLE adapter state, locale, and push token.
  3. Returns updated server config and any pending commands.

Send a heartbeat:

  • Every 5 minutes while online
  • On startup
  • When the firmware or software version changes
  • When the BLE adapter state changes, for example from off to on
  • When the battery level crosses a significant threshold. Every 10% is recommended.

A heartbeat does not change type or deviceId. If either differs from the registered value, the server keeps the registered value and still accepts the heartbeat. To change type, register again with the same deviceId. A different deviceId registers a separate gateway: see Choosing a deviceId.


Apply Server Config and Commands​

Registration, token refresh, and heartbeat responses can include a config object and a commands list. Handle them the same way whichever call they come from.

Config​

Read the config object like this:

ResponseMeaning
A field is absent or nullUse your default for that field.
config is nullClear all server values and go back to your defaults.
The config key is missing entirelyThe server could not work out a config this time. Keep your current values.

Store the latest config with your credentials and apply it from the next cycle onward. Ignore unknown fields, because new ones may be added without a version change.

These are the config fields that apply to direct integrations. Some fields in the API reference are sent only to Hubble's SDKs.

FieldMeaning
uploadIntervalMsUpload interval while idle
activeUploadIntervalMsUpload interval while active (moving)
uploadBatchSizePackets per upload batch
dedupWindowMsDeduplication window while idle
activeDedupWindowMsDeduplication window while active
uploadOnCellularfalse means hold uploads until a non-cellular link is available

Commands​

typeWhat the gateway must do
upload_logsSend the local debug log buffer to POST /api/v1/gateways/{gatewayId}/logs (reference).
scan_nowRun a BLE scan cycle right away, without waiting for the normal interval.
re_registerDiscard local credentials and run registration again.

Ignore command types you don't recognize.


Security Requirements​

Transport​

All traffic to the Gateway API must use TLS 1.2 or higher. Never send packet data or credentials in plaintext.

Credentials​

  • Gateway Group ID. A public, non-secret key, used only at registration. It is not a device credential, and you can embed it in firmware. See Getting a Gateway Group ID.
  • Device token. Short-lived. Store it at rest with access restricted to the gateway process.
  • Refresh token. Long-lived. Store it like the device token. Anyone who has it can act as the gateway until it is revoked, so never log it or send it off the gateway.

Rotation​

Device and refresh tokens rotate on every refresh. To rotate a Gateway Group ID, create a new group in the dashboard and roll its ID out to your gateways. When no gateways depend on the old group any more, disable it. Disabling a group disables every gateway registered with it.

Disabled Gateways​

An administrator can disable a gateway, or disable its whole gateway group. Disabling revokes its tokens, so the gateway usually sees 401 token_revoked first, and then 403 gateway_disabled if it tries to register again. The gateway should stop and alert an operator rather than retry.


Compliance​

Radio regulations and data privacy rules apply to every scanner. See Compliance.


Implementation Checklist​

  • Stable, unique deviceId for each physical gateway
  • Registration with X-Sdk-Key and all required fields, including manufacturer and model
  • Credentials and config stored with restricted access
  • Token refreshed before expiry, with the rotated pair stored right away
  • token_expired handled with one refresh and one retry
  • Re-registration on token_revoked, invalid_refresh_token, gateway_not_found, and the re_register command
  • Passive scan that keeps advertisements with non-empty 0x16 Service Data for 0xFCA6
  • Payload forwarded unchanged, base64-encoded
  • No rssi of 0 and no 0, 0 coordinates. Last fix reused with its real timestamp.
  • Gateway clock synced to NTP, GPS, or cellular time
  • Sightings deduplicated, keeping the strongest RSSI
  • Batches under the limits, gzip on large batches, a new batchId for each batch, the same batchId on retry
  • Retries driven by retryable, with exponential backoff, jitter, and a cap
  • At least 1 hour of local buffer, dropping the oldest packets first
  • Heartbeat every 5 minutes and on state changes
  • Server config applied and unknown fields ignored
  • upload_logs, scan_now, and re_register commands handled
  • TLS 1.2+, refresh token never logged

ℹ️ Was this page useful? Please give us feedback.