Trident IoT SDK
 
Loading...
Searching...
No Matches
APP Tokens
+ Collaboration diagram for APP Tokens:

Macros

#define TR_START_APP_TOKEN_DEFS    typedef struct __attribute__((packed))
 used to start the definition of the application tokens structure
 
#define TR_END_APP_TOKEN_DEFS    tr_app_token_struct_t;
 used to end the definition of the application tokens structure
 
#define TR_CREATE_APP_TOKEN(token, type)    type token;
 used to create a token which becomes an element in the application tokens structure with the passed in type and name
 
#define tr_get_app_token_len(token)    sizeof(((tr_app_token_struct_t*)0)->token)
 gets the size of an APP token
 
#define tr_get_app_token_offset(token)    ((uint32_t)(&((tr_app_token_struct_t*)0)->token))
 gets the address offset to a specific APP token
 
#define tr_get_app_token(data, token)
 copies the token data to the location pointed to by data
 
#define tr_app_token_check_erased(token)
 checks if a specific APP token is erased
 
#define tr_set_app_token(data, data_len, token)
 write token data to a specific APP token
 

Detailed Description


The TR_START_APP_TOKEN_DEFS and TR_END_APP_TOKEN_DEFS macros create a strucutre of all application tokens with defined element names and data types.
For example:
TR_START_APP_TOKEN_DEFS
{

 TR_CREATE_APP_TOKEN(MY_APP_TOKEN, uint8_t) 

}
TR_END_APP_TOKEN_DEFS


Macro Definition Documentation

◆ tr_app_token_check_erased

#define tr_app_token_check_erased ( token)
Value:
({ \
bool is_erased = true; \
uint8_t count = 0; \
uint8_t data[200]; \
tr_get_app_token(data, token); \
for (size_t i = 0 ; i < tr_get_app_token_len(token) ; i++) { \
if (data[i] == 0xFF) { \
count++; \
} \
} \
if (count != tr_get_app_token_len(token)) { \
is_erased = false; \
} \
is_erased; \
})
#define tr_get_app_token_len(token)
gets the size of an APP token
Definition tr_app_tokens.h:51

checks if a specific APP token is erased

Parameters
tokenname of APP token (ex. MY_APP_TOKEN)
Returns
returns true if erased, false otherwise

◆ TR_CREATE_APP_TOKEN

#define TR_CREATE_APP_TOKEN ( token,
type )    type token;

used to create a token which becomes an element in the application tokens structure with the passed in type and name

Parameters
tokenname of token to be created (ex. MY_APP_TOKEN)
typedata tyoe of token being created (ex. uint8_t)

◆ TR_END_APP_TOKEN_DEFS

#define TR_END_APP_TOKEN_DEFS    tr_app_token_struct_t;

used to end the definition of the application tokens structure

◆ tr_get_app_token

#define tr_get_app_token ( data,
token )
Value:
(uint8_t)tr_get_app_token_len(token), \
(uint32_t)(TR_APP_TOKEN_BASE + tr_get_app_token_offset(token)))
#define tr_get_app_token_offset(token)
gets the address offset to a specific APP token
Definition tr_app_tokens.h:57
void tr_platform_token_read(void *buffer, uint8_t buf_size, uint32_t token_addr)

copies the token data to the location pointed to by data

Parameters
datapointer to buffer to store the token data
tokenname of APP token to read (ex. MY_APP_TOKEN)

◆ tr_get_app_token_len

#define tr_get_app_token_len ( token)     sizeof(((tr_app_token_struct_t*)0)->token)

gets the size of an APP token

Parameters
tokenname of APP token (ex. MY_APP_TOKEN)
Returns
returns the size of a specific element in the token structure

◆ tr_get_app_token_offset

#define tr_get_app_token_offset ( token)     ((uint32_t)(&((tr_app_token_struct_t*)0)->token))

gets the address offset to a specific APP token

Parameters
tokenname of APP token (ex. MY_APP_TOKEN)
Returns
returns the address of the structure element referenced to 0

◆ tr_set_app_token

#define tr_set_app_token ( data,
data_len,
token )
Value:
do { \
tr_platform_token_write((uint8_t*)data, \
(uint8_t)data_len, \
(uint32_t)((TR_APP_TOKEN_BASE + tr_get_app_token_offset(token)))); \
} while (0)

write token data to a specific APP token

Parameters
datapointer to buffer with the token data
data_lennumber of bytes to write
tokenname of APP token to write (ex. MY_APP_TOKEN)

◆ TR_START_APP_TOKEN_DEFS

#define TR_START_APP_TOKEN_DEFS    typedef struct __attribute__((packed))

used to start the definition of the application tokens structure