nRF51 SDK
|
Macros | |
#define | SOURCE_FILE NRF_SOURCE_FILE_GZP_DEVICE |
File identifer for asserts. | |
Functions | |
void | gzp_init () |
void | gzp_erase_pairing_data (void) |
bool | gzp_address_req_send () |
gzp_id_req_res_t | gzp_id_req_send () |
void | gzp_id_req_cancel () |
bool | gzp_crypt_data_send (const uint8_t *src, uint8_t length) |
Misc. defines | |
#define | GZP_PARAMS_DB_ELEMENT_SYSTEM_ADDRESS 0 |
System address position. | |
#define | GZP_PARAMS_DB_ELEMENT_HOST_ID (GZP_PARAMS_DB_ELEMENT_SYSTEM_ADDRESS + GZP_SYSTEM_ADDRESS_WIDTH) |
Host ID position. | |
#define | GZP_PARAMS_DB_ELEMENT_SIZE (GZP_SYSTEM_ADDRESS_WIDTH + GZP_HOST_ID_LENGTH) |
Total size. | |
#define | GZP_PARAMS_DB_MAX_ENTRIES 14 |
Maximum allowed entries in the database. | |
Derived parameters | |
#define | GZP_PARAMS_DB_ADR GZP_PARAMS_STORAGE_ADR |
#define | GZP_PARAMS_DB_SIZE (GZP_PARAMS_DB_MAX_ENTRIES * GZP_PARAMS_DB_ELEMENT_SIZE) |
#define | GZP_INDEX_DB_ADR (GZP_PARAMS_STORAGE_ADR + GZP_PARAMS_DB_SIZE) |
#define | GZP_INDEX_DB_SIZE (GZP_DEVICE_PARAMS_STORAGE_SIZE - GZP_PARAMS_DB_SIZE) |
Typedefs | |
enum | gzp_tx_rx_trans_result_t { GZP_TX_RX_SUCCESS, GZP_TX_RX_FAILED_TO_SEND, GZP_TX_RX_NO_RESPONSE } |
Internal variables | |
static uint8_t | gzp_system_address [GZP_SYSTEM_ADDRESS_WIDTH] |
static uint8_t | gzp_host_id [GZP_HOST_ID_LENGTH] |
static uint8_t | dyn_key [GZP_DYN_KEY_LENGTH] |
static bool | gzp_id_req_pending = false |
Internal (static) function prototypes | |
static bool | gzp_tx_packet (const uint8_t *tx_packet, uint8_t length, uint8_t pipe) |
static gzp_tx_rx_trans_result_t | gzp_tx_rx_transaction (const uint8_t *tx_packet, uint8_t tx_length, uint8_t *rx_dst, uint32_t *rx_length, uint8_t pipe) |
static bool | gzp_crypt_tx_transaction (const uint8_t *tx_packet, uint8_t length) |
static bool | gzp_key_update (void) |
static void | gzp_params_db_add (const uint8_t *src_element, uint8_t index) |
static void | gzp_params_db_read (uint8_t *dst_element, uint8_t index) |
static void | gzp_index_db_add (uint8_t index) |
static uint8_t | gzp_index_db_read (void) |
static bool | gzp_index_db_full (void) |
static bool | gzp_index_db_empty (void) |
static bool | gzp_array_is_set (const uint8_t *src, uint8_t length) |
static bool | gzp_params_store (bool store_all) |
static bool | gzp_params_restore (void) |
void | gzp_delay_rx_periods (uint32_t rx_periods) |
void | gzp_tick_sleep_rx_periods (uint32_t rx_periods) |
void | print_string (char *p_expr) |
Internal (static) variables | |
static nrf_gzll_device_tx_info_t | latest_tx_info |
Information about the last TX attempt, e.g. RSSI of ACK. | |
static bool | tx_complete |
Flag to indicate whether a GZLL TX attempt has completed. | |
static bool | tx_success |
Flag to indicate whether a GZLL TX attempt was successful. | |
static const uint32_t | database [GZP_DEVICE_PARAMS_STORAGE_SIZE/4] |
Database for storing keys. More... | |
Possible return values for the function gzp_tx_rx_transaction()
Enumerator | |
---|---|
GZP_TX_RX_SUCCESS |
ACK received. Transaction successful. |
|
static |
Function for sending an encrypted packet.
The function waits for the transmission to complete.
tx_packet | Pointer to the packet to be sent. |
length | Length of the packet to be sent. |
pipe | Pipe on which the packet should be sent. |
true | If the transmission succeeded. |
false | If the transmission failed (timed out). |
|
static |
Function sending the packet *tx_packet and a subsequent packet fetching the response to *tx_packet.
tx_packet | is a pointer to the packet to be sent. |
tx_length | is the length of the packet to be sent. |
rx_dst | is a pointer to where the received response packet should be stored. |
rx_length | is a pointer to where the length of the received packet should be stored. |
pipe | is the pipe on which the packet should be sent. |
|
static |
Function for sending an encrypted packet. The function detects whether the correct key was used, and attempts to send a "key update" to the host if the wrong key was being used.
tx_packet | is a pointer to the packet to be sent. |
length | is the length of the packet to be sent. |
true | if transmission succeeded and packet was decrypted correctly by host. |
false | if transmission failed or packet was not decrypted correctly by host. |
|
static |
Function updateing the "dynamic key" and sending a "key update" to the host.
true | if key update succeeded. |
false | if if key update failed. |
|
static |
Function for adding an element to "parameters data base" in non volatile (NV) memory. An element is GZP_PARAMS_ELEMENT_SYSTEM_ADDRESS bytes long, holding the "system address" and "host ID".
The "parameters data base" can store up to GZP_DEVICE_PAIRING_PARAMS_DB_MAX_ENTRIES elements.
src_element | is a pointer to the element. |
index | is a number between 0 and (GZP_PARAMS_DB_MAX_ENTRIES - 1) selecting the location in which the element will be stored. |
|
static |
Function for reading an element from "parameters data base" in non volatile (NV) memory. An element is GZP_PARAMS_ELEMENT_SYSTEM_ADDRESS bytes long, holding the "system address" and "host ID".
dst_element | is a pointer where the read element should be stored. |
index | is a number between 0 and (GZP_PARAMS_DB_MAX_ENTRIES - 1). selecting the location that should be read. |
|
static |
Function for writing an index to the "index data base" in non volatile (NV) memory.
index | is the index to be written to the data base. |
|
static |
Function for reading the index previously written to the "index data base" in NV memory.
|
static |
Check "index data base" is full.
true | |
false |
|
static |
Function returning true if the "index data base" is empty.
true | |
false |
|
static |
Function returning true if array contains only 1s (0xff).
*src | is a pointer to the array to be evaluated. |
length | is the length of the array to be evaluated. |
true | |
false |
|
static |
Function for storing the current "system address" and "host ID" in NV memory.
store_all | selects whether only "system address" or both "system address" and "host ID" should be stored.
|
true | |
false |
|
static |
Restore the "system address" and "host ID" from NV memory.
true | |
false |
void gzp_delay_rx_periods | ( | uint32_t | rx_periods | ) |
Delay function. Will add a delay equal to GZLL_RX_PERIOD * rx_periods [us].
rx_periods |
void gzp_tick_sleep_rx_periods | ( | uint32_t | rx_periods | ) |
Delay function. Will add a delay equal to GZLL_RX_PERIOD * rx_periods [us] using the gazell timer and not a delay loop.
rx_periods |
void gzp_init | ( | void | ) |
Initialization function. This function initializes the Gazell Pairing Library.
This function must be called before any of the other Gazell Pairing Library functions are used and must be called after gzll_init() is called.
void gzp_erase_pairing_data | ( | void | ) |
Function for erasing all pairing data.
bool gzp_address_req_send | ( | void | ) |
Function for sending a "system address" request to a Host.
When calling this function the Device will attempt acquiring the "system address" from any Host within close proximity.
If a host is located within close proximity and pairing is enabled in the Host, a "system address" will be sent in return to the Device.
The new "system address" will apply immediately in the Device, and the new "system address" will be stored in non volatile (NV) memory.
Note. Using OTP devices limits the number of times a new "system address" can be stored in NV memory.
true | if new "system address" was received from a Host. |
false | if no "system address" was received from a Host. |
gzp_id_req_res_t gzp_id_req_send | ( | void | ) |
Function for sending a "Host ID request" to a Host.
The "Host ID" is needed to be able to send encrypted data using gzp_crypt_data_send().
The request will be sent using the "system address" previously received using gzp_address_req_send().
It is not required that the Host is within close proximity in order to acquire the "Host ID".
The new "Host ID" will apply immediately for the Device, and the new "Host ID" will be stored in non volatile (NV) memory.
Note. Using OTP devices limits the number of times a new "Host ID" can be stored in NV memory.
GZP_ID_RESP_PENDING | if a "Host ID request" has been sent to the Host, but the Host application has not yet decided whether to Grant or Reject the "ID request". |
GZP_ID_RESP_GRANTED | if the "Host ID" has been received from the Host. The received "Host ID" will be stored in non volatile memory. |
GZP_ID_RESP_REJECTED | if the Host application has rejected the "Host ID request". |
GZP_ID_RESP_FAILED | if failing to send a request or receive a response from the Host. |
void gzp_id_req_cancel | ( | void | ) |
Function for cancelling an ongoing (pending) "Host ID request".
After calling this function the "Host ID request" status will go to "ID request Idle".
bool gzp_crypt_data_send | ( | const uint8_t * | src, |
uint8_t | length | ||
) |
Function for sending encrypted user data to the Host.
Before any data can be sent the Device must acquire both the Host's "system address" by using gzp_address_req_send() and the "Host ID" by using gzp_id_req_send().
*src | is a pointer to the data packet to be sent. |
length | is the length of the data packet to be sent. |
true | if the data was successfully transmitted and decrypted by the Host. |
false | if data transmission failed or Host failed to decryption data correctly. |
|
static |