Wirepas SDK
wms_state.h
Go to the documentation of this file.
1 /* Copyright 2017 Wirepas Ltd. All Rights Reserved.
2  *
3  * See file LICENSE.txt for full license details.
4  *
5  */
6 
15 #ifndef APP_LIB_STATE_H_
16 #define APP_LIB_STATE_H_
17 
18 #include <stdlib.h>
19 #include <stdint.h>
20 #include <stdbool.h>
21 #include <limits.h>
22 
23 #include "wms_app.h"
24 #include "wms_settings.h" // For app_lib_settings_net_channel_t
25 
27 #define APP_LIB_STATE_NAME 0x02f9c165
28 
29 
30 #define APP_LIB_STATE_VERSION 0x20E
31 
37 #define APP_LIB_STATE_INVALID_ROUTE_COST UINT8_MAX
38 
44 #define APP_LIB_STATE_COST_UNKNOWN 0
45 
51 #define APP_LIB_STATE_LINKREL_UNKNOWN 0
52 
53 
59 typedef enum
60 {
69 
74 typedef enum
75 {
85 
89 typedef enum
90 {
97 
101 typedef struct
102 {
104  uint32_t address;
106  uint16_t last_update;
121  int8_t norm_rssi;
126  uint8_t cost;
130  uint8_t type;
136  int8_t tx_power;
142  int8_t rx_power;
144  uint8_t diradv_support;
146 
150 typedef struct
151 {
155  uint32_t number_nbors;
159 
163 typedef enum
164 {
175 
179 typedef enum
180 {
185 
189 typedef enum
190 {
194 
198 typedef struct
199 {
201 
212  int8_t rssi;
218  int8_t txpower;
219  bool is_sink;
220  bool is_ll;
221  uint8_t cost;
222  uint8_t type;
223 
228 
232 typedef struct
233 {
235  uint8_t hops_left;
237 
241 typedef struct
242 {
252  uint8_t cost;
254 
259 typedef enum
260 {
270 
281 typedef struct
282 {
287  uint8_t quality;
289  uint8_t error_codes;
291 
295 typedef enum
296 {
297  // Scan originated by application (by using call @ref
298  // app_lib_state_start_scan_nbors_f "lib_state->startScanNbors()")
300  // Scan originated by stack
303 
307 typedef struct
308 {
309  // Type of scan, @ref app_lib_state_scan_type_e
310  uint8_t scan_type;
312 
316 typedef struct
317 {
318  // Type (originator) of the scan
320  // Scan completion status: complete (true) or aborted (false)
321  bool complete;
323 
329 typedef void (*app_lib_state_on_beacon_cb_f)
330  (const app_lib_state_beacon_rx_t * beacon);
331 
361 
379 
393 typedef uint8_t (*app_lib_state_get_stack_state_f)(void);
394 
403 typedef app_res_e (*app_lib_state_get_access_cycle_f)(uint16_t * ac_value_p);
404 
410 typedef enum
411 {
428 
472 typedef void (*app_lib_state_on_stack_event_cb_f)
473  (app_lib_stack_event_e event, void *param);
474 
483 
502 
528 
535 typedef app_res_e
537 
552 typedef app_res_e (*app_lib_state_get_sink_cost_f)(uint8_t * cost_p);
553 
573 typedef app_res_e (*app_lib_state_set_sink_cost_f)(const uint8_t cost);
574 
575 
576 
585 
598 
607 
613  (void);
614 
618 typedef struct
619 {
635 
636 #endif /* APP_LIB_STATE_H_ */
APP_LIB_STATE_NETWORK_ADDRESS_NOT_SET
@ APP_LIB_STATE_NETWORK_ADDRESS_NOT_SET
Network address is not set.
Definition: wms_state.h:168
app_lib_state_start_scan_nbors_f
app_res_e(* app_lib_state_start_scan_nbors_f)(void)
Start neighbor scan.
Definition: wms_state.h:501
app_lib_state_install_quality_t::quality
uint8_t quality
Definition: wms_state.h:287
app_lib_state_t::getRouteInfo
app_lib_state_get_route_f getRouteInfo
Definition: wms_state.h:629
APP_LIB_STATE_ROLE_NOT_SET
@ APP_LIB_STATE_ROLE_NOT_SET
Node role is not set.
Definition: wms_state.h:170
app_lib_state_nbor_info_t::channel
app_lib_settings_net_channel_t channel
Definition: wms_state.h:128
app_lib_state_neighbor_scan_info_t::scan_type
app_lib_state_scan_type_e scan_type
Definition: wms_state.h:319
app_lib_state_install_quality_t
Installation quality information. Contains information about the nodes installation location i....
Definition: wms_state.h:281
app_lib_settings_net_channel_t
uint8_t app_lib_settings_net_channel_t
Channel type definition.
Definition: wms_settings.h:58
app_lib_state_beacon_rx_t::is_sink
bool is_sink
Device is sink.
Definition: wms_state.h:219
app_lib_state_scan_stop_f
app_res_e(* app_lib_state_scan_stop_f)(void)
Stops ongoing scan operation before ended.
Definition: wms_state.h:597
app_lib_state_route_info_t::sink
app_addr_t sink
Definition: wms_state.h:246
app_lib_state_install_quality_t::error_codes
uint8_t error_codes
Definition: wms_state.h:289
app_lib_state_get_sink_cost_f
app_res_e(* app_lib_state_get_sink_cost_f)(uint8_t *cost_p)
Query the currently set additional penalty for the sink usage.
Definition: wms_state.h:552
app_lib_state_beacon_type_e
app_lib_state_beacon_type_e
Type for beacons, passed in app_lib_state_beacon_rx_t.
Definition: wms_state.h:189
APP_LIB_STATE_NEIGHBOR_IS_CLUSTER
@ APP_LIB_STATE_NEIGHBOR_IS_CLUSTER
Definition: wms_state.h:67
app_lib_state_hops_adjust_t
Definition: wms_state.h:232
app_lib_state_nbor_info_t::last_update
uint16_t last_update
Definition: wms_state.h:106
app_lib_state_t::getAccessCycle
app_lib_state_get_access_cycle_f getAccessCycle
Definition: wms_state.h:623
app_lib_state_set_stack_event_cb_f
app_res_e(* app_lib_state_set_stack_event_cb_f)(app_lib_state_on_stack_event_cb_f cb)
Register callback for stack events.
Definition: wms_state.h:482
app_lib_state_get_install_quality_f
app_res_e(* app_lib_state_get_install_quality_f)(app_lib_state_install_quality_t *qual_out)
Read installation quality, app_lib_state_install_quality_t.
Definition: wms_state.h:606
app_lib_state_nbor_info_t::tx_power
int8_t tx_power
Definition: wms_state.h:136
app_lib_state_nbor_info_t::address
uint32_t address
Definition: wms_state.h:104
app_lib_state_hops_adjust_t::hops_left
uint8_t hops_left
Definition: wms_state.h:235
app_res_e
app_res_e
Definition: wms_app.h:201
app_lib_state_t::getStackState
app_lib_state_get_stack_state_f getStackState
Definition: wms_state.h:622
app_lib_state_beacon_rx_t::txpower
int8_t txpower
Tx power in dB This equals maximum transmission power that sender can transmit (which is used when tr...
Definition: wms_state.h:218
app_lib_state_beacon_rx_t
Structure to hold the information about received beacons.
Definition: wms_state.h:198
APP_LIB_STATE_SCAN_NBORS_ALL
@ APP_LIB_STATE_SCAN_NBORS_ALL
Definition: wms_state.h:92
APP_LIB_STATE_STACK_EVENT_SCRAT_XFER_STARTED
@ APP_LIB_STATE_STACK_EVENT_SCRAT_XFER_STARTED
Definition: wms_state.h:422
APP_LIB_STATE_INSTALL_QUALITY_ERROR_NOROUTE
@ APP_LIB_STATE_INSTALL_QUALITY_ERROR_NOROUTE
Definition: wms_state.h:264
wms_app.h
wms_settings.h
APP_LIB_STATE_STACK_EVENT_STACK_STARTED
@ APP_LIB_STATE_STACK_EVENT_STACK_STARTED
Definition: wms_state.h:415
app_lib_state_on_stack_event_cb_f
void(* app_lib_state_on_stack_event_cb_f)(app_lib_stack_event_e event, void *param)
Function type stack events callback.
Definition: wms_state.h:473
app_lib_state_get_access_cycle_f
app_res_e(* app_lib_state_get_access_cycle_f)(uint16_t *ac_value_p)
Get current access cycle.
Definition: wms_state.h:403
app_lib_state_nbor_list_t::nbors
app_lib_state_nbor_info_t * nbors
Definition: wms_state.h:157
APP_LIB_STATE_STACK_EVENT_SCRAT_XFER_STOPPED
@ APP_LIB_STATE_STACK_EVENT_SCRAT_XFER_STOPPED
Definition: wms_state.h:424
app_lib_stack_event_e
app_lib_stack_event_e
List of event generated by the stack when registering to app_lib_state_set_stack_event_cb_f.
Definition: wms_state.h:410
app_lib_state_beacon_rx_t::is_da_support
bool is_da_support
Sender supports Directed Advertiser sending packets to it.
Definition: wms_state.h:226
app_lib_state_nbor_info_t::rx_power
int8_t rx_power
Definition: wms_state.h:142
app_lib_state_route_info_t
Structure for route information.
Definition: wms_state.h:241
app_lib_state_set_on_beacon_cb_f
app_res_e(* app_lib_state_set_on_beacon_cb_f)(app_lib_state_on_beacon_cb_f cb)
Set a callback to be called when a beacon is received.
Definition: wms_state.h:536
app_lib_state_get_cluster_channel_t
app_lib_settings_net_channel_t(* app_lib_state_get_cluster_channel_t)(void)
Query cluster channel (i.e. operating channel) currently in use.
Definition: wms_state.h:613
app_lib_state_beacon_rx_t::is_ll
bool is_ll
Device is LL.
Definition: wms_state.h:220
app_lib_state_route_info_t::state
app_lib_state_route_state_e state
Definition: wms_state.h:244
APP_LIB_STATE_STOPPED
@ APP_LIB_STATE_STOPPED
Stack is stopped.
Definition: wms_state.h:166
app_lib_state_scan_type_e
app_lib_state_scan_type_e
Types of scans.
Definition: wms_state.h:295
app_lib_state_on_beacon_cb_f
void(* app_lib_state_on_beacon_cb_f)(const app_lib_state_beacon_rx_t *beacon)
Function type for a beacon reception callback.
Definition: wms_state.h:330
app_lib_state_start_stack_f
app_res_e(* app_lib_state_start_stack_f)(void)
Start the stack.
Definition: wms_state.h:360
app_lib_state_t
List of library functions.
Definition: wms_state.h:618
APP_LIB_STATE_NEIGHBOR_IS_NEXT_HOP
@ APP_LIB_STATE_NEIGHBOR_IS_NEXT_HOP
Definition: wms_state.h:63
APP_LIB_STATE_DIRADV_SUPPORTED
@ APP_LIB_STATE_DIRADV_SUPPORTED
Definition: wms_state.h:78
APP_LIB_STATE_DIRADV_NOT_SUPPORTED
@ APP_LIB_STATE_DIRADV_NOT_SUPPORTED
Definition: wms_state.h:80
APP_LIB_STATE_ACCESS_DENIED
@ APP_LIB_STATE_ACCESS_DENIED
Operation is not allowed.
Definition: wms_state.h:173
app_lib_state_route_info_t::next_hop
app_addr_t next_hop
Definition: wms_state.h:248
app_lib_state_t::stopScanNbors
app_lib_state_scan_stop_f stopScanNbors
Definition: wms_state.h:630
app_lib_state_diradv_support_e
app_lib_state_diradv_support_e
Support type for directed advertiser, i.e. does neighbor support sending directed advertiser packets ...
Definition: wms_state.h:74
app_lib_state_nbor_info_t::norm_rssi
int8_t norm_rssi
Definition: wms_state.h:121
app_lib_state_t::startStack
app_lib_state_start_stack_f startStack
Definition: wms_state.h:620
app_lib_state_t::startScanNbors
app_lib_state_start_scan_nbors_f startScanNbors
Definition: wms_state.h:624
app_lib_state_scan_nbors_type_e
app_lib_state_scan_nbors_type_e
Scan neighbor type to specify the scans that trigger the callback.
Definition: wms_state.h:89
APP_LIB_STATE_STARTED
@ APP_LIB_STATE_STARTED
Stack is started.
Definition: wms_state.h:165
SCAN_TYPE_APP_ORIGINATED
@ SCAN_TYPE_APP_ORIGINATED
Definition: wms_state.h:299
APP_LIB_STATE_INSTALL_QUALITY_ERROR_NONBORS
@ APP_LIB_STATE_INSTALL_QUALITY_ERROR_NONBORS
Definition: wms_state.h:266
app_lib_state_nbor_list_t
Neighbors list definition.
Definition: wms_state.h:150
install_quality_error_code_e
install_quality_error_code_e
Error codes for installation quality, if an error code is active, corrective action regarding the ins...
Definition: wms_state.h:259
app_lib_state_beacon_rx_t::address
app_addr_t address
Address of the beacon sender.
Definition: wms_state.h:200
app_lib_state_on_scan_start_info_t::scan_type
uint8_t scan_type
Definition: wms_state.h:310
APP_LIB_STATE_NODE_ADDRESS_NOT_SET
@ APP_LIB_STATE_NODE_ADDRESS_NOT_SET
Node address is not set.
Definition: wms_state.h:167
app_lib_state_get_stack_state_f
uint8_t(* app_lib_state_get_stack_state_f)(void)
Get the stack state.
Definition: wms_state.h:393
app_lib_state_beacon_rx_t::rssi
int8_t rssi
RSSI in dBm.
Definition: wms_state.h:212
app_addr_t
uint32_t app_addr_t
Definition: wms_app.h:228
app_lib_state_get_nbors_f
app_res_e(* app_lib_state_get_nbors_f)(app_lib_state_nbor_list_t *nbors_list)
Get list of neighbors.
Definition: wms_state.h:527
app_lib_state_route_state_e
app_lib_state_route_state_e
Route state.
Definition: wms_state.h:179
app_lib_state_neighbor_scan_info_t
Information on neighbor scan.
Definition: wms_state.h:316
app_lib_state_stop_stack_f
app_res_e(* app_lib_state_stop_stack_f)(void)
Stop the stack.
Definition: wms_state.h:378
APP_LIB_STATE_DIRADV_UNKNOWN
@ APP_LIB_STATE_DIRADV_UNKNOWN
Definition: wms_state.h:83
app_lib_state_nbor_info_t::diradv_support
uint8_t diradv_support
Definition: wms_state.h:144
app_lib_state_t::stopStack
app_lib_state_stop_stack_f stopStack
Definition: wms_state.h:621
app_lib_state_set_sink_cost_f
app_res_e(* app_lib_state_set_sink_cost_f)(const uint8_t cost)
Set additional penalty for the sink usage.
Definition: wms_state.h:573
app_lib_state_nbor_list_t::number_nbors
uint32_t number_nbors
Definition: wms_state.h:155
APP_LIB_STATE_ROUTE_STATE_INVALID
@ APP_LIB_STATE_ROUTE_STATE_INVALID
No next hop / route.
Definition: wms_state.h:181
app_lib_state_nbor_type_e
app_lib_state_nbor_type_e
Neighbor type.
Definition: wms_state.h:59
APP_LIB_STATE_APP_CONFIG_DATA_NOT_SET
@ APP_LIB_STATE_APP_CONFIG_DATA_NOT_SET
Definition: wms_state.h:171
APP_LIB_STATE_SCAN_NBORS_ONLY_REQUESTED
@ APP_LIB_STATE_SCAN_NBORS_ONLY_REQUESTED
Definition: wms_state.h:95
app_lib_state_on_scan_start_info_t
Information on started scan.
Definition: wms_state.h:307
APP_LIB_STATE_BEACON_TYPE_CB
@ APP_LIB_STATE_BEACON_TYPE_CB
Cluster beacon.
Definition: wms_state.h:192
APP_LIB_STATE_ROUTE_STATE_PENDING
@ APP_LIB_STATE_ROUTE_STATE_PENDING
Acquiring next hop / route.
Definition: wms_state.h:182
APP_LIB_STATE_NETWORK_CHANNEL_NOT_SET
@ APP_LIB_STATE_NETWORK_CHANNEL_NOT_SET
Network channel is not set.
Definition: wms_state.h:169
app_lib_state_nbor_info_t::link_reliability
uint8_t link_reliability
Definition: wms_state.h:110
app_lib_state_nbor_info_t::cost
uint8_t cost
Definition: wms_state.h:126
app_lib_state_neighbor_scan_info_t::complete
bool complete
Definition: wms_state.h:321
SCAN_TYPE_STACK_ORIGINATED
@ SCAN_TYPE_STACK_ORIGINATED
Definition: wms_state.h:301
APP_LIB_STATE_BEACON_TYPE_NB
@ APP_LIB_STATE_BEACON_TYPE_NB
Network beacon.
Definition: wms_state.h:191
APP_LIB_STATE_STACK_EVENT_SCAN_STARTED
@ APP_LIB_STATE_STACK_EVENT_SCAN_STARTED
Definition: wms_state.h:417
app_lib_state_stack_state_e
app_lib_state_stack_state_e
Stack state flags.
Definition: wms_state.h:163
app_lib_state_nbor_info_t
Neighbors info definition.
Definition: wms_state.h:101
app_lib_state_t::setOnStackEventCb
app_lib_state_set_stack_event_cb_f setOnStackEventCb
Definition: wms_state.h:632
app_lib_state_t::setOnBeaconCb
app_lib_state_set_on_beacon_cb_f setOnBeaconCb
Definition: wms_state.h:626
app_lib_state_t::setSinkCost
app_lib_state_set_sink_cost_f setSinkCost
Definition: wms_state.h:628
APP_LIB_STATE_STACK_EVENT_STACK_STOPPED
@ APP_LIB_STATE_STACK_EVENT_STACK_STOPPED
Definition: wms_state.h:413
app_lib_state_t::getSinkCost
app_lib_state_get_sink_cost_f getSinkCost
Definition: wms_state.h:627
APP_LIB_STATE_INSTALL_QUALITY_ERROR_NONE
@ APP_LIB_STATE_INSTALL_QUALITY_ERROR_NONE
Definition: wms_state.h:262
app_lib_state_t::getClusterChannel
app_lib_state_get_cluster_channel_t getClusterChannel
Definition: wms_state.h:633
APP_LIB_STATE_STACK_EVENT_SCAN_STOPPED
@ APP_LIB_STATE_STACK_EVENT_SCAN_STOPPED
Definition: wms_state.h:419
APP_LIB_STATE_STACK_EVENT_ROUTE_CHANGED
@ APP_LIB_STATE_STACK_EVENT_ROUTE_CHANGED
Definition: wms_state.h:426
app_lib_state_nbor_info_t::type
uint8_t type
Definition: wms_state.h:130
APP_LIB_STATE_INSTALL_QUALITY_ERROR_BADRSSI
@ APP_LIB_STATE_INSTALL_QUALITY_ERROR_BADRSSI
Definition: wms_state.h:268
app_lib_state_get_route_f
app_res_e(* app_lib_state_get_route_f)(app_lib_state_route_info_t *info)
Get route information.
Definition: wms_state.h:584
APP_LIB_STATE_ROUTE_STATE_VALID
@ APP_LIB_STATE_ROUTE_STATE_VALID
Valid next hop / route.
Definition: wms_state.h:183
app_lib_state_t::getInstallQual
app_lib_state_get_install_quality_f getInstallQual
Definition: wms_state.h:631
app_lib_state_t::getNbors
app_lib_state_get_nbors_f getNbors
Definition: wms_state.h:625
APP_LIB_STATE_NEIGHBOR_IS_MEMBER
@ APP_LIB_STATE_NEIGHBOR_IS_MEMBER
Definition: wms_state.h:65