identify: Make init API configurable and pass in identify effect in cb

Closes https://github.com/espressif/esp-matter/issues/238
This commit is contained in:
Shubham Patil
2023-03-10 16:59:13 +05:30
parent 290d524aea
commit d7215de6d2
7 changed files with 44 additions and 17 deletions
+20 -1
View File
@@ -1,8 +1,27 @@
# 15-March-2023
 
API Change
```
esp_err_t esp_matter::identification::init(uint16_t endpoint_id, uint8_t identify_type,
uint8_t effect_identifier = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK,
uint8_t effect_variant = EMBER_ZCL_IDENTIFY_EFFECT_VARIANT_DEFAULT);
```
- Above API now accepts the parameters for initial identification `effect_identifier` and `effect_variant`.
- If not used then default value will be used for initialization
```
typedef esp_err_t (*callback_t)(callback_type_t type, uint16_t endpoint_id, uint8_t effect_id, uint8_t effect_variant,
void *priv_data);
```
- Added additional parameter `effect_variant` in identification callback.
```
esp_matter::start(event_callback_t callback, intptr_t callback_arg = static_cast<intptr_t>(NULL))
```
- This API now accepts a parameter to pass additional data to the event callback. By default, the data is set to NULL in the API.
# 14-June-2022
@@ -31,11 +31,11 @@ esp_err_t set_callback(callback_t callback)
return ESP_OK;
}
static esp_err_t execute_callback(callback_type_t type, uint16_t endpoint_id, uint8_t effect_id)
static esp_err_t execute_callback(callback_type_t type, uint16_t endpoint_id, uint8_t effect_id, uint8_t effect_variant)
{
if (identification_callback) {
void *priv_data = endpoint::get_priv_data(endpoint_id);
return identification_callback(type, endpoint_id, effect_id, priv_data);
return identification_callback(type, endpoint_id, effect_id, effect_variant, priv_data);
}
return ESP_OK;
}
@@ -43,24 +43,26 @@ static esp_err_t execute_callback(callback_type_t type, uint16_t endpoint_id, ui
static void start_cb(Identify *identify)
{
ESP_LOGI(TAG, "Start callback");
execute_callback(START, identify->mEndpoint, identify->mCurrentEffectIdentifier);
execute_callback(START, identify->mEndpoint, identify->mCurrentEffectIdentifier, identify->mEffectVariant);
}
static void stop_cb(Identify *identify)
{
ESP_LOGI(TAG, "Stop callback");
execute_callback(STOP, identify->mEndpoint, identify->mCurrentEffectIdentifier);
execute_callback(STOP, identify->mEndpoint, identify->mCurrentEffectIdentifier, identify->mEffectVariant);
}
static void effect_cb(Identify *identify)
{
ESP_LOGI(TAG, "Effect callback");
execute_callback(EFFECT, identify->mEndpoint, identify->mCurrentEffectIdentifier);
execute_callback(EFFECT, identify->mEndpoint, identify->mCurrentEffectIdentifier, identify->mEffectVariant);
}
esp_err_t init(uint16_t endpoint_id, uint8_t identify_type)
esp_err_t init(uint16_t endpoint_id, uint8_t identify_type, uint8_t effect_identifier, uint8_t effect_variant)
{
Identify *identify = new Identify(endpoint_id, start_cb, stop_cb, (EmberAfIdentifyIdentifyType)identify_type, effect_cb);
Identify *identify = new Identify(endpoint_id, start_cb, stop_cb, (EmberAfIdentifyIdentifyType)identify_type,
effect_cb, static_cast<EmberAfIdentifyEffectIdentifier>(effect_identifier),
static_cast<EmberAfIdentifyEffectVariant>(effect_variant));
if (!identify) {
ESP_LOGE(TAG, "Fail to create identify object");
return ESP_FAIL;
+8 -2
View File
@@ -34,12 +34,14 @@ typedef enum callback_type {
* @param[in] type callback type.
* @param[in] endpoint_id Endpoint ID to identify.
* @param[in] effect_id Effect ID to identify with.
* @param[in] effect_variant Effect Variant
* @param[in] priv_data Pointer to the private data passed while creating the endpoint.
*
* @return ESP_OK on success.
* @return error in case of failure.
*/
typedef esp_err_t (*callback_t)(callback_type_t type, uint16_t endpoint_id, uint8_t effect_id, void *priv_data);
typedef esp_err_t (*callback_t)(callback_type_t type, uint16_t endpoint_id, uint8_t effect_id, uint8_t effect_variant,
void *priv_data);
/** Set identification callback
*
@@ -60,11 +62,15 @@ esp_err_t set_callback(callback_t callback);
*
* @param[in] endpoint_id Endpoint ID to identify.
* @param[in] identify_type The type supported by the device.
* @param[in] effect_identifier Effect identifier, default is EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK
* @param[in] effect_variant Effect variant, default is EMBER_ZCL_IDENTIFY_EFFECT_VARIANT_DEFAULT
*
* @return ESP_OK on success.
* @return error in case of failure.
*/
esp_err_t init(uint16_t endpoint_id, uint8_t identify_type);
esp_err_t init(uint16_t endpoint_id, uint8_t identify_type,
uint8_t effect_identifier = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK,
uint8_t effect_variant = EMBER_ZCL_IDENTIFY_EFFECT_VARIANT_DEFAULT);
} /* identification */
} /* esp_matter */
+1 -1
View File
@@ -1,7 +1,7 @@
2. Developing with the SDK
==========================
Please refer the :project_file:`Release Notes <RELEASE_NOTES.txt>` to know more about
Please refer the :project_file:`Release Notes <RELEASE_NOTES.md>` to know more about
the releases
2.1 Development Setup
+2 -2
View File
@@ -62,9 +62,9 @@ static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
}
static esp_err_t app_identification_cb(identification::callback_type_t type, uint16_t endpoint_id, uint8_t effect_id,
void *priv_data)
uint8_t effect_variant, void *priv_data)
{
ESP_LOGI(TAG, "Identification callback: type: %d, effect: %d", type, effect_id);
ESP_LOGI(TAG, "Identification callback: type: %u, effect: %u, variant: %u", type, effect_id, effect_variant);
return ESP_OK;
}
+2 -2
View File
@@ -100,9 +100,9 @@ static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
}
static esp_err_t app_identification_cb(identification::callback_type_t type, uint16_t endpoint_id, uint8_t effect_id,
void *priv_data)
uint8_t effect_variant, void *priv_data)
{
ESP_LOGI(TAG, "Identification callback: type: %d, effect: %d", type, effect_id);
ESP_LOGI(TAG, "Identification callback: type: %u, effect: %u, variant: %u", type, effect_id, effect_variant);
return ESP_OK;
}
+2 -2
View File
@@ -61,9 +61,9 @@ static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
}
static esp_err_t app_identification_cb(identification::callback_type_t type, uint16_t endpoint_id, uint8_t effect_id,
void *priv_data)
uint8_t effect_variant, void *priv_data)
{
ESP_LOGI(TAG, "Identification callback: type: %d, effect: %d", type, effect_id);
ESP_LOGI(TAG, "Identification callback: type: %u, effect: %u, variant: %u", type, effect_id, effect_variant);
return ESP_OK;
}