| {{zap_header}} |
| |
| // This file contains the tokens for nonSingletons stored in flash |
| |
| {{#endpoint_config}} |
| {{#tokens_context}} |
| |
| {{#each singletons}} |
| // Creator for attribute: {{name}}, singleton |
| #define CREATOR_{{define}}_SINGLETON {{asHex ../token_id 4}} |
| #define NVM3KEY_{{define}}_SINGLETON (NVM3KEY_DOMAIN_ZIGBEE | {{asHex ../token_id 4}}) |
| {{token_next ..}} |
| {{/each}} |
| {{#each endpoints}} |
| {{#each nonSingletons}} |
| // Creator for attribute: {{name}}, endpoint: {{../id}} |
| #define CREATOR_{{define}}_{{../id}} {{asHex ../../token_id 4}} |
| #define NVM3KEY_{{define}}_{{../id}} (NVM3KEY_DOMAIN_ZIGBEE | {{asHex ../../token_id 4}}) |
| {{token_next ../..}} |
| {{/each}} |
| {{/each}} |
| |
| // Types for the tokens |
| #ifdef DEFINETYPES |
| {{#each singletons}} |
| {{#if maxLength}} |
| typedef uint8_t tokType_{{tokenType}}[{{maxLength}}]; |
| {{else}} |
| typedef {{as_underlying_type type}} tokType_{{tokenType}}; |
| {{/if}} |
| {{/each}} |
| {{#each nonSingletons}} |
| {{#if maxLength}} |
| typedef uint8_t tokType_{{tokenType}}[{{maxLength}}]; |
| {{else}} |
| typedef {{as_underlying_type type}} tokType_{{tokenType}}; |
| {{/if}} |
| {{/each}} |
| #endif // DEFINETYPES |
| |
| |
| #ifdef DEFINETOKENS |
| {{#each singletons}} |
| {{#if longDefault}} |
| DEFINE_BASIC_TOKEN({{define}}_SINGLETON, tokType_{{tokenType}}, { {{longDefault}} }) |
| {{else}} |
| {{#if defaultValue}} |
| DEFINE_BASIC_TOKEN({{define}}_SINGLETON, tokType_{{tokenType}}, {{defaultValue}}) |
| {{else}} |
| DEFINE_BASIC_TOKEN({{define}}_SINGLETON, tokType_{{tokenType}}, 0) |
| {{/if}} |
| {{/if}} |
| {{/each}} |
| {{#each endpoints}} |
| {{#each nonSingletons}} |
| {{#if longDefault}} |
| DEFINE_BASIC_TOKEN({{define}}_{{../id}}, tokType_{{tokenType}}, { {{longDefault}} }) |
| {{else}} |
| {{#if defaultValue}} |
| DEFINE_BASIC_TOKEN({{define}}_{{../id}}, tokType_{{tokenType}}, {{defaultValue}}) |
| {{else}} |
| DEFINE_BASIC_TOKEN({{define}}_{{../id}}, tokType_{{tokenType}}, 0) |
| {{/if}} |
| {{/if}} |
| {{/each}} |
| {{/each}} |
| #endif // DEFINETOKENS |
| |
| |
| // Macro snippet that loads all the attributes from tokens |
| #define GENERATED_TOKEN_LOADER(endpoint) do {\ |
| {{#if hasAttributes}} |
| uint8_t ptr[{{maxSize}}]; \ |
| {{/if}} |
| {{#if hasNonSingletons}} |
| uint8_t curNetwork = emberGetCurrentNetwork(); \ |
| uint8_t epNetwork; \ |
| {{/if}} |
| {{#each singletons}} |
| halCommonGetToken((tokType_{{tokenType}} *)ptr, TOKEN_{{define}}_SINGLETON); \ |
| {{#if serverSide}} |
| emberAfWriteServerAttribute(1, ZCL_{{as_delimited_macro cluster.name}}_CLUSTER_ID, ZCL_{{define}}_ATTRIBUTE_ID, (uint8_t*)ptr, ZCL_{{as_delimited_macro type}}_ATTRIBUTE_TYPE); \ |
| {{/if}} |
| {{#unless serverSide}} |
| emberAfWriteClientAttribute(1, ZCL_{{as_delimited_macro cluster.name}}_CLUSTER_ID, ZCL_{{define}}_ATTRIBUTE_ID, (uint8_t*)ptr, ZCL_{{as_delimited_macro type}}_ATTRIBUTE_TYPE); \ |
| {{/unless}} |
| {{/each}} |
| {{#each endpoints}} |
| {{#if hasNonSingletons}} |
| epNetwork = emberAfNetworkIndexFromEndpoint({{id}}); \ |
| if({{id}} == (endpoint) || (EMBER_BROADCAST_ENDPOINT == (endpoint) && epNetwork == curNetwork)) { \ |
| {{#each nonSingletons}} |
| halCommonGetToken((tokType_{{tokenType}} *)ptr, TOKEN_{{define}}_{{../id}}); \ |
| {{#if serverSide}} |
| emberAfWriteServerAttribute(1, ZCL_{{as_delimited_macro cluster.name}}_CLUSTER_ID, ZCL_{{define}}_ATTRIBUTE_ID, (uint8_t*)ptr, ZCL_{{as_delimited_macro type}}_ATTRIBUTE_TYPE); \ |
| {{/if}} |
| {{#unless serverSide}} |
| emberAfWriteClientAttribute(1, ZCL_{{as_delimited_macro cluster.name}}_CLUSTER_ID, ZCL_{{define}}_ATTRIBUTE_ID, (uint8_t*)ptr, ZCL_{{as_delimited_macro type}}_ATTRIBUTE_TYPE); \ |
| {{/unless}} |
| {{/each}} |
| } \ |
| {{/if}} |
| {{/each}} |
| } while(false) |
| |
| |
| // Macro snippet that saves the attribute to token |
| #define GENERATED_TOKEN_SAVER do { \ |
| uint8_t allZeroData[{{maxSize}}]; \ |
| MEMSET(allZeroData, 0, {{maxSize}}); \ |
| if ( data == NULL ) { data = allZeroData; } \ |
| {{#each clusters}} |
| {{#if hasSingletons}} |
| if ( {{hexCode}} == clusterId ) { \ |
| {{#each singletons}} |
| if ( {{hexCode}} == metadata->attributeId && 0x0000 == emberAfGetMfgCode(metadata) && !emberAfAttributeIsClient(metadata) ) { \ |
| halCommonSetToken(TOKEN_{{define}}_SINGLETON, data); } \ |
| {{/each}} |
| } \ |
| {{/if}} |
| {{/each}} |
| {{#each endpoints}} |
| {{#if hasNonSingletons}} |
| if ( {{id}} == endpoint ) { \ |
| {{#each clusters}} |
| {{#if hasNonSingletons}} |
| if ( {{hexCode}} == clusterId ) { \ |
| {{#each nonSingletons}} |
| if ( {{hexCode}} == metadata->attributeId && 0x0000 == emberAfGetMfgCode(metadata) && {{#if serverSide}}!{{/if}}emberAfAttributeIsClient(metadata) ) \ |
| halCommonSetToken(TOKEN_{{define}}_{{../../id}}, data); \ |
| {{/each}} |
| } \ |
| {{/if}} |
| {{/each}} |
| } \ |
| {{/if}} |
| {{/each}} |
| } while(false) |
| |
| {{/tokens_context}} |
| {{/endpoint_config}} |