Wirepas SDK
wms_settings.h
Go to the documentation of this file.
1/* Copyright 2019 Wirepas Ltd. All Rights Reserved.
2 *
3 * See file LICENSE.txt for full license details.
4 *
5 */
6
22#ifndef APP_LIB_SETTINGS_H_
23#define APP_LIB_SETTINGS_H_
24
25#include <stdlib.h>
26#include <stdint.h>
27#include <stdbool.h>
28
29#include "wms_app.h"
30
32#define APP_LIB_SETTINGS_NAME 0x74ced676
33
35#define APP_LIB_SETTINGS_VERSION 0x20d
36
44#define APP_LIB_SETTINGS_AES_KEY_NUM_BYTES 16
45
51#define APP_LIB_SETTINGS_LL_ROLE_BIT 0x10
52
53// Device address definition is in app/app.h */
54
61
66
71#define CHANNEL_NO_CHANNEL 0
72
94
95
109
110
144typedef struct __attribute__((packed))
145{
146 struct
147 {
148 const uint8_t (*encryption_key_p)
150 const uint8_t (*authentication_key_p)
153 } network_key_pair, management_key_pair;
154
155 struct
156 {
161 uint8_t apply_flags : 1;
162
165 uint8_t app_key_management_supported : 1;
166
169 uint8_t app_key_management_configured : 1;
170
173 uint8_t revoke_keys : 1;
174
176 uint8_t reserved : 4;
177 } flags;
178
182
183
190
212typedef bool (*app_lib_settings_is_group_cb_f)(app_addr_t group_addr);
213
236
253 uint32_t * bits_p);
254
267
281
302 const uint8_t * key_p);
303
314
330
342
357
368
389
402 app_lib_settings_role_t * role_p);
403
431
455
481 const uint8_t * key_p);
482
505
531 const uint8_t * key_p);
532
554typedef app_res_e (*app_lib_settings_get_ac_range_f)(uint16_t * ac_min_value_p,
555 uint16_t * ac_max_value_p);
556
606typedef app_res_e (*app_lib_settings_set_ac_range_f)(uint16_t ac_min_value,
607 uint16_t ac_max_value);
608
621typedef app_res_e (*app_lib_settings_get_offline_scan_f)(uint16_t * max_scan_p);
622
647typedef app_res_e (*app_lib_settings_set_offline_scan_f)(uint16_t max_scan);
648
665 uint16_t * min_value_p, uint16_t * max_value_p);
666
682 uint16_t * min_value_p, uint16_t * max_value_p);
683
715
740 uint8_t * channels_p, size_t num_bytes);
741
779 const uint8_t * channels_p, size_t num_bytes);
780
789
796typedef bool (*app_lib_settings_is_valid_network_channel_f)(uint8_t channel);
797
805
814
830
831
833#define REMOTE_API_CSAP_WRITE_UNICAST 0x1
834
835// Return codes, these must match the values of the enum response_type_e in remote API
837#define REMOTE_API_CSAP_RESPONSE_NORMAL 0
839#define REMOTE_API_CSAP_RESPONSE_NONE 1
841#define REMOTE_API_CSAP_RESPONSE_ACCESS_DENIED 0xf8
843#define REMOTE_API_CSAP_RESPONSE_WRITE_ONLY_ATTRIBUTE 0xf9
845#define REMOTE_API_CSAP_RESPONSE_INVALID_BROADCAST_REQUEST 0xfa
847#define REMOTE_API_CSAP_RESPONSE_INVALID_BEGIN 0xfb
849#define REMOTE_API_CSAP_RESPONSE_NO_SPACE_FOR_RESPONSE 0xfc
851#define REMOTE_API_CSAP_RESPONSE_INVALID_VALUE 0xfd
853#define REMOTE_API_CSAP_RESPONSE_INVALID_LENGTH 0xfe
855#define REMOTE_API_CSAP_RESPONSE_UNKNOWN_REQUEST 0xff
856
877
906typedef uint8_t (*app_lib_settings_remote_api_csap_write_f)( uint16_t attr_id, uint32_t flags, app_lib_settings_remote_api_csap_data_t * data);
907
922
923
946
947
963
964
975
976
992
993
1003
1018
1026typedef struct
1027{
1069
1070#endif /* APP_LIB_SETTINGS_H_ */
app_res_e
Definition wms_app.h:202
uint32_t app_addr_t
Definition wms_app.h:228
app_res_e(* app_lib_settings_set_feature_lock_bits_f)(uint32_t bits)
Set feature lock bits.
uint8_t(* app_lib_settings_remote_api_csap_write_f)(uint16_t attr_id, uint32_t flags, app_lib_settings_remote_api_csap_data_t *data)
A callback function type used for providing the Remote API CSAP Write request information to applicat...
app_res_e(* app_lib_settings_set_node_role_f)(app_lib_settings_role_t role)
Set node role.
app_res_e(* app_lib_settings_get_network_channel_limits_f)(uint16_t *min_value_p, uint16_t *max_value_p)
Get network channel range.
app_lib_settings_get_ac_range_f getAcRange
app_res_e(* app_lib_settings_get_node_address_f)(app_addr_t *addr_p)
Get node address.
app_lib_settings_set_network_address_f setNetworkAddress
app_res_e(* app_lib_settings_set_network_channel_f)(app_lib_settings_net_channel_t channel)
Set network channel.
app_res_e(* app_lib_settings_reset_all_f)(void)
Reset all settings to default values.
app_lib_settings_set_authentication_key_f setAuthenticationKey
app_res_e(* app_lib_settings_register_remote_api_csap_update_cb_f)(app_lib_settings_remote_api_csap_update_f cb)
Register a callback function which is to be called when a CSAP Update request is received and it need...
app_lib_settings_is_valid_node_role_f isValidNodeRole
app_lib_settings_get_offline_scan_f getOfflineScan
app_res_e(* app_lib_settings_register_remote_api_csap_cancel_cb_f)(app_lib_settings_remote_api_csap_cancel_f cb)
Register a callback function which is to be called when a CSAP Cancel request is received and it need...
app_lib_settings_set_ac_range_f setAcRange
void(* app_lib_settings_remote_api_csap_cancel_f)(void)
A callback function type used for providing the Remote API Cancel request information to application ...
bool(* app_lib_settings_is_valid_node_address_f)(app_addr_t addr)
Check that the node address is valid.
app_lib_settings_set_feature_lock_bits_f setFeatureLockBits
app_lib_settings_get_network_channel_limits_f getNetworkChannelLimits
app_lib_settings_get_network_address_f getNetworkAddress
app_lib_settings_register_remote_api_csap_read_cb_f registerRemoteApiCsapReadCb
app_lib_settings_set_node_address_f setNodeAddress
app_res_e(* app_lib_settings_get_network_address_f)(app_lib_settings_net_addr_t *addr_p)
Get network address.
bool(* app_lib_settings_is_valid_network_address_f)(app_lib_settings_net_addr_t addr)
Check that the network address is valid.
app_res_e(* app_lib_settings_set_node_address_f)(app_addr_t addr)
Set node address.
app_lib_settings_get_feature_lock_key_f getFeatureLockKey
app_lib_settings_set_group_query_cb_f registerGroupQuery
app_lib_settings_get_ac_range_limits_f getAcRangeLimits
app_lib_settings_is_valid_node_address_f isValidNodeAddress
app_res_e(* app_lib_settings_get_network_channel_f)(app_lib_settings_net_channel_t *channel_p)
Get network channel.
app_res_e(* app_lib_settings_set_encryption_key_f)(const uint8_t *key_p)
Set encryption key.
app_lib_settings_set_reserved_channels_f setReservedChannels
uint32_t app_lib_settings_net_addr_t
Network address type definition.
#define APP_LIB_SETTINGS_AES_KEY_NUM_BYTES
AES key size in bytes.
app_res_e(* app_lib_settings_get_offline_scan_f)(uint16_t *max_scan_p)
Get the maximum offline scan interval in seconds.
uint8_t app_lib_settings_role_t
Node role type.
app_res_e(* app_lib_settings_set_ac_range_f)(uint16_t ac_min_value, uint16_t ac_max_value)
Set range for access cycle.
app_lib_settings_is_valid_network_channel_f isValidNetworkChannel
app_lib_settings_get_network_channel_f getNetworkChannel
app_lib_settings_is_valid_network_address_f isValidNetworkAddress
app_lib_settings_remote_api_res_e
@ APP_LIB_SETTINGS_REMOTE_API_RES_NONE
@ APP_LIB_SETTINGS_REMOTE_API_RES_OK
@ APP_LIB_SETTINGS_REMOTE_API_RES_OK_RESET
app_lib_settings_set_offline_scan_f setOfflineScan
app_lib_settings_get_node_role_f getNodeRole
app_res_e(* app_lib_settings_get_ac_range_f)(uint16_t *ac_min_value_p, uint16_t *ac_max_value_p)
Get the access cycle range.
app_lib_settings_key_management_config_f keyManagementConfiguration
app_lib_settings_set_network_channel_f setNetworkChannel
app_res_e(* app_lib_settings_get_node_role_f)(app_lib_settings_role_t *role_p)
app_res_e(* app_lib_settings_get_authentication_key_f)(uint8_t *key_p)
Check if the authentication key is set and read the key value.
app_res_e(* app_lib_settings_set_feature_lock_key_f)(const uint8_t *key_p)
Set feature lock key.
app_lib_settings_get_node_address_f getNodeAddress
bool(* app_lib_settings_is_group_cb_f)(app_addr_t group_addr)
Callback used for determining on which multicast groups the device belongs.
app_res_e(* app_lib_settings_set_group_query_cb_f)(app_lib_settings_is_group_cb_f cb)
Set the callback function for multicat groups.
app_lib_settings_reset_all_f resetAll
app_res_e(* app_lib_settings_set_authentication_key_f)(const uint8_t *key_p)
Set authentication key.
app_res_e(* app_lib_settings_key_management_config_f)(const app_lib_settings_key_management_configuration_t *key_mgmt_cfg_p)
Key management configuration using the settings API.
app_res_e(* app_lib_settings_set_reserved_channels_f)(const uint8_t *channels_p, size_t num_bytes)
Set reserved channels.
app_res_e(* app_lib_settings_get_feature_lock_key_f)(uint8_t *key_p)
Check if feature lock key is set.
bool(* app_lib_settings_is_valid_node_role_f)(app_lib_settings_role_t role)
Check that the node role is valid.
app_lib_settings_set_encryption_key_f setEncryptionKey
app_res_e(* app_lib_settings_register_remote_api_csap_write_cb_f)(app_lib_settings_remote_api_csap_write_f cb)
Register a callback function which is to be called when a CSAP Write request is received and it needs...
app_lib_settings_get_reserved_channels_f getReservedChannels
app_res_e(* app_lib_settings_get_feature_lock_bits_f)(uint32_t *bits_p)
Get feature lock bits.
app_lib_settings_remote_api_res_e(* app_lib_settings_remote_api_csap_update_f)(void)
A callback function type used for providing the Remote API Update request information to application ...
app_lib_settings_set_feature_lock_key_f setFeatureLockKey
app_res_e(* app_lib_settings_set_network_address_f)(app_lib_settings_net_addr_t addr)
Set network address.
app_lib_settings_set_node_role_f setNodeRole
app_res_e(* app_lib_settings_get_encryption_key_f)(uint8_t *key_p)
Check if the encryption key is set and read the key value.
app_res_e(* app_lib_settings_get_ac_range_limits_f)(uint16_t *min_value_p, uint16_t *max_value_p)
Get access cycle range limits.
uint8_t(* app_lib_settings_remote_api_csap_read_f)(uint16_t attr_id, app_lib_settings_remote_api_csap_data_t *data)
A callback function type used for providing the Remote API CSAP Read request information to applicati...
app_lib_settings_role_e
@ APP_LIB_SETTINGS_ROLE_HEADNODE_LE
@ APP_LIB_SETTINGS_ROLE_SUBNODE_LL
@ APP_LIB_SETTINGS_ROLE_SINK_LL
@ APP_LIB_SETTINGS_ROLE_HEADNODE_LL
@ APP_LIB_SETTINGS_ROLE_AUTOROLE_LE
@ APP_LIB_SETTINGS_ROLE_SINK_LE
@ APP_LIB_SETTINGS_ROLE_SUBNODE_LE
@ APP_LIB_SETTINGS_ROLE_ADVERTISER
@ APP_LIB_SETTINGS_ROLE_AUTOROLE_LL
app_lib_settings_get_authentication_key_f getAuthenticationKey
app_res_e(* app_lib_settings_get_reserved_channels_f)(uint8_t *channels_p, size_t num_bytes)
Get reserved channels.
app_lib_settings_register_remote_api_csap_update_cb_f registerRemoteApiCsapUpdateCb
app_lib_settings_get_encryption_key_f getEncryptionKey
app_res_e(* app_lib_settings_register_remote_api_csap_read_cb_f)(app_lib_settings_remote_api_csap_read_f cb)
Register a callback function which is to be called when a CSAP Read request is received and it needs ...
app_lib_settings_register_remote_api_csap_cancel_cb_f registerRemoteApiCsapCancelCb
app_lib_settings_get_feature_lock_bits_f getFeatureLockBits
bool(* app_lib_settings_is_valid_network_channel_f)(uint8_t channel)
Check that the network channel is valid.
uint8_t app_lib_settings_net_channel_t
Channel type definition.
app_lib_settings_register_remote_api_csap_write_cb_f registerRemoteApiCsapWriteCb
app_res_e(* app_lib_settings_set_offline_scan_f)(uint16_t max_scan)
Set the maximum offline scan interval in seconds.
Struct containing the CSAP Read adn Write request and response information. Needed the requests are h...
Structure to hold key management configuration information for the settings API.
Settings library API.