DocsBluetooth LE Open APIDevice State Reference

Device State Reference

The device's live state, exposed as named values you can read, write, and subscribe to.

Device state is a flat set of named values. Each one is:

  • Readable { method: "get", ns: "deviceState", prop: "<KEY>" }
  • Writable { method: "set", ns: "deviceState", prop: "<KEY>", value: … }
  • Streamable — whenever a value changes, an event is pushed on EVENTS_OUT (while DEVICE_APP_CONNECTED is true).

Reading vs. writing in practice

Many values are populated by the device itself (GPS, battery, kill counts, ammo during play) — you'll usually read and subscribeto those rather than write them. The API allows writing any value; it's coerced to the value's type and rejected with invalidValue on a mismatch.

Device

KeyTypeDescription
FSM_STATEstringCurrent state-machine state (also on the fsm namespace).
DEVICE_ROLEnumberHost, client, moderator, etc.
DEVICE_ENVnumberIndoor / outdoor environment.
DEVICE_VOLUMEnumberDevice audio volume.
DEVICE_BATTERY_LEVELnumber255 = full, 0 = empty. Event rate-limited (~5s).
DEVICE_WIFI_NAMEstringProvisioned WiFi network name.
DEVICE_WIFI_STATUSnumber0 = disconnected, 1 = connecting, 2 = connected.
DEVICE_BLE_MACstringThe device's Bluetooth MAC address.
DEVICE_BLE_COUNTnumberNumber of connected BLE devices.
DEVICE_APP_CONNECTEDbooleanSet true to enable the live event stream. Set on connect.
DEVICE_HEADSET_CONNECTEDbooleanWhether a headset is paired.
DEVICE_ESP_BRIDGEbooleanRelay ESP-NOW mesh traffic over the event channel.
IR_RECEIVER_ENABLEDbooleanWhether the IR receiver is enabled.
DEVICE_DEBUG_ENABLEDbooleanWhether BLE debug output is enabled.

NFC

KeyTypeDescription
NFC_TAGstringUID (hex) of the currently-present NFC tag; empty when no tag is present. Treat a change to a non-empty value as "a tag appeared", and to empty as "removed".
NFC_DATAstringThe first NDEF text/URI record payload of the last tag read. Set (and streamed) just before NFC_TAG when a tag appears, so it is available when NFC_TAG changes. NOT cleared on removal.

Location

KeyTypeDescription
GPS_SATELLITESnumberSatellites locked. Event rate-limited (~2s).
GPS_LATITUDEnumberLatitude. Event rate-limited (~2s).
GPS_LONGITUDEnumberLongitude. Event rate-limited (~2s).

Game

KeyTypeDescription
GAME_CONNECTEDbooleanWhether the device is in a game.
GAME_IDnumberCurrent game id.
GAME_PLAYER_COUNTnumberPlayers in the game / lobby.
GAME_HOST_MACstringThe host's MAC address (when this device is a client).
GAME_DISPLAY_NAMEstringHuman-readable game name.
GAME_TIMEnumberLive game clock. GET returns the running clock.
GAME_TIME_MAX_MINSnumberGame length in minutes (0 = unlimited).
GAME_SCRIPT_IDstringBattleScript file id for the game.
GAME_SCRIPT_LABELstringBattleScript label.
GAME_IS_TEAM_BASEDbooleanWhether the game is team-based.
GAME_RESPAWN_MODEnumberTrigger respawn, base respawn, etc.
GAME_RESPAWN_TIME_SECSnumberRespawn delay in seconds.
GAME_WEAPON_1numberStarting weapon 1 (0 = none).
GAME_WEAPON_2numberStarting weapon 2 (0 = none).
GAME_RADAR_TYPEnumber0 = off, 1 = movement-based, 2 = permanent.
GAME_MAP_TYPEnumber0 = unlimited, 1 = limited.
AUDIO_PACKstringAudio pack in use.
TEAM_POINTSnumberThe team's total score (signed).

Player & vitals

KeyTypeDescription
PLAYER_READYbooleanWhether the player is marked ready.
PLAYER_NAMEstringPlayer name.
PLAYER_IDnumberPlayer / tagger id.
PLAYER_TEAM_IDnumberTeam the player is on.
PLAYER_SHIELDnumberCurrent shield.
PLAYER_SHIELD_INITIALnumberShield the player starts with.
PLAYER_SHIELD_MAXnumberMaximum shield.
PLAYER_SHIELD_FULL_RECHARGE_TIMEnumberms to recharge shield 0→100%. 0 = not recharging.
PLAYER_ARMOURnumberCurrent armour.
PLAYER_ARMOUR_INITIALnumberArmour the player starts with.
PLAYER_ARMOUR_MAXnumberMaximum armour.
PLAYER_LIVESnumberCurrent lives.
PLAYER_LIVES_INITIALnumberLives the player starts with.
PLAYER_LIVES_MAXnumberMaximum lives.
PLAYER_POINTSnumberThe player's total score (signed).
PLAYER_KILL_COUNTnumberKills achieved.
PLAYER_DEATH_COUNTnumberDeaths.
PLAYER_IS_INVULNERABLEbooleanWhether the player cannot take damage.
PLAYER_IS_RESPAWNINGbooleanWhether a respawn countdown is running.
COUNTDOWN_SECSnumberLive on-screen countdown in seconds (e.g. respawn). Read alongside FSM_STATE.

Weapon

KeyTypeDescription
WEAPON_IDnumberCurrently enabled weapon.
WEAPON_AMMOnumberCurrent ammo.
WEAPON_AMMO_MAXnumberMaximum ammo.
WEAPON_SHOTS_FIREDnumberTotal shots fired.
WEAPON_SHOT_POWERnumberCurrent shot power (damage or healing).
WEAPON_SHOT_TYPEnumberCurrent shot type.
WEAPON_SHOT_INTERVAL_MSnumberMinimum time between shots (fire rate).
WEAPON_SHOT_CHARGE_MIN_MSnumberMinimum charge-up time.
WEAPON_SHOT_CHARGE_MAX_MSnumberMaximum charge-up time.
WEAPON_SHOT_DELAY_MSnumberDelay between trigger pull and firing.
WEAPON_IS_CHARGE_BASEDbooleanWhether the weapon must be charged before firing.
WEAPON_IS_CHARGINGbooleanWhether the weapon is currently charging.
WEAPON_SHOT_CHARGE_AUTO_FIREbooleanFire on full charge vs. on trigger release.
WEAPON_CAN_RELOADbooleanWhether the current weapon can reload.
WEAPON_RELOAD_DELAY_MSnumberReload time in ms.
WEAPON_IS_BUSYnumberCount of actions making the weapon busy (reloading, jammed, …).
LED_MUZZLE_FLASHbooleanWhether the muzzle-flash LED is on.

Reading NFC tags

Subscribe to NFC_TAG to react to tags: it holds the UID (hex) of the tag currently on the reader, and is set back to an empty string the moment the tag is removed. So a change to a non-empty value means "a tag appeared" and a change to empty means "removed".

NFC_DATA is set before NFC_TAG

When a tag appears, the device reads its first NDEF text or URI record and puts the payload in NFC_DATA — and it does so before updating NFC_TAG. Because events are delivered in order, by the time you receive the NFC_TAG change the matching NFC_DATA has already arrived. Read them together: trigger off NFC_TAG, then use the latest NFC_DATA.

NFC_DATA is not cleared on removal (it reflects the last tag read), and is empty if the tag had no readable NDEF text/URI record. Both NTAG/Ultralight and MIFARE Classic tags are supported.

Game states

The device's state machine drives what's happening in a game. Subscribe to the fsm event ({ ns: "fsm", prop: "state", value }) to follow transitions, or read the current value with { method: "get", ns: "fsm", prop: "state" }. The common gameplay states:

StateMeaning
HOMELobby / idle — looking for and counting nearby players.
GAME_LOBBYJoined a game lobby, waiting for the game to start.
IN_GAMEActively playing.
DEADEliminated, awaiting respawn (trigger-pull or respawn box).
RESPAWNINGRespawn countdown running — see COUNTDOWN_SECS.
GAME_OVERThis player is out of lives (player-specific).
GAME_ENDThe game has ended for everyone.