123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- #ifndef ANT_ENCRYPT_CONFIG__
- #define ANT_ENCRYPT_CONFIG__
- #include <stdint.h>
- #include "sdk_errors.h"
- #include "nrf_sdh_ant.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define ADV_BURST_CFG_MIN_SIZE 8
- #define ADV_BURST_CFG_PACKET_SIZE_INDEX 1
- #define ADV_BURST_CFG_REQUIRED_FEATURES 2
- #define ADV_BURST_CFG_OPTIONAL_FEATURES 5
- typedef struct
- {
- uint8_t mode;
- uint8_t key_index;
- uint8_t decimation_rate;
- } ant_encrypt_channel_settings_t;
- typedef union
- {
- uint8_t * pp_array[3];
- struct
- {
- uint8_t * p_encryption_id;
- uint8_t * p_user_info;
- uint8_t * p_random_num_seed;
- } items;
- } ant_encrypt_info_settings_t;
- typedef struct
- {
- uint8_t packet_length;
- uint8_t required_feature;
- uint8_t optional_feature;
- } ant_encrypt_adv_burst_settings_t;
- typedef struct
- {
- ant_encrypt_info_settings_t info;
- uint8_t * * pp_key;
- uint8_t key_number;
- ant_encrypt_adv_burst_settings_t * p_adv_burst_config;
- } ant_encrypt_stack_settings_t;
- typedef enum
- {
- ANT_ENC_EVT_NEGOTIATION_SUCCESS,
- ANT_ENC_EVT_NEGOTIATION_FAIL,
- ANT_ENC_EVT_CHANNEL_LOST
- } ant_encrypt_user_evt_t;
- typedef void (* ant_encryp_user_handler_t)(uint8_t channel, ant_encrypt_user_evt_t event);
- #define ANT_CRYPTO_INFO_SETTINGS_INIT(P_ENC_ID, P_USER_INFO, P_RAND_NUM_SEED) \
- { \
- .items = \
- { \
- .p_encryption_id = P_ENC_ID, \
- .p_user_info = P_USER_INFO, \
- .p_random_num_seed = P_RAND_NUM_SEED \
- } \
- }
- #define ANT_ENCRYPT_STACK_SETTINGS_BASE_DEF(NAME, P_KEY, P_ENC_ID) \
- ant_encrypt_adv_burst_settings_t NAME##_ant_enc_adv_burst_set = \
- { \
- .packet_length = ADV_BURST_MODES_MAX_SIZE, \
- .required_feature = 0, \
- .optional_feature = 0 \
- }; \
- uint8_t * pp_##NAME##_key[1] = {P_KEY}; \
- ant_encrypt_stack_settings_t NAME ## _ant_crypto_settings = \
- { \
- .info = ANT_CRYPTO_INFO_SETTINGS_INIT(P_ENC_ID, NULL, NULL), \
- .pp_key = pp_##NAME##_key, \
- .key_number = 1, \
- .p_adv_burst_config = &NAME##_ant_enc_adv_burst_set \
- }
- #define ANT_ENCRYPT_STACK_SETTINGS_BASE(NAME) (NAME##_ant_crypto_settings)
- ret_code_t ant_channel_encrypt_config_perform(uint8_t channel_number,
- ant_encrypt_channel_settings_t * p_crypto_config);
- ret_code_t ant_channel_encrypt_config(uint8_t channel_type,
- uint8_t channel_num,
- ant_encrypt_channel_settings_t * p_crypto_config);
- ret_code_t ant_stack_encryption_config(ant_encrypt_stack_settings_t const * const p_crypto_info_set);
- void ant_enc_event_handler_register(ant_encryp_user_handler_t p_handler);
- #ifdef __cplusplus
- }
- #endif
- #endif
|