|
SDK for TESAIoT Dev Kit
API reference & tutorials (ModusToolbox)
|
#include <stdbool.h>#include <stddef.h>#include <stdint.h>Go to the source code of this file.
Data Structures | |
| struct | ble_nus_config_t |
| struct | ble_nus_diag_t |
Macros | |
| #define | BLE_NUS_MAX_PAYLOAD 244 |
| #define | BLE_NUS_ADV_INTERVAL_MS 100 |
| #define | BLE_NUS_ADV_FAST_SECONDS 30 |
| #define | BLE_NUS_METER_PAYLOAD_MAX 24 |
Typedefs | |
| typedef void(*) | ble_nus_rx_cb_t(const uint8_t *data, size_t len, void *user_ctx) |
| typedef void(*) | ble_nus_state_cb_t(ble_nus_state_t state, void *user_ctx) |
Enumerations | |
| enum | ble_nus_state_t { BLE_NUS_STATE_OFF = 0 , BLE_NUS_STATE_ADVERTISING , BLE_NUS_STATE_CONNECTED , BLE_NUS_STATE_ERROR } |
Functions | |
| bool | ble_nus_init (const ble_nus_config_t *cfg) |
| Initialise the AIROC stack and start advertising; the chip-power task must own the boot call. | |
| int | ble_nus_send (const uint8_t *data, size_t len) |
| Send bytes over NUS TX; -1 unless connected with notifications on. Weak stub exists pre-init. | |
| void | ble_nus_deinit (void) |
| Soft-stop: drops advertising and the link, keeps the AIROC host stack alive. | |
| void | ble_nus_rearm_advertising (void) |
| Re-arm advertising on an already-initialised stack; idempotent from any state. | |
| ble_nus_state_t | ble_nus_get_state (void) |
| Lock-free state read, safe before init; the firmware polls it rather than trusting the callback. | |
| const char * | ble_nus_get_adv_name (void) |
| Pointer to the static Bento-XXXX advertising name; NULL until the BD address resolves. | |
| void | ble_nus_passkey_cb (const char *passkey_6_digits) |
| Weak pairing-passkey callback — not reached in this build. | |
| void | ble_nus_get_diagnostics (ble_nus_diag_t *out) |
| Fill a caller-owned diagnostics snapshot — the _diag.ble block of bento.fw.query. | |
| #define BLE_NUS_MAX_PAYLOAD 244 |
Max payload size per NUS frame (BLE MTU 247 minus ATT header).
| #define BLE_NUS_ADV_INTERVAL_MS 100 |
Advertising interval, in milliseconds, once the initial fast window ends.
This bounds how often a connectionless reader can see a new reading: the payload can be rewritten far faster than the radio transmits it, so the interval, not the update rate, is the ceiling.
Override per project in the makefile, e.g. DEFINES+=BLE_NUS_ADV_INTERVAL_MS=1000 for a battery-powered node that only needs a reading a second.
100 ms suits a bench kit and a scope: mains powered, and several advertisements land inside any plausible scan window. A shipped meter on a cell would use a far longer interval and trade resolution for years of life - which is why this is a knob and not a constant.
| #define BLE_NUS_ADV_FAST_SECONDS 30 |
Seconds of fast advertising after the stack starts, before it settles to BLE_NUS_ADV_INTERVAL_MS.
| #define BLE_NUS_METER_PAYLOAD_MAX 24 |
Largest payload that fits the advertisement beside the flags structure. 31 total, 3 for flags, 4 for the manufacturer-data header and company identifier, leaves 24.
| typedef void(*) ble_nus_rx_cb_t(const uint8_t *data, size_t len, void *user_ctx) |
RX callback invoked from BLE task context when host writes to NUS RX. Payload is NOT null-terminated. Copy before returning.
| typedef void(*) ble_nus_state_cb_t(ble_nus_state_t state, void *user_ctx) |
State-change callback (advertising -> connected -> disconnected).
| enum ble_nus_state_t |