forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Silabs ZCL8 XML implementation (project-chip#4613)
* Add Silabs ZCL8 XML implementation - Add silabs implementation of af-gen-event and af-tokens. Not yet compatible with CHIP (TODO issue project-chip#3637) * Restyled by clang-format * Restyled by prettier-json * Restyled by prettier-markdown Co-authored-by: Restyled.io <[email protected]>
- Loading branch information
Showing
42 changed files
with
25,045 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{{> header}} | ||
|
||
// #TODO : This template wasn't tested in any way with CHIP | ||
// Might need a zap submodule update and / or other fixes to make it work. | ||
// ISSUE : #3637 | ||
|
||
|
||
#pragma once | ||
|
||
#define EMBER_AF_GENERATED_UC_EVENTS_DEF \ | ||
{{#user_endpoint_types}} | ||
{{#user_clusters}} | ||
{{#if (is_enabled enabled)}} | ||
{{#template_options category="tick_events"}} | ||
{{#if (is_lowercase_equal (concatenate ../name ../side) optionLabel)~}} | ||
sl_zigbee_event_t {{optionCode}}Event{{endpoint_type_identifier ../../endpointTypeId}}; \ | ||
{{/if}} | ||
{{/template_options}} | ||
{{/if}} | ||
{{/user_clusters}} | ||
{{/user_endpoint_types}} | ||
{{#all_user_clusters}} | ||
{{#template_options category="generic_events"}} | ||
{{#if (is_lowercase_equal (concatenate ../name ../side) optionLabel)~}} | ||
sl_zigbee_event_t {{optionCode}}EndpointEvents[{{user_endpoint_count_by_cluster ../id ../side}}]; \ | ||
{{/if}} | ||
{{/template_options}} | ||
{{/all_user_clusters}} | ||
|
||
|
||
#define EMBER_AF_GENERATED_UC_EVENTS_INIT \ | ||
{{#all_user_clusters}} | ||
{{#if (is_enabled enabled)}} | ||
{{#template_options category="tick_events"}} | ||
{{#if (is_lowercase_equal (concatenate ../name ../side) optionLabel)~}} | ||
extern void {{optionCode}}(uint8_t enpoint); \ | ||
{{/if}} | ||
{{/template_options}} | ||
{{/if}} | ||
{{/all_user_clusters}} | ||
{{#user_endpoint_types}} | ||
{{#user_clusters}} | ||
{{#if (is_enabled enabled)}} | ||
{{#template_options category="tick_events"}} | ||
{{#if (is_lowercase_equal (concatenate ../name ../side) optionLabel)~}} | ||
sl_zigbee_endpoint_event_init(&{{optionCode}}Event{{endpoint_type_identifier ../../endpointTypeId}}, {{optionCode}}, {{endpoint_type_identifier ../../endpointTypeId}}); \ | ||
{{/if}} | ||
{{/template_options}} | ||
{{/if}} | ||
{{/user_clusters}} | ||
{{/user_endpoint_types}} | ||
{{#all_user_clusters}} | ||
{{#if (is_enabled enabled)}} | ||
{{#template_options category="generic_events"}} | ||
{{#if (is_lowercase_equal (concatenate ../name ../side) optionLabel)~}} | ||
extern void {{optionCode}}EndpointEventHandler(uint8_t enpoint); \ | ||
{{/if}} | ||
{{/template_options}} | ||
{{/if}} | ||
{{/all_user_clusters}} | ||
{{#user_endpoint_types}} | ||
{{#user_clusters}} | ||
{{#if (is_enabled enabled)}} | ||
{{#template_options category="generic_events"}} | ||
{{#if (is_lowercase_equal (concatenate ../name ../side) optionLabel)~}} | ||
sl_zigbee_endpoint_event_init(&{{optionCode}}EndpointEvents[{{endpoint_type_identifier ../../endpointTypeId}}], {{optionCode}}EndpointEventHandler, {{endpoint_type_identifier ../../endpointTypeId}}); \ | ||
{{/if}} | ||
{{/template_options}} | ||
{{/if}} | ||
{{/user_clusters}} | ||
{{/user_endpoint_types}} | ||
|
||
// sl_zigbee_event_context_t structs used to populate the sli_zigbee_app_event_context table | ||
#define EMBER_AF_GENERATED_UC_EVENT_CONTEXT \ | ||
{{#user_endpoint_types}} | ||
{{#user_clusters}} | ||
{{#if (is_enabled enabled)}} | ||
{{#template_options category="tick_events"}} | ||
{{#if (is_lowercase_equal (concatenate ../name ../side) optionLabel)~}} | ||
{ {{endpoint_type_identifier ../../endpointTypeId}}, {{asHex ../code}}, {{#if (is_client ../side)}}true{{else}}false{{/if}}, EMBER_AF_LONG_POLL, EMBER_AF_OK_TO_SLEEP, &{{optionCode}}Event{{endpoint_type_identifier ../../endpointTypeId}} }, \ | ||
{{/if}} | ||
{{/template_options}} | ||
{{/if}} | ||
{{/user_clusters}} | ||
{{/user_endpoint_types}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
{{> header}} | ||
|
||
// #TODO : This template wasn't tested in any way with CHIP | ||
// Might need a zap submodule update and / or other fixes to make it work. | ||
// ISSUE : #3637 | ||
|
||
|
||
#pragma once | ||
|
||
{{#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}} |
Oops, something went wrong.