123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334 |
- #ifndef TILE_TOA_MODULE_H_
- #define TILE_TOA_MODULE_H_
- #include <stdint.h>
- #include <stdbool.h>
- #define TOA_MPS 14
- #define TILE_SESSION_KEY_LEN 16
- struct toa_channel_tag
- {
- uint8_t session_key[TILE_SESSION_KEY_LEN];
- uint32_t nonceA;
- uint32_t nonceT;
- uint16_t state;
- uint16_t check_delay;
- uint16_t ack_delay;
- };
- typedef struct toa_channel_tag toa_channel_t;
- struct tile_toa_module
- {
-
- uint8_t* tile_id;
-
- uint8_t* auth_key;
-
-
- toa_channel_t* channels;
-
-
- uint8_t* queue;
-
- uint16_t queue_size;
-
- uint8_t num_channels;
-
- uint8_t* mic_failure_count;
-
-
- uint8_t* auth_failure_count;
-
-
- uint32_t* channel_open_count;
-
-
- uint32_t* authenticate_count;
-
-
- uint16_t* tka_closed_channel_count;
-
- int (*send_response)(uint8_t *data, uint16_t len);
-
- int (*associate)(uint8_t* tile_id, uint8_t* tile_auth_key, uint8_t* authorization_type);
- };
- enum TOA_FEATURE_ERROR_CODES
- {
- TOA_ERROR_OK = 0x00,
-
- TOA_ERROR_UNSUPPORTED = 0x01,
-
- TOA_ERROR_PARAMETERS = 0x02,
-
- TOA_ERROR_SECURITY = 0x03,
-
- TOA_ERROR_INVALID_STATE = 0x04,
-
- TOA_ERROR_MEM_READ = 0x05,
-
- TOA_ERROR_MEM_WRITE = 0x06,
-
- TOA_ERROR_DATA_LENGTH = 0x07,
-
- TOA_ERROR_INVALID_SIZE = 0x08,
-
- TOA_ERROR_SIGNATURE = 0x09,
-
- TOA_ERROR_CRC = 0x0A,
-
- TOA_ERROR_CRC2 = 0x0B,
-
- TOA_ERROR_HASH = 0x0C,
-
- TOA_ERROR_PRODUCT_HEADER = 0x0D,
-
- TOA_ERROR_IMAGE_HEADER = 0x0E,
-
- TOA_ERROR_SAME_IMAGE = 0x0F,
-
- TOA_ERROR_INVALID_DATA = 0x10,
-
- TOA_ERROR_MEM_ERASE = 0x11,
-
- TOA_ERROR_RESOURCE_IN_USE = 0x12,
-
- };
- enum TOA_ERROR_CODES
- {
- TOA_RSP_ERROR_SECURITY = 0x01,
-
- TOA_RSP_ERROR_UNSUPPORTED = 0x02,
-
- TOA_RSP_ERROR_PARAMETERS = 0x03,
-
- TOA_RSP_ERROR_DROPPED_RSP = 0x04,
-
- TOA_RSP_ERROR_NO_CID_AVAILABLE = 0x05,
-
-
- TOA_RSP_ERROR_AUTHORIZATION = 0x06,
-
- TOA_RSP_SERVICE_UNAVAILABLE = 0x07,
-
- };
- int tile_toa_register(struct tile_toa_module *module);
- void tile_toa_transport_ready(bool ready);
- void tile_toa_response_sent_ok(void);
- void tile_toa_command_received(const uint8_t* data, uint8_t datalen);
- int tile_toa_authorized(uint8_t authorization_type, uint16_t authorization_time);
- #endif
|