diff --git a/ezlopi-cloud/ezlopi-cloud-scenes/ezlopi_cloud_scenes_block_list.c b/ezlopi-cloud/ezlopi-cloud-scenes/ezlopi_cloud_scenes_block_list.c index 41ec5ebf1..e8f95d543 100644 --- a/ezlopi-cloud/ezlopi-cloud-scenes/ezlopi_cloud_scenes_block_list.c +++ b/ezlopi-cloud/ezlopi-cloud-scenes/ezlopi_cloud_scenes_block_list.c @@ -148,8 +148,8 @@ static bool __found_item_in_field(l_fields_v2_t* field_node, uint32_t item_id) uint32_t item_id_check = strtoul(field_node->field_value.u_value.value_string, NULL, 16); TRACE_D("item-id: %s | %08x", field_node->field_value.u_value.value_string, item_id); - // uint32_t item_id_check = strtoul(field_node->value.value_string, NULL, 16); - // TRACE_D("item-id: %s | %08x", field_node->value.value_string, item_id); + // uint32_t item_id_check = strtoul(field_node->field_value.u_value.value_string, NULL, 16); + // TRACE_D("item-id: %s | %08x", field_node->field_value.u_value.value_string, item_id); if (item_id_check == item_id) { diff --git a/ezlopi-core/ezlopi-core-ble/ezlopi_core_ble_config.h b/ezlopi-core/ezlopi-core-ble/ezlopi_core_ble_config.h index eae7c0a65..e12a8e40b 100644 --- a/ezlopi-core/ezlopi-core-ble/ezlopi_core_ble_config.h +++ b/ezlopi-core/ezlopi-core-ble/ezlopi_core_ble_config.h @@ -11,7 +11,7 @@ typedef enum e_gatt_status GATT_STATUS_MAX } e_gatt_status_t; -typedef void (*f_upcall_t)(esp_gatt_value_t *value, esp_ble_gatts_cb_param_t *param); +typedef void (*f_upcall_t)(esp_gatt_value_t* value, esp_ble_gatts_cb_param_t* param); typedef struct s_gatt_descr { @@ -23,8 +23,8 @@ typedef struct s_gatt_descr f_upcall_t write_upcall; f_upcall_t write_exce_upcall; esp_gatt_perm_t permission; - esp_attr_control_t *control; - struct s_gatt_descr *next; + esp_attr_control_t* control; + struct s_gatt_descr* next; } s_gatt_descr_t; typedef struct s_gatt_char @@ -39,8 +39,8 @@ typedef struct s_gatt_char f_upcall_t write_upcall; f_upcall_t write_exce_upcall; esp_attr_control_t control; - s_gatt_descr_t *descriptor; - struct s_gatt_char *next; + s_gatt_descr_t* descriptor; + struct s_gatt_char* next; } s_gatt_char_t; typedef struct s_gatt_service @@ -52,8 +52,8 @@ typedef struct s_gatt_service e_gatt_status_t status; uint16_t service_handle; esp_gatt_srvc_id_t service_id; - struct s_gatt_char *characteristics; - struct s_gatt_service *next; + struct s_gatt_char* characteristics; + struct s_gatt_service* next; } s_gatt_service_t; #endif // _EZLOPI_CORE_BLE_CONFIG_H_ \ No newline at end of file diff --git a/ezlopi-core/ezlopi-core-devices/CMakeLists.txt b/ezlopi-core/ezlopi-core-devices/CMakeLists.txt index 8c7f84512..0ee72492c 100644 --- a/ezlopi-core/ezlopi-core-devices/CMakeLists.txt +++ b/ezlopi-core/ezlopi-core-devices/CMakeLists.txt @@ -35,56 +35,56 @@ set(EZLOPI_SENSOR_DEVICE_COMPONENTS sensor-0017-ADC-potentiometer sensor-0018-other-internal-hall-effect - sensor-0019-digitalIn-PIR - sensor-0020-other-2axis-joystick - sensor-0021-UART-MB1013 - device-0022-PWM-dimmable-lamp - sensor-0023-digitalIn-touch-switch-TTP223B - sensor-0024-other-HCSR04 - sensor-0025-digitalIn-LDR - sensor-0026-ADC-LDR + # sensor-0019-digitalIn-PIR + # sensor-0020-other-2axis-joystick + # sensor-0021-UART-MB1013 + # device-0022-PWM-dimmable-lamp + # sensor-0023-digitalIn-touch-switch-TTP223B + # sensor-0024-other-HCSR04 + # sensor-0025-digitalIn-LDR + # sensor-0026-ADC-LDR sensor-0027-ADC-waterLeak - sensor-0028-other-GY61 - sensor-0029-I2C-GXHTC3 - sensor-0030-oneWire-DS18B20 - sensor-0031-other-JSNSR04T + # sensor-0028-other-GY61 + # sensor-0029-I2C-GXHTC3 + # sensor-0030-oneWire-DS18B20 + # sensor-0031-other-JSNSR04T sensor-0032-ADC-soilMoisture - sensor-0033-ADC-turbidity - sensor-0034-digitalIn-proximity - sensor-0035-digitalIn-touch-sensor-TPP223B - device-0036-PWM-servo-MG996R - sensor-0037-pms5003-sensor - device-0038-other-RGB + # sensor-0033-ADC-turbidity + # sensor-0034-digitalIn-proximity + # sensor-0035-digitalIn-touch-sensor-TPP223B + # device-0036-PWM-servo-MG996R + # sensor-0037-pms5003-sensor + # device-0038-other-RGB - sensor-0040-other-TCS230 - sensor-0041-ADC-FC28-soilMoisture - sensor-0042-ADC-shunt-voltmeter - sensor-0043-ADC-GYML8511-UV-intensity - sensor-0044-I2C-TSL256-luminosity - sensor-0046-ADC-ACS712-05B-currentmeter + # sensor-0040-other-TCS230 + # sensor-0041-ADC-FC28-soilMoisture + # sensor-0042-ADC-shunt-voltmeter + # sensor-0043-ADC-GYML8511-UV-intensity + # sensor-0044-I2C-TSL256-luminosity + # sensor-0046-ADC-ACS712-05B-currentmeter - sensor-0047-other-HX711-loadcell - sensor-0048-other-MQ4-CH4-detector - sensor-0049-other-MQ2-LPG-detector - sensor-0050-other-MQ3-alcohol-detector - sensor-0051-other-MQ8-H2-detector - sensor-0052-other-MQ135-NH3-detector - sensor-0053-UART-GYGPS6MV2 - sensor-0054-PWM-YFS201-flowmeter + # sensor-0047-other-HX711-loadcell + # sensor-0048-other-MQ4-CH4-detector + # sensor-0049-other-MQ2-LPG-detector + # sensor-0050-other-MQ3-alcohol-detector + # sensor-0051-other-MQ8-H2-detector + # sensor-0052-other-MQ135-NH3-detector + # sensor-0053-UART-GYGPS6MV2 + # sensor-0054-PWM-YFS201-flowmeter sensor-0055-ADC-FlexResistor - sensor-0056-ADC-Force-Sensitive-Resistor - sensor-0057-other-KY026-FlameDetector - sensor-0059-other-MQ6-LPG-detector - sensor-0060-digitalIn-vibration-detector - sensor-0061-digitalIn-reed-switch - sensor-0062-other-MQ7-CO-detector - sensor-0063-other-MQ9-LPG-flameable-detector - sensor-0065-digitalIn-float-switch - sensor-0066-other-R307-FingerPrint - sensor-0067-UART-hilink-presence-sensor - sensor-0068-I2C-ENS160-gas-sensor - sensor-0069-UART-ze08-ch02-gas-sensor + # sensor-0056-ADC-Force-Sensitive-Resistor + # sensor-0057-other-KY026-FlameDetector + # sensor-0059-other-MQ6-LPG-detector + # sensor-0060-digitalIn-vibration-detector + # sensor-0061-digitalIn-reed-switch + # sensor-0062-other-MQ7-CO-detector + # sensor-0063-other-MQ9-LPG-flameable-detector + # sensor-0065-digitalIn-float-switch + # sensor-0066-other-R307-FingerPrint + # sensor-0067-UART-hilink-presence-sensor + # sensor-0068-I2C-ENS160-gas-sensor + # sensor-0069-UART-ze08-ch02-gas-sensor ) diff --git a/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices.c b/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices.c index a6fa8f501..405cd797f 100644 --- a/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices.c +++ b/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices.c @@ -14,6 +14,10 @@ static void ezlopi_device_parse_json_v3(cJSON* cj_config); static void ezlopi_device_free_single(l_ezlopi_device_t* device); static void ezlopi_device_print_controller_cloud_information_v3(void); +static void ezlopi_device_free_item(l_ezlopi_item_t* items); +static void ezlopi_device_free_setting(l_ezlopi_device_settings_v3_t* settings); +static void ezlopi_device_free_all_device_setting(l_ezlopi_device_t* curr_device); + void ezlopi_device_name_set_by_device_id(uint32_t a_device_id, cJSON* cj_new_name) { if (a_device_id && cj_new_name && cj_new_name->valuestring) @@ -577,15 +581,15 @@ static void ezlopi_device_free_item(l_ezlopi_item_t* items) free(items); } -// static void ezlopi_device_free_setting(l_ezlopi_device_settings_v3 *settings) -// { -// if (settings->next) -// { -// ezlopi_device_free_setting(settings->next);//recursive -// } -// -// free(settings); -// } +static void ezlopi_device_free_setting(l_ezlopi_device_settings_v3_t* settings) +{ + if (settings->next) + { + ezlopi_device_free_setting(settings->next); + } + + free(settings); +} static void ezlopi_device_free_single(l_ezlopi_device_t* device) { @@ -595,9 +599,44 @@ static void ezlopi_device_free_single(l_ezlopi_device_t* device) device->items = NULL; } + // if (device->settings) + // { + // ezlopi_device_free_setting(device->settings); + // device->settings = NULL; + // } + // if (device->cloud_properties.device_type_id) + // { + // free(device->cloud_properties.device_type_id); + // } + if (NULL != device->cloud_properties.info) + { + cJSON_Delete(device->cloud_properties.info); + device->cloud_properties.info = NULL; + } + free(device); } +static void ezlopi_device_free_all_device_setting(l_ezlopi_device_t* curr_device) +{ + if (curr_device) + { + ezlopi_device_free_all_device_setting(curr_device->next); + ezlopi_device_free_setting(curr_device->settings); // unlink settings from devices, items, rooms, etc. + } +} + +void ezlopi_device_factory_info_reset(void) +{ + // clear all 'devices', along with their 'items & settings' + l_ezlopi_device_t* curr_device = l_device_head; + if (curr_device) + { + ezlopi_device_free_all_device_setting(curr_device); + } +} + + l_ezlopi_device_settings_v3_t* ezlopi_device_add_settings_to_device_v3(l_ezlopi_device_t* device, int (*setting_func)(e_ezlopi_settings_action_t action, struct l_ezlopi_device_settings_v3* setting, void* arg, void* user_arg)) { l_ezlopi_device_settings_v3_t* new_setting = NULL; diff --git a/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices.h b/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices.h index 7e66e1806..b36c754af 100644 --- a/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices.h +++ b/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices.h @@ -141,49 +141,50 @@ typedef struct l_ezlopi_item s_ezlopi_adc_t adc; } interface; - void *user_arg; - int (*func)(e_ezlopi_actions_t action, struct l_ezlopi_item *item, void *arg, void *user_arg); + void* user_arg; + int (*func)(e_ezlopi_actions_t action, struct l_ezlopi_item* item, void* arg, void* user_arg); - struct l_ezlopi_item *next; + struct l_ezlopi_item* next; } l_ezlopi_item_t; typedef struct l_ezlopi_device_settings_v3 { - void *user_arg; + void* user_arg; s_ezlopi_cloud_device_settings_t cloud_properties; - int (*func)(e_ezlopi_settings_action_t action, struct l_ezlopi_device_settings_v3 *setting, void *arg, void *user_arg); - struct l_ezlopi_device_settings_v3 *next; + int (*func)(e_ezlopi_settings_action_t action, struct l_ezlopi_device_settings_v3* setting, void* arg, void* user_arg); + struct l_ezlopi_device_settings_v3* next; } l_ezlopi_device_settings_v3_t; typedef struct l_ezlopi_device { - l_ezlopi_item_t *items; - l_ezlopi_device_settings_v3_t *settings; + l_ezlopi_item_t* items; + l_ezlopi_device_settings_v3_t* settings; s_ezlopi_cloud_device_t cloud_properties; - struct l_ezlopi_device *next; + struct l_ezlopi_device* next; } l_ezlopi_device_t; void ezlopi_device_prepare(void); -l_ezlopi_device_t *ezlopi_device_get_head(void); -l_ezlopi_device_t *ezlopi_device_add_device(cJSON *cj_device); +l_ezlopi_device_t* ezlopi_device_get_head(void); +l_ezlopi_device_t* ezlopi_device_add_device(cJSON* cj_device); -l_ezlopi_device_t *ezlopi_device_get_by_id(uint32_t device_id); -l_ezlopi_item_t *ezlopi_device_get_item_by_id(uint32_t item_id); -l_ezlopi_device_settings_v3_t *ezlopi_device_settings_get_by_id(uint32_t settings_id); +l_ezlopi_device_t* ezlopi_device_get_by_id(uint32_t device_id); +l_ezlopi_item_t* ezlopi_device_get_item_by_id(uint32_t item_id); +l_ezlopi_device_settings_v3_t* ezlopi_device_settings_get_by_id(uint32_t settings_id); // l_ezlopi_item_t *ezlopi_device_add_item_to_device(l_ezlopi_device_t *device); -l_ezlopi_item_t *ezlopi_device_add_item_to_device(l_ezlopi_device_t *device, - int (*item_func)(e_ezlopi_actions_t action, struct l_ezlopi_item *item, void *arg, void *user_arg)); - -l_ezlopi_device_settings_v3_t *ezlopi_device_add_settings_to_device_v3(l_ezlopi_device_t *device, - int (*setting_func)(e_ezlopi_settings_action_t action, struct l_ezlopi_device_settings_v3 *setting, void *arg, void *user_arg)); - -void ezlopi_device_free_device(l_ezlopi_device_t *device); -void ezlopi_device_free_device_by_item(l_ezlopi_item_t *item); -cJSON *ezlopi_device_create_device_table_from_prop(l_ezlopi_device_t *device_prop); -s_ezlopi_cloud_controller_t *ezlopi_device_get_controller_information(void); -void ezlopi_device_name_set_by_device_id(uint32_t device_id, cJSON *cj_new_name); +l_ezlopi_item_t* ezlopi_device_add_item_to_device(l_ezlopi_device_t* device, + int (*item_func)(e_ezlopi_actions_t action, struct l_ezlopi_item* item, void* arg, void* user_arg)); + +l_ezlopi_device_settings_v3_t* ezlopi_device_add_settings_to_device_v3(l_ezlopi_device_t* device, + int (*setting_func)(e_ezlopi_settings_action_t action, struct l_ezlopi_device_settings_v3* setting, void* arg, void* user_arg)); + +void ezlopi_device_free_device(l_ezlopi_device_t* device); +void ezlopi_device_free_device_by_item(l_ezlopi_item_t* item); +void ezlopi_device_factory_info_reset(void); +cJSON* ezlopi_device_create_device_table_from_prop(l_ezlopi_device_t* device_prop); +s_ezlopi_cloud_controller_t* ezlopi_device_get_controller_information(void); +void ezlopi_device_name_set_by_device_id(uint32_t device_id, cJSON* cj_new_name); #endif // EZLOPI_CORE_DEVICES_H diff --git a/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices_list_includes.h b/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices_list_includes.h index cc5a778b3..c618592c5 100644 --- a/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices_list_includes.h +++ b/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices_list_includes.h @@ -21,54 +21,54 @@ #include "sensor_0018_other_internal_hall_effect.h" #endif // CONFIG_IDF_TARGET_ESP32 -#include "sensor_0019_digitalIn_PIR.h" -#include "sensor_0020_other_2axis_joystick.h" -#include "sensor_0021_UART_MB1013.h" -#include "device_0022_PWM_dimmable_lamp.h" -#include "sensor_0023_digitalIn_touch_switch_TTP223B.h" -#include "sensor_0024_other_HCSR04.h" -#include "sensor_0025_digitalIn_LDR.h" -#include "sensor_0026_ADC_LDR.h" +// #include "sensor_0019_digitalIn_PIR.h" +// #include "sensor_0020_other_2axis_joystick.h" +// #include "sensor_0021_UART_MB1013.h" +// #include "device_0022_PWM_dimmable_lamp.h" +// #include "sensor_0023_digitalIn_touch_switch_TTP223B.h" +// #include "sensor_0024_other_HCSR04.h" +// #include "sensor_0025_digitalIn_LDR.h" +// #include "sensor_0026_ADC_LDR.h" #include "sensor_0027_ADC_waterLeak.h" -#include "sensor_0028_other_GY61.h" -#include "sensor_0029_I2C_GXHTC3.h" -#include "sensor_0030_oneWire_DS18B20.h" -#include "sensor_0031_other_JSNSR04T.h" +// #include "sensor_0028_other_GY61.h" +// #include "sensor_0029_I2C_GXHTC3.h" +// #include "sensor_0030_oneWire_DS18B20.h" +// #include "sensor_0031_other_JSNSR04T.h" #include "sensor_0032_ADC_soilMoisture.h" -#include "sensor_0033_ADC_turbidity.h" -#include "sensor_0034_digitalIn_proximity.h" -#include "sensor_0035_digitalIn_touch_sensor_TPP223B.h" -#include "device_0036_PWM_servo_MG996R.h" -#include "sensor_0037_pms5003_sensor.h" -#include "device_0038_other_RGB.h" +// #include "sensor_0033_ADC_turbidity.h" +// #include "sensor_0034_digitalIn_proximity.h" +// #include "sensor_0035_digitalIn_touch_sensor_TPP223B.h" +// #include "device_0036_PWM_servo_MG996R.h" +// #include "sensor_0037_pms5003_sensor.h" +// #include "device_0038_other_RGB.h" -#include "sensor_0040_other_TCS230.h" -#include "sensor_0041_ADC_FC28_soilMoisture.h" -#include "sensor_0042_ADC_shunt_voltmeter.h" -#include "sensor_0043_ADC_GYML8511_UV_intensity.h" -#include "sensor_0044_I2C_TSL256_luminosity.h" -#include "sensor_0046_ADC_ACS712_05B_currentmeter.h" -#include "sensor_0047_other_HX711_loadcell.h" -#include "sensor_0048_other_MQ4_CH4_detector.h" -#include "sensor_0049_other_MQ2_LPG_detector.h" -#include "sensor_0050_other_MQ3_alcohol_detector.h" -#include "sensor_0051_other_MQ8_H2_detector.h" -#include "sensor_0052_other_MQ135_NH3_detector.h" -#include "sensor_0053_UART_GYGPS6MV2.h" -#include "sensor_0054_PWM_YFS201_flowmeter.h" +// #include "sensor_0040_other_TCS230.h" +// #include "sensor_0041_ADC_FC28_soilMoisture.h" +// #include "sensor_0042_ADC_shunt_voltmeter.h" +// #include "sensor_0043_ADC_GYML8511_UV_intensity.h" +// #include "sensor_0044_I2C_TSL256_luminosity.h" +// #include "sensor_0046_ADC_ACS712_05B_currentmeter.h" +// #include "sensor_0047_other_HX711_loadcell.h" +// #include "sensor_0048_other_MQ4_CH4_detector.h" +// #include "sensor_0049_other_MQ2_LPG_detector.h" +// #include "sensor_0050_other_MQ3_alcohol_detector.h" +// #include "sensor_0051_other_MQ8_H2_detector.h" +// #include "sensor_0052_other_MQ135_NH3_detector.h" +// #include "sensor_0053_UART_GYGPS6MV2.h" +// #include "sensor_0054_PWM_YFS201_flowmeter.h" #include "sensor_0055_ADC_FlexResistor.h" -#include "sensor_0056_ADC_Force_Sensitive_Resistor.h" -#include "sensor_0057_other_KY026_FlameDetector.h" +// #include "sensor_0056_ADC_Force_Sensitive_Resistor.h" +// #include "sensor_0057_other_KY026_FlameDetector.h" -#include "sensor_0059_other_MQ6_LPG_detector.h" -#include "sensor_0060_digitalIn_vibration_detector.h" -#include "sensor_0061_digitalIn_reed_switch.h" -#include "sensor_0062_other_MQ7_CO_detector.h" -#include "sensor_0063_other_MQ9_LPG_flameable_detector.h" -#include "sensor_0065_digitalIn_float_switch.h" -#include "sensor_0066_other_R307_FingerPrint.h" -#include "sensor_0067_hilink_presence_sensor.h" -#include "sensor_0068_ENS160_gas_sensor.h" -#include "sensor_0069_ze08_ch02_gas_sensor.h" +// #include "sensor_0059_other_MQ6_LPG_detector.h" +// #include "sensor_0060_digitalIn_vibration_detector.h" +// #include "sensor_0061_digitalIn_reed_switch.h" +// #include "sensor_0062_other_MQ7_CO_detector.h" +// #include "sensor_0063_other_MQ9_LPG_flameable_detector.h" +// #include "sensor_0065_digitalIn_float_switch.h" +// #include "sensor_0066_other_R307_FingerPrint.h" +// #include "sensor_0067_hilink_presence_sensor.h" +// #include "sensor_0068_ENS160_gas_sensor.h" +// #include "sensor_0069_ze08_ch02_gas_sensor.h" #endif // _EZLOPI_CORE_DEVICES_LIST_INCLUDES_H_ diff --git a/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices_list_modules.h b/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices_list_modules.h index d3ac47eb0..b3c4f2f09 100644 --- a/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices_list_modules.h +++ b/ezlopi-core/ezlopi-core-devices/ezlopi_core_devices_list_modules.h @@ -29,63 +29,63 @@ EZLOPI_DEVICE_LIST("sensor-potentiometer-ADC ", 17, sensor_0017_ADC_p EZLOPI_DEVICE_LIST("sensor-Hall-effect ", 18, sensor_0018_other_internal_hall_effect) #endif // CONFIG_IDF_TARGET_ESP32 -EZLOPI_DEVICE_LIST("sensor-PIR-digital-proximity ", 19, sensor_0019_digitalIn_PIR) -EZLOPI_DEVICE_LIST("sensor-2AXIS-JOYSTICK ", 20, sensor_0020_other_2axis_joystick) -EZLOPI_DEVICE_LIST("sensor-UART-MB1013 ", 21, sensor_0021_UART_MB1013) - -EZLOPI_DEVICE_LIST("device-PWM-dimmable-lamp ", 22, device_0022_PWM_dimmable_lamp) -EZLOPI_DEVICE_LIST("sensor-TTP223B-digital-touch ", 23, sensor_0023_digitalIn_touch_switch_TTP223B) -EZLOPI_DEVICE_LIST("sensor-HCSR04-pulse-width ", 24, sensor_0024_other_HCSR04_v3) -EZLOPI_DEVICE_LIST("sensor-LDR-digital-in ", 25, sensor_0025_digitalIn_LDR) -EZLOPI_DEVICE_LIST("sensor-LDR-ADC ", 26, sensor_0026_ADC_LDR) +// EZLOPI_DEVICE_LIST("sensor-PIR-digital-proximity ", 19, sensor_0019_digitalIn_PIR) +// EZLOPI_DEVICE_LIST("sensor-2AXIS-JOYSTICK ", 20, sensor_0020_other_2axis_joystick) +// EZLOPI_DEVICE_LIST("sensor-UART-MB1013 ", 21, sensor_0021_UART_MB1013) + +// EZLOPI_DEVICE_LIST("device-PWM-dimmable-lamp ", 22, device_0022_PWM_dimmable_lamp) +// EZLOPI_DEVICE_LIST("sensor-TTP223B-digital-touch ", 23, sensor_0023_digitalIn_touch_switch_TTP223B) +// EZLOPI_DEVICE_LIST("sensor-HCSR04-pulse-width ", 24, sensor_0024_other_HCSR04_v3) +// EZLOPI_DEVICE_LIST("sensor-LDR-digital-in ", 25, sensor_0025_digitalIn_LDR) +// EZLOPI_DEVICE_LIST("sensor-LDR-ADC ", 26, sensor_0026_ADC_LDR) EZLOPI_DEVICE_LIST("sensor-WATERLEAK-ADC ", 27, sensor_0027_ADC_waterLeak) -EZLOPI_DEVICE_LIST("sensor-GY61-other-accelerometer ", 28, sensor_0028_other_GY61) +// EZLOPI_DEVICE_LIST("sensor-GY61-other-accelerometer ", 28, sensor_0028_other_GY61) -EZLOPI_DEVICE_LIST("sensor-GXHTC3-I2C-temp-humidity ", 29, sensor_0029_I2C_GXHTC3) -EZLOPI_DEVICE_LIST("sensor-DS18B20-1-wire-temp ", 30, sensor_0030_oneWire_DS18B20) -EZLOPI_DEVICE_LIST("sensor-JNSR04T-digital-distance ", 31, sensor_0031_other_JSNSR04T) +// EZLOPI_DEVICE_LIST("sensor-GXHTC3-I2C-temp-humidity ", 29, sensor_0029_I2C_GXHTC3) +// EZLOPI_DEVICE_LIST("sensor-DS18B20-1-wire-temp ", 30, sensor_0030_oneWire_DS18B20) +// EZLOPI_DEVICE_LIST("sensor-JNSR04T-digital-distance ", 31, sensor_0031_other_JSNSR04T) EZLOPI_DEVICE_LIST("sensor-soilMoisture-ADC ", 32, sensor_0032_ADC_soilMoisture) -EZLOPI_DEVICE_LIST("sensor-turbidity-ADC ", 33, sensor_0033_ADC_turbidity) -EZLOPI_DEVICE_LIST("sensor-proximity-digital ", 34, sensor_0034_digitalIn_proximity) -EZLOPI_DEVICE_LIST("sensor-TPP223B-digital-touch ", 35, sensor_0035_digitalIn_touch_sensor_TPP223B) -EZLOPI_DEVICE_LIST("sensor-PMS5003 ", 37, sensor_pms5003_v3) -EZLOPI_DEVICE_LIST("device-other-RGB-LED ", 38, device_0038_other_RGB) - -EZLOPI_DEVICE_LIST("device-PWM-servo-MG996R ", 36, device_0036_PWM_servo_MG996R) - -EZLOPI_DEVICE_LIST("sensor-TCS230-other-color ", 40, sensor_0040_other_TCS230) -EZLOPI_DEVICE_LIST("sensor-FC28-soilMoisture-ADC ", 41, sensor_0041_ADC_FC28_soilMoisture) -EZLOPI_DEVICE_LIST("sensor-shunt-voltmeter-ADC ", 42, sensor_0042_ADC_shunt_voltmeter) -EZLOPI_DEVICE_LIST("sensor-GYML8511-ADC-intensity ", 43, sensor_0043_ADC_GYML8511_UV_intensity) -EZLOPI_DEVICE_LIST("sensor-TSL256-I2C-luminosity ", 44, sensor_0044_I2C_TSL256_luminosity) - -EZLOPI_DEVICE_LIST("sensor-ACS712-currentmeter-ADC ", 46, sensor_0046_ADC_ACS712_05B_currentmeter) - -EZLOPI_DEVICE_LIST("sensor-HX711-loadcell ", 47, sensor_0047_other_HX711_loadcell) - -EZLOPI_DEVICE_LIST("sensor-MQ4-CH4-methane ", 48, sensor_0048_other_MQ4_CH4_detector) -EZLOPI_DEVICE_LIST("sensor-MQ2-LPG-detector ", 49, sensor_0049_other_MQ2_LPG_detector) -EZLOPI_DEVICE_LIST("sensor-MQ3-alcohol-detector ", 50, sensor_0050_other_MQ3_alcohol_detector) -EZLOPI_DEVICE_LIST("sensor-MQ8-H2-detector ", 51, sensor_0051_other_MQ8_H2_detector) -EZLOPI_DEVICE_LIST("sensor-MQ135-NH3-detector ", 52, sensor_0052_other_MQ135_NH3_detector) -EZLOPI_DEVICE_LIST("sensor-GYGPS6MV2-UART-gps ", 53, sensor_0053_UART_GYGPS6MV2) -EZLOPI_DEVICE_LIST("sensor-YFS201-PWM-flowmeter ", 54, sensor_0054_PWM_YFS201_flowmeter) +// EZLOPI_DEVICE_LIST("sensor-turbidity-ADC ", 33, sensor_0033_ADC_turbidity) +// EZLOPI_DEVICE_LIST("sensor-proximity-digital ", 34, sensor_0034_digitalIn_proximity) +// EZLOPI_DEVICE_LIST("sensor-TPP223B-digital-touch ", 35, sensor_0035_digitalIn_touch_sensor_TPP223B) +// EZLOPI_DEVICE_LIST("sensor-PMS5003 ", 37, sensor_pms5003_v3) +// EZLOPI_DEVICE_LIST("device-other-RGB-LED ", 38, device_0038_other_RGB) + +// EZLOPI_DEVICE_LIST("device-PWM-servo-MG996R ", 36, device_0036_PWM_servo_MG996R) + +// EZLOPI_DEVICE_LIST("sensor-TCS230-other-color ", 40, sensor_0040_other_TCS230) +// EZLOPI_DEVICE_LIST("sensor-FC28-soilMoisture-ADC ", 41, sensor_0041_ADC_FC28_soilMoisture) +// EZLOPI_DEVICE_LIST("sensor-shunt-voltmeter-ADC ", 42, sensor_0042_ADC_shunt_voltmeter) +// EZLOPI_DEVICE_LIST("sensor-GYML8511-ADC-intensity ", 43, sensor_0043_ADC_GYML8511_UV_intensity) +// EZLOPI_DEVICE_LIST("sensor-TSL256-I2C-luminosity ", 44, sensor_0044_I2C_TSL256_luminosity) + +// EZLOPI_DEVICE_LIST("sensor-ACS712-currentmeter-ADC ", 46, sensor_0046_ADC_ACS712_05B_currentmeter) + +// EZLOPI_DEVICE_LIST("sensor-HX711-loadcell ", 47, sensor_0047_other_HX711_loadcell) + +// EZLOPI_DEVICE_LIST("sensor-MQ4-CH4-methane ", 48, sensor_0048_other_MQ4_CH4_detector) +// EZLOPI_DEVICE_LIST("sensor-MQ2-LPG-detector ", 49, sensor_0049_other_MQ2_LPG_detector) +// EZLOPI_DEVICE_LIST("sensor-MQ3-alcohol-detector ", 50, sensor_0050_other_MQ3_alcohol_detector) +// EZLOPI_DEVICE_LIST("sensor-MQ8-H2-detector ", 51, sensor_0051_other_MQ8_H2_detector) +// EZLOPI_DEVICE_LIST("sensor-MQ135-NH3-detector ", 52, sensor_0052_other_MQ135_NH3_detector) +// EZLOPI_DEVICE_LIST("sensor-GYGPS6MV2-UART-gps ", 53, sensor_0053_UART_GYGPS6MV2) +// EZLOPI_DEVICE_LIST("sensor-YFS201-PWM-flowmeter ", 54, sensor_0054_PWM_YFS201_flowmeter) EZLOPI_DEVICE_LIST("sensor-Flex-Resistor-ADC ", 55, sensor_0055_ADC_FlexResistor) -EZLOPI_DEVICE_LIST("sensor-Force-sensetive-resistor-ADC ", 56, sensor_0056_ADC_Force_Sensitive_Resistor) -EZLOPI_DEVICE_LIST("sensor-KY026-Flame-detector ", 57, sensor_0057_other_KY026_FlameDetector) - -EZLOPI_DEVICE_LIST("sensor-MQ6-LPG-detector ", 59, sensor_0059_other_MQ6_LPG_detector) -EZLOPI_DEVICE_LIST("sensor-vibration-detector-Digital ", 60, sensor_0060_digitalIn_vibration_detector) -EZLOPI_DEVICE_LIST("sensor-reed-switch-digital ", 61, sensor_0061_digitalIn_reed_switch) -EZLOPI_DEVICE_LIST("sensor-MQ7-CO-detector ", 62, sensor_0062_other_MQ7_CO_detector) -EZLOPI_DEVICE_LIST("sensor-MQ9-LPG-flameable-detector ", 63, sensor_0063_other_MQ9_LPG_flameable_detector) - -EZLOPI_DEVICE_LIST("sensor-float-switch-digital ", 65, sensor_0065_digitalIn_float_switch) -EZLOPI_DEVICE_LIST("sensor-fingerprint-sensor ", 66, sensor_0066_other_R307_FingerPrint) -EZLOPI_DEVICE_LIST("sensor-hilink-presence-sensor ", 67, sensor_0067_hilink_presence_sensor_v3) -EZLOPI_DEVICE_LIST("sensor-ENS160-gas-sensor ", 68, sensor_0068_ENS160_gas_sensor) -EZLOPI_DEVICE_LIST("sensor-ze08-ch02-gas-sensor ", 69, sensor_0069_ze08_ch02_gas_sensor) +// EZLOPI_DEVICE_LIST("sensor-Force-sensetive-resistor-ADC ", 56, sensor_0056_ADC_Force_Sensitive_Resistor) +// EZLOPI_DEVICE_LIST("sensor-KY026-Flame-detector ", 57, sensor_0057_other_KY026_FlameDetector) + +// EZLOPI_DEVICE_LIST("sensor-MQ6-LPG-detector ", 59, sensor_0059_other_MQ6_LPG_detector) +// EZLOPI_DEVICE_LIST("sensor-vibration-detector-Digital ", 60, sensor_0060_digitalIn_vibration_detector) +// EZLOPI_DEVICE_LIST("sensor-reed-switch-digital ", 61, sensor_0061_digitalIn_reed_switch) +// EZLOPI_DEVICE_LIST("sensor-MQ7-CO-detector ", 62, sensor_0062_other_MQ7_CO_detector) +// EZLOPI_DEVICE_LIST("sensor-MQ9-LPG-flameable-detector ", 63, sensor_0063_other_MQ9_LPG_flameable_detector) + +// EZLOPI_DEVICE_LIST("sensor-float-switch-digital ", 65, sensor_0065_digitalIn_float_switch) +// EZLOPI_DEVICE_LIST("sensor-fingerprint-sensor ", 66, sensor_0066_other_R307_FingerPrint) +// EZLOPI_DEVICE_LIST("sensor-hilink-presence-sensor ", 67, sensor_0067_hilink_presence_sensor_v3) +// EZLOPI_DEVICE_LIST("sensor-ENS160-gas-sensor ", 68, sensor_0068_ENS160_gas_sensor) +// EZLOPI_DEVICE_LIST("sensor-ze08-ch02-gas-sensor ", 69, sensor_0069_ze08_ch02_gas_sensor) //////// End of sensor/device list EZLOPI_DEVICE_LIST(NULL, 0, NULL) \ No newline at end of file diff --git a/ezlopi-core/ezlopi-core-factory-info/ezlopi_core_factory_info.c b/ezlopi-core/ezlopi-core-factory-info/ezlopi_core_factory_info.c index 7f9bd2820..ee3123406 100644 --- a/ezlopi-core/ezlopi-core-factory-info/ezlopi_core_factory_info.c +++ b/ezlopi-core/ezlopi-core-factory-info/ezlopi_core_factory_info.c @@ -2,6 +2,8 @@ #include #include "ezlopi_util_trace.h" + +#include "ezlopi_core_nvs.h" #include "ezlopi_core_factory_info.h" #if (ID_BIN_VERSION_2 == ID_BIN_VERSION) @@ -690,3 +692,17 @@ int ezlopi_factory_info_v3_factory_reset(void) return ret; } + +int ezlopi_factory_info_v3_scenes_factory_soft_reset(void) +{ + int ret = 0; + if (ezlopi_factory_info_v3_set_wifi("ezlopitest", "ezlopitest")) + { + ret = 1; + } + else + { + TRACE_E("Could not activate factory/soft reset"); + } + return ret; +} diff --git a/ezlopi-core/ezlopi-core-factory-info/ezlopi_core_factory_info.h b/ezlopi-core/ezlopi-core-factory-info/ezlopi_core_factory_info.h index 6e3cadc70..7e45e8e89 100644 --- a/ezlopi-core/ezlopi-core-factory-info/ezlopi_core_factory_info.h +++ b/ezlopi-core/ezlopi-core-factory-info/ezlopi_core_factory_info.h @@ -13,12 +13,11 @@ extern "C" #define EZLOPI_DEVICE_TYPE_TEST_DEVICE -1 #define EZLOPI_DEVICE_TYPE_GENERIC 0 - -#ifdef EZPI_DEV_TYPE_GENERIC -#define EZLOPI_DEVICE_TYPE EZLOPI_DEVICE_TYPE_GENERIC -#else +#if CONFIG_EZPI_DEV_TYPE_TEST == 1 #define EZLOPI_DEVICE_TYPE EZLOPI_DEVICE_TYPE_TEST_DEVICE -#endif +#else +#define EZLOPI_DEVICE_TYPE EZLOPI_DEVICE_TYPE_GENERIC +#endif #define EZLOPI_FACTORY_INFO_V3_PARTITION_NAME "prov_data" #define EZLOPI_FACTORY_INFO_V3_PARTITION_SIZE 0x8000 // 32KB @@ -151,6 +150,8 @@ extern "C" void ezlopi_factory_info_v3_free(void* arg); int ezlopi_factory_info_v3_factory_reset(void); + int ezlopi_factory_info_v3_scenes_factory_soft_reset(void); + #if (EZLOPI_DEVICE_TYPE_GENERIC == EZLOPI_DEVICE_TYPE) #elif (EZLOPI_DEVICE_TYPE_TEST_DEVICE == EZLOPI_DEVICE_TYPE) @@ -165,80 +166,24 @@ extern "C" \"id_room\": \"\",\ \"id_item\": 1,\ \"gpio_in\": 0,\ - \"gpio_out\": 1,\ + \"gpio_out\": 2,\ \"pullup_ip\": false,\ - \"pullup_op\": true,\ + \"pullup_op\": false,\ \"is_ip\": false,\ \"ip_inv\": false,\ \"op_inv\": false,\ \"val_ip\": false,\ \"val_op\": false\ },\ - {\ - \"dev_type\": 2,\ - \"dev_name\": \"Switch\",\ - \"id_room\": \"\",\ - \"id_item\": 4,\ - \"gpio\": 21,\ - \"logic_inv\": false,\ - \"pull_up\": true,\ - \"val_ip\": false,\ - \"ip_inv\": false\ - },\ {\ \"dev_type\": 3,\ - \"dev_name\": \"Water_leak\",\ - \"id_room\": \"\",\ - \"id_item\": 27,\ - \"gpio\": 7\ - },\ - {\ - \"dev_type\": 5,\ - \"dev_name\": \"RGB-Backlight\",\ - \"gpio\": 48,\ - \"id_item\": 9,\ - \"id_room\": \"\",\ - \"pwm_resln\": 3,\ - \"freq_hz\": 50,\ - \"duty_cycle\": 10\ - },\ - {\ - \"dev_type\": 6,\ - \"dev_name\": \"UART_MB1013\",\ - \"id_item\": 21,\ - \"id_room\": \"\",\ - \"gpio_tx\": 17,\ - \"gpio_rx\": 18,\ - \"baud_rate\": 9600\ - },\ - {\ - \"dev_type\": 7,\ - \"dev_name\": \"DHT 11\",\ - \"id_room\": \"\",\ - \"id_item\": 15,\ - \"gpio\": 15\ - },\ - {\ - \"dev_type\": 8,\ - \"dev_name\": \"GY271\",\ - \"id_room\": \"\",\ - \"id_item\": 7,\ - \"gpio_sda\": 40,\ - \"gpio_scl\": 41,\ - \"pullup_scl\": true,\ - \"pullup_sda\": true,\ - \"slave_addr\": 13\ - },\ - {\ - \"dev_name\": \"MQ9_LPG\",\ - \"dev_type\": 10,\ - \"id_item\": 63,\ + \"dev_name\": \"soil_moisture\",\ \"id_room\": \"\",\ - \"gpio1\": 25,\ - \"gpio2\": 6\ + \"id_item\": 32,\ + \"gpio\": 33\ }\ ],\ - \"dev_total\": 8}"; + \"dev_total\": 2}"; #endif diff --git a/ezlopi-core/ezlopi-core-http/CMakeLists.txt b/ezlopi-core/ezlopi-core-http/CMakeLists.txt index d4e53392a..7c4ff0fb1 100644 --- a/ezlopi-core/ezlopi-core-http/CMakeLists.txt +++ b/ezlopi-core/ezlopi-core-http/CMakeLists.txt @@ -4,6 +4,7 @@ file(GLOB_RECURSE config_src "*.c") set(ESP_IDF_COMPONENTS json + mbedtls esp-tls esp_http_client ) @@ -12,8 +13,13 @@ set(EZLOPI_COMPONENTS ezlopi-util-trace ) +set(EZLOPI_CORE_COMPONENTS + ezlopi-core-event-group +) + idf_component_register(SRCS "ezlopi_core_http.c" "${config_src}" INCLUDE_DIRS "." REQUIRES ${ESP_IDF_COMPONENTS} ${EZLOPI_COMPONENTS} + ${EZLOPI_CORE_COMPONENTS} ) diff --git a/ezlopi-core/ezlopi-core-http/ezlopi_core_http.c b/ezlopi-core/ezlopi-core-http/ezlopi_core_http.c index 9864f87be..f0209541e 100644 --- a/ezlopi-core/ezlopi-core-http/ezlopi_core_http.c +++ b/ezlopi-core/ezlopi-core-http/ezlopi_core_http.c @@ -1,9 +1,22 @@ +#include #include "esp_tls.h" +// #ifdef CONFIG_ESP_TLS_USING_MBEDTLS +#include "mbedtls/platform.h" +#include "mbedtls/net_sockets.h" +#include "mbedtls/esp_debug.h" +#include "mbedtls/ssl.h" +#include "mbedtls/entropy.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/error.h" +#include "mbedtls/certs.h" +// #endif #include "ezlopi_util_trace.h" #include "ezlopi_core_http.h" +#include "ezlopi_core_event_group.h" + static void ezlopi_http_free_rx_data(s_rx_data_t* rx_data); static esp_err_t ezlopi_http_event_handler(esp_http_client_event_t* evt); @@ -19,6 +32,455 @@ static esp_err_t ezlopi_http_event_handler(esp_http_client_event_t* evt); } \ } + +#define GET_STRING_SIZE(str) ((NULL != str) ? (strlen(str)) : 0) +#if 0 +// typedef struct ll_resp_buf +// { +// uint32_t len; +// uint8_t *buffer; +// struct ll_resp_buf *next; +// } ll_resp_buf_t; // implementation for response +#endif +//--------------- Memory Malloc functions -------------------------- +int ezlopi_core_http_calc_empty_bufsize(char* dest_buff, int dest_size, int reqd_size) +{ + int limit = dest_size - GET_STRING_SIZE(dest_buff); + limit = (limit > 0) ? limit : 0; + if (limit > reqd_size) + { + return limit; + } + return 0; +} + +int ezlopi_core_http_mem_malloc(char** __dest_ptr, const char* src_ptr) +{ + int ret = GET_STRING_SIZE(src_ptr); // calculate the size of content to be stored + if (NULL != src_ptr) + { + FREE_IF_NOT_NULL(*__dest_ptr); + // Now, do a fresh allocation + ret += 5; // (must be: n>2) + char* tmp_ptr = malloc(ret); + if (tmp_ptr) + { + bzero(tmp_ptr, (ret)); + snprintf(tmp_ptr, ret, "%s", src_ptr); + // TRACE_D("1. *Malloc_New_buffer : (%p)->(%p) : [%d]", *__dest_ptr, tmp_ptr, ret); + *__dest_ptr = tmp_ptr; // old gets replaced by new address + // TRACE_D("2.__dest_ptr(%p) : size=> [%d]", *__dest_ptr, GET_STRING_SIZE(*__dest_ptr)); + } + } + else + { + TRACE_E(" Error !!, given 'src_ptr' is NULL or Zero .... Allocation Aborted..."); + } + return ret; +} + +int ezlopi_core_http_dyna_relloc(char** Buf, int reqSize) +{ + int ret = 0; + if ((NULL != *Buf) && (reqSize > 0)) // strictly: (new-size != 0) + { + void* NewBuf = realloc(*Buf, reqSize); // reqSize ≤ 1.6 * n + if (NULL == NewBuf) + { + TRACE_E("Reallocation - failed"); + } + else + { + // TRACE_D("Relocating [%p] to [%p]: NewBuf[%d]", *Buf, NewBuf, reqSize); + *Buf = NewBuf; + ret = 1; // return success + } + } + return ret; +} + +//--------------------------- Static Mbedtls Functions ----------------------------------------------------- +/** + * @brief Function Trigger http_requests via mbedTLS. + * + * @return Address of a memory_block ; (char*)malloc(...) + */ +static void ezlopi_core_http_request_via_mbedTLS(const char* web_server, int web_port_num, const char* url_req, char** resp_buf) +{ + TRACE_I("&result==[%p] --> *resp_buf=>[%p]", resp_buf, *resp_buf); + int ret, flags, len; + uint32_t tmp_buf_size = 256; + char tmp_buf[tmp_buf_size]; + + char web_port[10] = { 0 }; + snprintf(web_port, 10, "%d", web_port_num); + web_port[9] = '\0'; + + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_ssl_context ssl; + mbedtls_x509_crt cacert; + mbedtls_ssl_config conf; + // mbedtls_entropy_context* entropy = malloc(sizeof(mbedtls_entropy_context)); + // mbedtls_ctr_drbg_context* ctr_drbg = malloc(sizeof(mbedtls_ctr_drbg_context)); + // mbedtls_ssl_context* ssl = malloc(sizeof(mbedtls_ssl_context)); + // mbedtls_x509_crt* cacert = malloc(sizeof(mbedtls_x509_crt)); + // mbedtls_ssl_config* conf = malloc(sizeof(mbedtls_ssl_config)); + // if (entropy && ctr_drbg && ssl && cacert && conf) + // { + mbedtls_net_context server_fd; + mbedtls_ssl_init(&ssl); + mbedtls_x509_crt_init(&cacert); + mbedtls_ctr_drbg_init(&ctr_drbg); + // TRACE_I("Seeding the random number generator"); + mbedtls_ssl_config_init(&conf); + mbedtls_entropy_init(&entropy); + if (0 != (ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, + NULL, 0))) + { + TRACE_E("mbedtls_ctr_drbg_seed returned %d", ret); + goto exit; + } + // TRACE_I("Attaching the certificate bundle..."); + + ret = esp_crt_bundle_attach(&conf); + if (ret < 0) + { + TRACE_E("esp_crt_bundle_attach returned -0x%x\n\n", -ret); + goto exit; + } + // TRACE_I("Setting hostname for TLS session..."); + + /* Hostname set here should match CN in server certificate */ + if (0 != (ret = mbedtls_ssl_set_hostname(&ssl, web_server))) + { + TRACE_E("mbedtls_ssl_set_hostname returned -0x%x", -ret); + goto exit; + } + + // TRACE_I("Setting up the SSL/TLS structure..."); + if (0 != (ret = mbedtls_ssl_config_defaults(&conf, + MBEDTLS_SSL_IS_CLIENT, + MBEDTLS_SSL_TRANSPORT_STREAM, + MBEDTLS_SSL_PRESET_DEFAULT))) + { + TRACE_E("mbedtls_ssl_config_defaults returned %d", ret); + goto exit; + } + + /* MBEDTLS_SSL_VERIFY_OPTIONAL is bad for security, in this example it will print + a warning if CA verification fails but it will continue to connect. + You should consider using MBEDTLS_SSL_VERIFY_REQUIRED in your own code. + */ + // mbedtls_ssl_conf_authmode(conf, MBEDTLS_SSL_VERIFY_REQUIRED); + mbedtls_ssl_conf_authmode(&conf, MBEDTLS_SSL_VERIFY_OPTIONAL); + mbedtls_ssl_conf_ca_chain(&conf, &cacert, NULL); + mbedtls_ssl_conf_rng(&conf, mbedtls_ctr_drbg_random, &ctr_drbg); +#ifdef CONFIG_MBEDTLS_DEBUG + mbedtls_esp_enable_debug_log(conf, CONFIG_MBEDTLS_DEBUG_LEVEL); +#endif + + if (0 != (ret = mbedtls_ssl_setup(&ssl, &conf))) + { + TRACE_E("mbedtls_ssl_setup returned -0x%x\n\n", -ret); + goto exit; + } + + mbedtls_net_init(&server_fd); + // TRACE_I("Connecting to %s:%s...", web_server, web_port); + + if (0 != (ret = mbedtls_net_connect(&server_fd, web_server, + web_port, MBEDTLS_NET_PROTO_TCP))) + { + TRACE_E("mbedtls_net_connect returned -%x", -ret); + goto exit; + } + // TRACE_I("Connected."); + mbedtls_ssl_set_bio(&ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, NULL); + + // TRACE_I("Performing the SSL/TLS handshake..."); + time_t start_tm = 0, now = 0; // now keeping track of time + time(&start_tm); + time(&now); + while (0 != (ret = mbedtls_ssl_handshake(&ssl))) + { + TRACE_W("ret => %x", -ret); // mbedtls_ssl_conf_async_private_cb() + if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) + { + TRACE_E("mbedtls_ssl_handshake returned -0x%x", -ret); + goto exit; + } + time(&now); + if ((now - start_tm) > (time_t)5) // 5sec + { + goto exit; + } + } + + // TRACE_I("Verifying peer X.509 certificate..."); + if (0 != (flags = mbedtls_ssl_get_verify_result(&ssl))) + { + /* In real life, we probably want to close connection if ret != 0 */ + TRACE_E("Failed to verify peer certificate!"); + bzero(tmp_buf, tmp_buf_size); + mbedtls_x509_crt_verify_info(tmp_buf, tmp_buf_size, " ! ", flags); + TRACE_E("verification Error_info: %s", tmp_buf); + goto exit; + } + else + { + // TRACE_I("Certificate verified."); + } + // TRACE_I("Cipher suite is %s", mbedtls_ssl_get_ciphersuite(ssl)); + // TRACE_I("Writing HTTP request..."); + size_t written_bytes = 0; + do + { + ret = mbedtls_ssl_write(&ssl, (const unsigned char*)url_req + written_bytes, + strlen(url_req) - written_bytes); + if (ret >= 0) + { + // TRACE_I("%d bytes written", ret); + written_bytes += ret; + } + else if (ret != MBEDTLS_ERR_SSL_WANT_WRITE && ret != MBEDTLS_ERR_SSL_WANT_READ) + { + TRACE_E("mbedtls_ssl_write returned -0x%x", -ret); + goto exit; + } + } while (written_bytes < strlen(url_req)); + + // TRACE_I("Reading HTTP response..."); + uint32_t resp_buf_size = tmp_buf_size + 1; + char* resp_buf_dummy = (char*)malloc(resp_buf_size); // points to a memory-block + if (resp_buf_dummy) + { + bzero(resp_buf_dummy, resp_buf_size); // clear the buffer + uint8_t reply_count = 0; + do + { + len = tmp_buf_size - 1; + bzero(tmp_buf, tmp_buf_size); + ret = mbedtls_ssl_read(&ssl, (unsigned char*)tmp_buf, len); + if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) + { + TRACE_I("MBEDTLS_ERR_SSL_WANT_READ/WRITE"); + continue; + } + if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) + { + TRACE_S("MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY"); + ret = 0; + break; + } + if (ret < 0) + { + TRACE_E("mbedtls_ssl_read returned -0x%x", -ret); + break; + } + if (ret == 0) + { + // TRACE_I("connection closed"); + break; + } + len = ret; + // TRACE_D("ret[%d]: %s", len, tmp_buf); + if (ret > 0) + { + reply_count++; + if (reply_count > 1) + { + resp_buf_size += (len + 5); // (+2)makes sure ; additional space for '\0' + if (ezlopi_core_http_dyna_relloc(&resp_buf_dummy, resp_buf_size)) + { + snprintf(resp_buf_dummy + strlen(resp_buf_dummy), len, "%s", tmp_buf); + } + else + { + resp_buf_size -= (len + 5); + } + } + else + { + snprintf(resp_buf_dummy, len, "%s", tmp_buf); // 513 + } + } + } while (1); + + if (strlen(resp_buf_dummy) > 0) + { + *resp_buf = resp_buf_dummy; + TRACE_I("&result==[%p] --> *resp_buf=>[%p] ", resp_buf, *resp_buf); + } + else + { + *resp_buf = NULL; + free(resp_buf_dummy); + } + } + + mbedtls_ssl_close_notify(&ssl); +exit: + mbedtls_ssl_session_reset(&ssl); + mbedtls_net_free(&server_fd); + if (0 != ret) + { + mbedtls_strerror(ret, tmp_buf, 100); + TRACE_E("Last error was: -0x%x - %s", -ret, tmp_buf); + } + TRACE_D("Minimum free heap size: %d bytes", esp_get_minimum_free_heap_size()); + + // Clearing used structures + mbedtls_ssl_free(&ssl); + mbedtls_ssl_config_free(&conf); + mbedtls_ctr_drbg_free(&ctr_drbg); + mbedtls_entropy_free(&entropy); + + // free(ssl); + // free(conf); + // free(ctr_drbg); + // free(entropy); + // free(cacert); +// } + TRACE_I("Completed a request"); +} + +/** + * @brief Function to extract the parameter values from 'config' struct and append it to '*request' + * + * @param config : custom struct consisting [headers + content + server_name + web_port ...] + * @param request : *ptr that holds the complete request_url + * @param request_len : total char-capacity the '*request' can contain. + */ +static void ezlopi_core_http_generate_request(s_ezlopi_core_http_mbedtls_t* config, char** request, int request_len) +{ + if ((NULL != config) && (NULL != *request) && (request_len > 0)) + { + // 1. Identify Http-Method + switch (config->method) + { + case HTTP_METHOD_GET: + { + // TRACE_S("HTTP GET-METHOD [%d]", config->method); + if (((NULL != config->username) && (GET_STRING_SIZE(config->username) > 0)) && + ((NULL != config->password) && (GET_STRING_SIZE(config->password) > 0))) + { + snprintf(*request, request_len, "GET %s?username=%s&password=%s HTTP/1.0\r\nUser-Agent: esp-idf/1.0 esp32\r\n", config->url, config->username, config->password); + } + else + { + snprintf(*request, request_len, "GET %s HTTP/1.0\r\nUser-Agent: esp-idf/1.0 esp32\r\n", config->url); + } + break; + } + case HTTP_METHOD_POST: + { + // TRACE_S("HTTP POST-METHOD [%d]", config->method); + snprintf(*request, request_len, "POST %s HTTP/1.0\r\nUser-Agent: esp-idf/1.0 esp32\r\n", config->url); + break; + } + case HTTP_METHOD_PUT: + { + // TRACE_S("HTTP PUT-METHOD [%d]", config->method); + snprintf(*request, request_len, "PUT %s HTTP/1.0\r\nUser-Agent: esp-idf/1.0 esp32\r\n", config->url); + break; + } + case HTTP_METHOD_DELETE: + { + // TRACE_S("HTTP DELETE-METHOD [%d]", config->method); + snprintf(*request, request_len, "DELETE %s HTTP/1.0\r\nUser-Agent: esp-idf/1.0 esp32\r\n", config->url); + break; + } + default: + { + TRACE_E("METHOD NOT FOUND.. {%d}", config->method); + break; + } + } + + // 2. adding 'Headers' to request_buffer + int max_allowed = 0; + if ((NULL != config->header) && (GET_STRING_SIZE(config->header) > 0)) + { + max_allowed = ezlopi_core_http_calc_empty_bufsize(*request, request_len, (strlen(config->header) + 3)); + if (max_allowed > 0) + { + snprintf(*request + strlen(*request), max_allowed, "%s\r\n", config->header); + } + } + // 3. adding content body to *request + if ((NULL != config->content) && (GET_STRING_SIZE(config->content) > 0)) + { + if ((HTTP_METHOD_GET != config->method) && + ((NULL != config->username) && (NULL != config->password))) + { + max_allowed = ezlopi_core_http_calc_empty_bufsize(*request, request_len, (strlen(config->username) + strlen(config->password) + strlen(config->content) + 3)); + } + else + { + max_allowed = ezlopi_core_http_calc_empty_bufsize(*request, request_len, (strlen(config->content) + 3)); + } + + if (max_allowed > 0) + { + snprintf(*request + strlen(*request), max_allowed, "%s\r\n", config->content); + } + } + } + else + { + TRACE_E("invalid arguments to generate Request_URL"); + } +} + +void ezlopi_core_http_mbedtls_req(s_ezlopi_core_http_mbedtls_t* config) +{ + if (config) + { + int request_len = (config->url_maxlen) + (config->header_maxlen) + (config->content_maxlen) + 100; // [>25] ; for "skipSecurity: true" + char* request = malloc(sizeof(char) * request_len); + if (request) + { + bzero(request, request_len); + request[request_len - 1] = '\0'; + + ezlopi_core_http_generate_request(config, &request, request_len); + + // Ready-Up 'request' buffer + TRACE_I("request[capacity: %d]:\n\n%s[%d]", request_len, request, strlen(request)); + +#if 0 + // char* cloud_server = NULL; // ezlopi_factory_info_v3_get_cloud_server(); + // char* ca_certificate = NULL; // ezlopi_factory_info_v3_get_ca_certificate(); + // char* ssl_shared_key = NULL; // ezlopi_factory_info_v3_get_ssl_shared_key(); + // char* ssl_private_key = NULL; // ezlopi_factory_info_v3_get_ssl_private_key(); + // s_ezlopi_http_data_t *ws_endpoint = ezlopi_http_get_request(request, NULL, NULL, NULL); + // if (ws_endpoint) + // { + // if (ws_endpoint->response) + // { + // TRACE_D("=>\n%s[%d]", ws_endpoint->response, strlen(ws_endpoint->response)) + // free(ws_endpoint->response); + // } + // free(ws_endpoint); + // } +#endif + TRACE_D("Minimum free heap size: %d bytes\n", esp_get_minimum_free_heap_size()); + TRACE_E("&result==[%p]", &(config->response)); + ezlopi_core_http_request_via_mbedTLS(config->web_server, (config->web_port), request, &(config->response)); + if (config->response) + { + TRACE_D("*result[%p] =>\n[%d]\n%s", config->response, strlen(config->response), config->response); + free(config->response); // return to destination buffer + config->response = NULL; + } + free(request); + } + } +} +//------------------------------------------------------------------------------------------------------------------------------------------------------ + + s_ezlopi_http_data_t* ezlopi_http_get_request(const char* cloud_url, const char* private_key, const char* shared_key, const char* ca_certificate) { char* ret = NULL; @@ -132,7 +594,7 @@ s_ezlopi_http_data_t* ezlopi_http_post_request(const char* cloud_url, const char cJSON* header = headers->child; while (header) { - // TRACE_I("%s: %s", header->string, header->valuestring); + TRACE_I("%s: %s", header->string, header->valuestring); esp_http_client_set_header(client, header->string, header->valuestring); header = header->next; } @@ -159,7 +621,7 @@ s_ezlopi_http_data_t* ezlopi_http_post_request(const char* cloud_url, const char while (cur_d) { strcat(ret, cur_d->ptr); - // TRACE_D("%.*s", cur_d->len, cur_d->ptr); + TRACE_D("%.*s", cur_d->len, cur_d->ptr); cur_d = cur_d->next; } } diff --git a/ezlopi-core/ezlopi-core-http/ezlopi_core_http.h b/ezlopi-core/ezlopi-core-http/ezlopi_core_http.h index c9da39534..6c97cdaab 100644 --- a/ezlopi-core/ezlopi-core-http/ezlopi_core_http.h +++ b/ezlopi-core/ezlopi-core-http/ezlopi_core_http.h @@ -4,10 +4,14 @@ #include #include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + #include "esp_err.h" #include "esp_log.h" #include "esp_event.h" #include "esp_http_client.h" +#include "esp_crt_bundle.h" #include "cJSON.h" #ifdef __cplusplus @@ -17,21 +21,75 @@ extern "C" typedef struct s_rx_data { - char *ptr; + char* ptr; int len; int total_len; - struct s_rx_data *next; + struct s_rx_data* next; } s_rx_data_t; typedef struct ezlopi_http_data { - char *response; + char* response; HttpStatus_Code status_code; } s_ezlopi_http_data_t; - s_ezlopi_http_data_t *ezlopi_http_get_request(const char *cloud_url, const char *private_key, const char *shared_key, const char *ca_certificate); - s_ezlopi_http_data_t *ezlopi_http_post_request(const char *cloud_url, const char *location, cJSON *headers, const char *private_key, const char *shared_key, const char *ca_certificate); + typedef struct s_ezlopi_core_http_mbedtls + { + esp_http_client_method_t method; // default :- GET_METHOD + bool skip_cert_common_name_check; + int web_port; + char* url; // ptr => complete_url [.eg. https://www.google.com/json?username=qqqq&password=zzzz ] + char* web_server; // ptr => web_sever_name [.eg. www.google.com] + char* header; // ptr => headers [.eg. {"Accept" : "*/*", ....}] + char* content; + char* username; + char* password; + char* response; + uint8_t username_maxlen; // max @ 256 bytes + uint8_t password_maxlen; + uint16_t url_maxlen; // max @ 65536 = 60Kb + uint16_t web_server_maxlen; + uint16_t header_maxlen; + uint16_t content_maxlen; + uint16_t response_maxlen; + TaskHandle_t mbedtls_task_handle; + } s_ezlopi_core_http_mbedtls_t; + + /** + * @brief Function to return remaining space in *dest_buffer. + */ + int ezlopi_core_http_calc_empty_bufsize(char* dest_buff, int dest_size, int reqd_size); + + /** + * @brief This function :- mallocs fresh memory_block to '__dest_ptr' , copies content of 'src_ptr' to '__dest_ptr' and returns malloced_size. + * + * @param __dest_ptr [ Address of ptr which will point to (char*) block of memory. ] + * @param src_ptr [ Address of the string literal you want to store/append. ] + * + * @return (int) [size_of_malloced block] + */ + int ezlopi_core_http_mem_malloc(char** __dest_ptr, const char* src_ptr); + + /** + * @brief This function creates new_memory_block (size == 'reqSize') & Rellocates Original memory-block (*Buf) to new_memory_block_address + * + * @param Buf [ Address of ptr which will point to (char*) original block of memory. ] + * @param reqSize [ new-size to be allocated. ] + * + * @return (int) [0 ==> Fail ; 1 ==> Success] + */ + int ezlopi_core_http_dyna_relloc(char** Buf, int reqSize); + + /** + * @brief This Task , generates a http request, by combining information contained in '*config'. + * + * @param config : config_struct [ complete_url + webserver-name + web_port + headers + content + username + password + response ] + */ + void ezlopi_core_http_mbedtls_req(s_ezlopi_core_http_mbedtls_t* tmp_http_data); + + s_ezlopi_http_data_t* ezlopi_http_get_request(const char* cloud_url, const char* private_key, const char* shared_key, const char* ca_certificate); + s_ezlopi_http_data_t* ezlopi_http_post_request(const char* cloud_url, const char* location, cJSON* headers, const char* private_key, const char* shared_key, const char* ca_certificate); #ifdef __cplusplus } diff --git a/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c b/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c index af83ef20b..e5878f4d7 100644 --- a/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c +++ b/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.c @@ -364,6 +364,53 @@ uint32_t ezlopi_nvs_get_boot_count(void) return boot_count; } +void ezlopi_nvs_scenes_soft_reset(void) +{ + esp_err_t err = ESP_OK; + if (1 == ezlopi_nvs_init()) + { + // only 'wifi' key is cleared during 'soft reset' + if (ESP_OK != (err = nvs_erase_key(ezlopi_nvs_handle, wifi_info_nvs_name))) + { + TRACE_E("Erasing nvs-key '%s' failed!, error: %s", wifi_info_nvs_name, esp_err_to_name(err)); + } + } +} + +void ezlopi_nvs_scenes_factory_info_reset(void) +{ + esp_err_t err = ESP_OK; + if (1 == ezlopi_nvs_init()) + { + // list of nvs keys cleared during 'factory reset' + if (ESP_OK != (err = nvs_erase_key(ezlopi_nvs_handle, user_id_nvs_name))) // ble + { + TRACE_E("Erasing nvs-key '%s' failed!, error: %s", user_id_nvs_name, esp_err_to_name(err)); + } + if (ESP_OK != (err = nvs_erase_key(ezlopi_nvs_handle, passkey_nvs_name))) // ble + { + TRACE_E("Erasing nvs-key '%s' failed!, error: %s", passkey_nvs_name, esp_err_to_name(err)); + } + if (ESP_OK != (err = nvs_erase_key(ezlopi_nvs_handle, ezlopi_scenes_v2_nvs_name))) + { + TRACE_E("Erasing nvs-key '%s' failed!, error: %s", ezlopi_scenes_v2_nvs_name, esp_err_to_name(err)); + } + if (ESP_OK != (err = nvs_erase_key(ezlopi_nvs_handle, ezlopi_scripts_nvs_ids))) + { + TRACE_E("Erasing nvs-key '%s' failed!, error: %s", ezlopi_scripts_nvs_ids, esp_err_to_name(err)); + } + if (ESP_OK != (err = nvs_erase_key(ezlopi_nvs_handle, ezlopi_scenes_expression_ids))) + { + TRACE_E("Erasing nvs-key '%s' failed!, error: %s", ezlopi_scenes_expression_ids, esp_err_to_name(err)); + } + // if (ESP_OK != (err = nvs_erase_key(ezlopi_nvs_handle, settings_initialized_status_name))) // "settings_magic" + // { + // TRACE_E("Erasing nvs-key '%s' failed!, error: %s", settings_initialized_status_name, esp_err_to_name(err)); + // } + } + ezlopi_nvs_scenes_soft_reset(); +} + uint8_t ezlopi_nvs_write_int32(int32_t i, const char* key_name) { uint8_t ret = 0; diff --git a/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.h b/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.h index 6370bc30e..bc2fb43ed 100644 --- a/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.h +++ b/ezlopi-core/ezlopi-core-nvs/ezlopi_core_nvs.h @@ -44,6 +44,9 @@ extern "C" uint32_t ezlopi_nvs_get_provisioning_status(void); void ezlopi_nvs_set_provisioning_status(void); + void ezlopi_nvs_scenes_soft_reset(void); + void ezlopi_nvs_scenes_factory_info_reset(void); + #if 0 int ezlopi_settings_save_settings(const s_ezlopi_hub_settings_t* settings_list, uint16_t num_settings); int ezlopi_settings_retrive_settings(s_ezlopi_hub_settings_t* ezlopi_settings_list, uint16_t num_settings); @@ -87,9 +90,9 @@ extern "C" char* ezlopi_nvs_read_modes(void); int ezlopi_nvs_write_modes(char* data); - - char *ezlopi_nvs_read_latidtude_longitude(); - int ezlopi_nvs_write_latitude_longitude(char *data); + + char* ezlopi_nvs_read_latidtude_longitude(); + int ezlopi_nvs_write_latitude_longitude(char* data); #ifdef __cplusplus } diff --git a/ezlopi-core/ezlopi-core-ota/CMakeLists.txt b/ezlopi-core/ezlopi-core-ota/CMakeLists.txt index c6fdc9958..1ff581c8e 100644 --- a/ezlopi-core/ezlopi-core-ota/CMakeLists.txt +++ b/ezlopi-core/ezlopi-core-ota/CMakeLists.txt @@ -10,8 +10,13 @@ set(EZLOPI_CORE_COMPONENTS ezlopi-core-reset ) +set(EZLOPI_SERVICE_COMPONENTS + ezlopi-service-ota +) + idf_component_register(SRCS "ezlopi_core_ota.c" "${config_src}" INCLUDE_DIRS "." REQUIRES ${ESP_IDF_COMPONENTS} ${EZLOPI_CORE_COMPONENTS} + ${EZLOPI_SERVICE_COMPONENTS} ) diff --git a/ezlopi-core/ezlopi-core-ota/ezlopi_core_ota.c b/ezlopi-core/ezlopi-core-ota/ezlopi_core_ota.c index 2e4ccc2ee..5ac5631b4 100644 --- a/ezlopi-core/ezlopi-core-ota/ezlopi_core_ota.c +++ b/ezlopi-core/ezlopi-core-ota/ezlopi_core_ota.c @@ -1,4 +1,6 @@ // #include "cJSON.h" +// #include "nvs.h" +// #include "nvs_flash.h" #include #include @@ -17,32 +19,44 @@ #include "ezlopi_core_reset.h" #include "ezlopi_core_factory_info.h" -// #include "nvs.h" -// #include "nvs_flash.h" +#include "ezlopi_service_ota.h" #define HASH_LEN 32 #ifdef CONFIG_FIRMWARE_UPGRADE_BIND_IF /* The interface name value can refer to if_desc in esp_netif_defaults.h */ #if CONFIG_FIRMWARE_UPGRADE_BIND_IF_ETH -static const char *bind_interface_name = "eth"; +static const char* bind_interface_name = "eth"; #elif CONFIG_FIRMWARE_UPGRADE_BIND_IF_STA -static const char *bind_interface_name = "sta"; +static const char* bind_interface_name = "sta"; #endif #endif #define OTA_URL_SIZE 512 +typedef enum e_ezlopi_ota_state +{ + EZLOPI_OTA_STATE_FINISH = 0, + EZLOPI_OTA_STATE_STARTED, + EZLOPI_OTA_STATE_UPDATING, + EZLOPI_OTA_STATE_MAX, +} e_ezlopi_ota_state_t; + static volatile uint32_t __ota_in_process = 0; -static void ezlopi_ota_process(void *pv); -static esp_err_t _http_event_handler(esp_http_client_event_t *evt); +static void ezlopi_ota_process(void* pv); +static esp_err_t _http_event_handler(esp_http_client_event_t* evt); -void ezlopi_ota_start(cJSON *url) +uint32_t __get_ota_state(void) +{ + return ((__ota_in_process < EZLOPI_OTA_STATE_MAX) ? __ota_in_process : EZLOPI_OTA_STATE_FINISH); +} + +void ezlopi_ota_start(cJSON* url) { if (url && url->valuestring) { - char *ota_url = (char *)malloc(OTA_URL_SIZE); + char* ota_url = (char*)malloc(OTA_URL_SIZE); memcpy(ota_url, url->valuestring, OTA_URL_SIZE); if (0 == __ota_in_process) { @@ -61,14 +75,14 @@ void ezlopi_ota_start(cJSON *url) } } -static void ezlopi_ota_process(void *pv) +static void ezlopi_ota_process(void* pv) { - __ota_in_process = 1; - char *url = (char *)pv; + __ota_in_process = EZLOPI_OTA_STATE_STARTED; + char* url = (char*)pv; TRACE_S("Starting OTA "); #ifdef CONFIG_FIRMWARE_UPGRADE_BIND_IF - esp_netif_t *netif = get_example_netif_from_desc(bind_interface_name); + esp_netif_t* netif = get_example_netif_from_desc(bind_interface_name); if (netif == NULL) { TRACE_E("Can't find netif from interface description"); @@ -111,6 +125,11 @@ static void ezlopi_ota_process(void *pv) } #endif + if (true == __get_ota_service_busy_state()) + { + __ota_in_process = EZLOPI_OTA_STATE_UPDATING; + } + esp_err_t ret = esp_https_ota(&config); if (ret == ESP_OK) { @@ -122,7 +141,7 @@ static void ezlopi_ota_process(void *pv) TRACE_E("Firmware upgrade failed"); } - __ota_in_process = 0; + __ota_in_process = EZLOPI_OTA_STATE_FINISH; vTaskDelete(NULL); @@ -130,7 +149,7 @@ static void ezlopi_ota_process(void *pv) free(url); } -static esp_err_t _http_event_handler(esp_http_client_event_t *evt) +static esp_err_t _http_event_handler(esp_http_client_event_t* evt) { switch (evt->event_id) { diff --git a/ezlopi-core/ezlopi-core-ota/ezlopi_core_ota.h b/ezlopi-core/ezlopi-core-ota/ezlopi_core_ota.h index 0007ac865..3e5d510a2 100644 --- a/ezlopi-core/ezlopi-core-ota/ezlopi_core_ota.h +++ b/ezlopi-core/ezlopi-core-ota/ezlopi_core_ota.h @@ -9,7 +9,8 @@ extern "C" { #endif - void ezlopi_ota_start(cJSON *cj_url); + uint32_t __get_ota_state(void); + void ezlopi_ota_start(cJSON* cj_url); #ifdef __cplusplus } diff --git a/ezlopi-core/ezlopi-core-scenes/CMakeLists.txt b/ezlopi-core/ezlopi-core-scenes/CMakeLists.txt index b20700e40..8636116fd 100644 --- a/ezlopi-core/ezlopi-core-scenes/CMakeLists.txt +++ b/ezlopi-core/ezlopi-core-scenes/CMakeLists.txt @@ -2,7 +2,7 @@ file(GLOB_RECURSE config_src "*.c") -idf_component_register(SRCS "ezlopi_core_scenes_scripts.c" "${config_src}" +idf_component_register(SRCS "ezlopi_core_scenes_print.c" "ezlopi_core_scenes_then_methods_helper_func.c" "ezlopi_core_scenes_status_changed.c" "ezlopi_core_scenes_then_methods.c" "ezlopi_core_scenes_v2.c" "ezlopi_core_scenes_cjson.c" "ezlopi_core_scenes_when_methods_helper_functions.c" "ezlopi_core_scenes_when_methods.c" "ezlopi_core_scenes_scripts.c" "${config_src}" INCLUDE_DIRS "." REQUIRES core - ) \ No newline at end of file + ) \ No newline at end of file diff --git a/ezlopi-core/ezlopi-core-scenes/__operators_macros/__in_array_comparision_operators_macros.h b/ezlopi-core/ezlopi-core-scenes/__operators_macros/__in_array_comparision_operators_macros.h new file mode 100644 index 000000000..3a3876b64 --- /dev/null +++ b/ezlopi-core/ezlopi-core-scenes/__operators_macros/__in_array_comparision_operators_macros.h @@ -0,0 +1,6 @@ +SCENES_IN_ARRAY_OPERATORS(NONE, NULL, NULL, NULL) +////////////////////////////////////////////////////////////////////////////// +SCENES_IN_ARRAY_OPERATORS(IN, "in", "contain", "inArray") +SCENES_IN_ARRAY_OPERATORS(NOT_IN, "not_in", "doesn't contain", "inArray") +////////////////////////////////////////////////////////////////////////////// +SCENES_IN_ARRAY_OPERATORS(MAX, NULL, NULL, NULL) \ No newline at end of file diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_cjson.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_cjson.c index 1e7ff4361..93ac24da5 100755 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_cjson.c +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_cjson.c @@ -38,13 +38,13 @@ cJSON* ezlopi_scene_cjson_get_field(l_fields_v2_t* field_node) case EZLOPI_VALUE_TYPE_FLOAT: { cJSON_AddNumberToObject(cj_field, ezlopi_value_str, field_node->field_value.u_value.value_double); - // cJSON_AddNumberToObject(cj_field, ezlopi_value_str, field_node->value.value_double); + // cJSON_AddNumberToObject(cj_field, ezlopi_value_str, field_node->field_value.u_value.value_double); break; } case EZLOPI_VALUE_TYPE_BOOL: { if (0 == field_node->field_value.u_value.value_double) - // if (0 == field_node->value.value_double) + // if (0 == field_node->field_value.u_value.value_double) { cJSON_AddFalseToObject(cj_field, ezlopi_value_str); } @@ -57,9 +57,10 @@ cJSON* ezlopi_scene_cjson_get_field(l_fields_v2_t* field_node) case EZLOPI_VALUE_TYPE_ITEM: case EZLOPI_VALUE_TYPE_STRING: case EZLOPI_VALUE_TYPE_INTERVAL: + case EZLOPI_VALUE_TYPE_SCENEID: { __cjson_add_string(cj_field, ezlopi_value_str, field_node->field_value.u_value.value_string); - // __cjson_add_string(cj_field, ezlopi_value_str, field_node->value.value_string); + // __cjson_add_string(cj_field, ezlopi_value_str, field_node->field_value.u_value.value_string); break; } case EZLOPI_VALUE_TYPE_BLOCKS: @@ -86,14 +87,37 @@ cJSON* ezlopi_scene_cjson_get_field(l_fields_v2_t* field_node) } break; } + case EZLOPI_VALUE_TYPE_ENUM: + case EZLOPI_VALUE_TYPE_TOKEN: + { + if (field_node->field_value.e_type == VALUE_TYPE_STRING) + { + __cjson_add_string(cj_field, ezlopi_value_str, field_node->field_value.u_value.value_string); + } + else if (field_node->field_value.e_type == VALUE_TYPE_CJSON) + { + cJSON_AddItemToObject(cj_field, ezlopi_value_str, cJSON_Duplicate(field_node->field_value.u_value.cj_value, 1)); + } + + } + case EZLOPI_VALUE_TYPE_CREDENTIAL: case EZLOPI_VALUE_TYPE_DICTIONARY: case EZLOPI_VALUE_TYPE_ARRAY: + case EZLOPI_VALUE_TYPE_WEEKLY_INTERVAL: + case EZLOPI_VALUE_TYPE_DAILY_INTERVAL: + case EZLOPI_VALUE_TYPE_24_HOURS_TIME: + case EZLOPI_VALUE_TYPE_24_HOURS_TIME_ARRAY: + case EZLOPI_VALUE_TYPE_INT_ARRAY: + case EZLOPI_VALUE_TYPE_HMS_INTERVAL: + { + // #warning "need to duplicate?" + // cJSON_AddItemReferenceToObject(cj_field, ezlopi_value_str, field_node->field_value.u_value.cj_value); + cJSON_AddItemToObject(cj_field, ezlopi_value_str, cJSON_Duplicate(field_node->field_value.u_value.cj_value, 1)); + break; + } case EZLOPI_VALUE_TYPE_RGB: case EZLOPI_VALUE_TYPE_CAMERA_STREAM: case EZLOPI_VALUE_TYPE_USER_CODE: - case EZLOPI_VALUE_TYPE_WEEKLY_INTERVAL: - case EZLOPI_VALUE_TYPE_DAILY_INTERVAL: - case EZLOPI_VALUE_TYPE_TOKEN: case EZLOPI_VALUE_TYPE_BUTTON_STATE: case EZLOPI_VALUE_TYPE_USER_LOCK_OPERATION: case EZLOPI_VALUE_TYPE_USER_CODE_ACTION: @@ -141,11 +165,6 @@ cJSON* ezlopi_scene_cjson_get_field(l_fields_v2_t* field_node) case EZLOPI_VALUE_TYPE_REACTIVE_POWER_CONSUMPTION: case EZLOPI_VALUE_TYPE_DEVICE: case EZLOPI_VALUE_TYPE_EXPRESSION: - case EZLOPI_VALUE_TYPE_24_HOURS_TIME: - case EZLOPI_VALUE_TYPE_24_HOURS_TIME_ARRAY: - case EZLOPI_VALUE_TYPE_INT_ARRAY: - case EZLOPI_VALUE_TYPE_HMS_INTERVAL: - case EZLOPI_VALUE_TYPE_NONE: case EZLOPI_VALUE_TYPE_MAX: { @@ -394,19 +413,46 @@ static void __cjson_add_fields(cJSON* cj_block, l_fields_v2_t* fields) snprintf(id_str, sizeof(id_str), "%u", (uint32_t)curr_field->field_value.u_value.value_double); break; } + case EZLOPI_VALUE_TYPE_ARRAY: + case EZLOPI_VALUE_TYPE_24_HOURS_TIME: + case EZLOPI_VALUE_TYPE_24_HOURS_TIME_ARRAY: + case EZLOPI_VALUE_TYPE_INT_ARRAY: + case EZLOPI_VALUE_TYPE_HMS_INTERVAL: case EZLOPI_VALUE_TYPE_HOUSE_MODE_ID_ARRAY: { + // #warning "adding reference vs duplicating the object?"; cJSON_AddItemReferenceToObject(cj_field, ezlopi_value_str, curr_field->field_value.u_value.cj_value); break; } + case EZLOPI_VALUE_TYPE_CREDENTIAL: case EZLOPI_VALUE_TYPE_DICTIONARY: - case EZLOPI_VALUE_TYPE_ARRAY: + case EZLOPI_VALUE_TYPE_ENUM: + case EZLOPI_VALUE_TYPE_TOKEN: + { + if (VALUE_TYPE_STRING == curr_field->field_value.e_type) + { + __cjson_add_string(cj_field, ezlopi_value_str, curr_field->field_value.u_value.value_string); + } + else if (VALUE_TYPE_CJSON == curr_field->field_value.e_type) + { + cJSON_AddItemReferenceToObject(cj_field, ezlopi_value_str, curr_field->field_value.u_value.cj_value); + } + else + { + TRACE_W("Value type not Implemented!, value_type: %d", curr_field->value_type); + } + break; + } + case EZLOPI_VALUE_TYPE_SCENEID: + { + __cjson_add_string(cj_field, ezlopi_value_str, curr_field->field_value.u_value.value_string); + break; + } case EZLOPI_VALUE_TYPE_RGB: case EZLOPI_VALUE_TYPE_CAMERA_STREAM: case EZLOPI_VALUE_TYPE_USER_CODE: case EZLOPI_VALUE_TYPE_WEEKLY_INTERVAL: case EZLOPI_VALUE_TYPE_DAILY_INTERVAL: - case EZLOPI_VALUE_TYPE_TOKEN: case EZLOPI_VALUE_TYPE_BUTTON_STATE: case EZLOPI_VALUE_TYPE_USER_LOCK_OPERATION: case EZLOPI_VALUE_TYPE_USER_CODE_ACTION: @@ -454,10 +500,6 @@ static void __cjson_add_fields(cJSON* cj_block, l_fields_v2_t* fields) case EZLOPI_VALUE_TYPE_REACTIVE_POWER_CONSUMPTION: case EZLOPI_VALUE_TYPE_DEVICE: case EZLOPI_VALUE_TYPE_EXPRESSION: - case EZLOPI_VALUE_TYPE_24_HOURS_TIME: - case EZLOPI_VALUE_TYPE_24_HOURS_TIME_ARRAY: - case EZLOPI_VALUE_TYPE_INT_ARRAY: - case EZLOPI_VALUE_TYPE_HMS_INTERVAL: case EZLOPI_VALUE_TYPE_MAX: { TRACE_W("Value type not implemented!, curr-type: %d", curr_field->value_type); diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_delete.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_delete.c index d3243a043..b05d0384d 100755 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_delete.c +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_delete.c @@ -85,38 +85,38 @@ void ezlopi_scenes_delete_field_value(l_fields_v2_t* field) case VALUE_TYPE_NUMBER: { field->field_value.u_value.value_double = 0; - // field->value.value_double = 0; + // field->field_value.u_value.value_double = 0; break; } case VALUE_TYPE_STRING: { if (field->field_value.u_value.value_string) - // if (field->value.value_string) + // if (field->field_value.u_value.value_string) { free(field->field_value.u_value.value_string); field->field_value.u_value.value_string = NULL; - // free(field->value.value_string); - // field->value.value_string = NULL; + // free(field->field_value.u_value.value_string); + // field->field_value.u_value.value_string = NULL; } break; } case VALUE_TYPE_BOOL: { field->field_value.u_value.value_bool = false; - // field->value.value_bool = false; + // field->field_value.u_value.value_bool = false; break; } case VALUE_TYPE_CJSON: { if (field->field_value.u_value.cj_value) - // if (field->value.cj_value) + // if (field->field_value.u_value.cj_value) { cJSON_Delete(field->field_value.u_value.cj_value); field->field_value.u_value.cj_value = NULL; - // cJSON_Delete(field->value.cj_value); - // field->value.cj_value = NULL; + // cJSON_Delete(field->field_value.u_value.cj_value); + // field->field_value.u_value.cj_value = NULL; } break; } diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_edit.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_edit.c index 029bf2681..c5ff1b4a7 100644 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_edit.c +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_edit.c @@ -8,22 +8,22 @@ #include "ezlopi_service_meshbot.h" -static void _edit_scene(l_scenes_list_v2_t *scene_node, cJSON *cj_scene); +static void _edit_scene(l_scenes_list_v2_t* scene_node, cJSON* cj_scene); -int ezlopi_core_scene_edit_store_updated_to_nvs(cJSON *cj_updated_scene) +int ezlopi_core_scene_edit_store_updated_to_nvs(cJSON* cj_updated_scene) { int ret = 0; if (cj_updated_scene) { - char *update_scene_str = cJSON_Print(cj_updated_scene); + char* update_scene_str = cJSON_Print(cj_updated_scene); if (update_scene_str) { - cJSON *cj_scene_id = cJSON_GetObjectItem(cj_updated_scene, ezlopi__id_str); + cJSON* cj_scene_id = cJSON_GetObjectItem(cj_updated_scene, ezlopi__id_str); if (cj_scene_id && cj_scene_id->valuestring) { ezlopi_nvs_delete_stored_data_by_name(cj_scene_id->valuestring); cJSON_Minify(update_scene_str); - if(1 == ezlopi_nvs_write_str(update_scene_str, strlen(update_scene_str), cj_scene_id->valuestring)) + if (1 == ezlopi_nvs_write_str(update_scene_str, strlen(update_scene_str), cj_scene_id->valuestring)) { ret = 1; } @@ -36,14 +36,14 @@ int ezlopi_core_scene_edit_store_updated_to_nvs(cJSON *cj_updated_scene) return ret; } -int ezlopi_core_scene_edit_update_id(uint32_t scene_id, cJSON *cj_updated_scene) +int ezlopi_core_scene_edit_update_id(uint32_t scene_id, cJSON* cj_updated_scene) { int ret = 0; CJSON_TRACE("cj_updated_scene", cj_updated_scene); if (scene_id && cj_updated_scene) { - l_scenes_list_v2_t *scene_node = ezlopi_scenes_get_scenes_head_v2(); + l_scenes_list_v2_t* scene_node = ezlopi_scenes_get_scenes_head_v2(); while (scene_node) { if (scene_id == scene_node->_id) @@ -65,7 +65,7 @@ int ezlopi_core_scene_edit_update_id(uint32_t scene_id, cJSON *cj_updated_scene) return ret; } -static void _edit_scene(l_scenes_list_v2_t *scene_node, cJSON *cj_scene) +static void _edit_scene(l_scenes_list_v2_t* scene_node, cJSON* cj_scene) { CJSON_GET_VALUE_INT(cj_scene, ezlopi_enabled_str, scene_node->enabled); CJSON_GET_VALUE_INT(cj_scene, ezlopi_is_group_str, scene_node->is_group); @@ -75,7 +75,7 @@ static void _edit_scene(l_scenes_list_v2_t *scene_node, cJSON *cj_scene) CJSON_GET_VALUE_STRING_BY_COPY(cj_scene, ezlopi_parent_id_str, scene_node->parent_id); { - cJSON *cj_user_notifications = cJSON_GetObjectItem(cj_scene, ezlopi_user_notifications_str); + cJSON* cj_user_notifications = cJSON_GetObjectItem(cj_scene, ezlopi_user_notifications_str); if (cj_user_notifications && (cJSON_Array == cj_user_notifications->type)) { ezlopi_scenes_delete_user_notifications(scene_node->user_notifications); @@ -84,7 +84,7 @@ static void _edit_scene(l_scenes_list_v2_t *scene_node, cJSON *cj_scene) } { - cJSON *cj_house_modes = cJSON_GetObjectItem(cj_scene, ezlopi_house_modes_str); + cJSON* cj_house_modes = cJSON_GetObjectItem(cj_scene, ezlopi_house_modes_str); if (cj_house_modes && (cJSON_Array == cj_house_modes->type)) { ezlopi_scenes_delete_house_modes(scene_node->house_modes); @@ -93,7 +93,7 @@ static void _edit_scene(l_scenes_list_v2_t *scene_node, cJSON *cj_scene) } { - cJSON *cj_then_blocks = cJSON_GetObjectItem(cj_scene, ezlopi_then_str); + cJSON* cj_then_blocks = cJSON_GetObjectItem(cj_scene, ezlopi_then_str); if (cj_then_blocks && (cJSON_Array == cj_then_blocks->type)) { ezlopi_scenes_delete_action_blocks(scene_node->then_block); @@ -102,7 +102,7 @@ static void _edit_scene(l_scenes_list_v2_t *scene_node, cJSON *cj_scene) } { - cJSON *cj_when_blocks = cJSON_GetObjectItem(cj_scene, ezlopi_when_str); + cJSON* cj_when_blocks = cJSON_GetObjectItem(cj_scene, ezlopi_when_str); if (cj_when_blocks && (cJSON_Array == cj_when_blocks->type)) { ezlopi_scenes_delete_when_blocks(scene_node->when_block); @@ -111,7 +111,7 @@ static void _edit_scene(l_scenes_list_v2_t *scene_node, cJSON *cj_scene) } { - cJSON *cj_else_blocks = cJSON_GetObjectItem(cj_scene, ezlopi_else_str); + cJSON* cj_else_blocks = cJSON_GetObjectItem(cj_scene, ezlopi_else_str); if (cj_else_blocks && (cJSON_Array == cj_else_blocks->type)) { ezlopi_scenes_delete_action_blocks(scene_node->else_block); diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_operators.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_operators.c index 29923e684..abb514ab8 100755 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_operators.c +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_operators.c @@ -9,6 +9,22 @@ #include "ezlopi_cloud_constants.h" +//------------------------------------------------- +#define MAX_STRING_LEN(str1, str2) ((strlen(str1) > strlen(str2)) ? strlen(str1) : strlen(str2)) +#define OPERATE_ON_STRINGS(STR1, op, STR2) (strncmp(STR1, STR2, MAX_STRING_LEN(STR1, STR2)) op 0) // logical-arrangement of '__ op 0' returns correct results +#define STR_OP_COMP(STR1, op, STR2) \ + ((NULL == STR1) ? false \ + : (NULL == STR2) ? false \ + : OPERATE_ON_STRINGS(STR1, op, STR2)) + +static const char* const ezlopi_scenes_value_numeric_range_value_types[] = { +#define EZLOPI_VALUE_TYPE(type, name) name, +#include "ezlopi_core_scenes_value_types.h" +#undef EZLOPI_VALUE_TYPE +}; + +//------------------------------------------------- + /************* Numeric ************/ static const char* const ezlopi_scenes_num_cmp_operators_op[] = { #define SCENES_NUM_COMP_OPERATORS(OPERATOR, op, name, method) op, @@ -246,12 +262,26 @@ const char* ezlopi_scenes_strings_comparator_operators_get_method(e_scene_str_cm return ret; } +static char* ezlopi_scenes_laststr_comp(const char* haystack, const char* needle) +{ + char* loc = NULL; + char* found = NULL; + size_t pos = 0; + while ((found = strstr(haystack + pos, needle)) != 0) + { + loc = found; + pos = (found - haystack) + 1; + } + return loc; +} + int ezlopi_scenes_operators_value_strings_operations(uint32_t item_id, l_fields_v2_t* value_field, l_fields_v2_t* comparator_field) { int ret = 0; if (item_id && value_field && comparator_field) { - double item_value = 0.0; + char* item_value = NULL; + // int item_value_size = 0; cJSON* cj_item_value = cJSON_CreateObject(); l_ezlopi_device_t* device = ezlopi_device_get_head(); while (device) @@ -267,8 +297,10 @@ int ezlopi_scenes_operators_value_strings_operations(uint32_t item_id, l_fields_ cJSON* cj_value = cJSON_GetObjectItem(cj_item_value, ezlopi_value_str); if (cj_value) { - #warning "Krishna needs to complete this" - item_value = cj_value->valuedouble; + if (cJSON_IsString(cj_value)) + { + item_value = cJSON_GetStringValue(cj_value); + } } } @@ -279,89 +311,122 @@ int ezlopi_scenes_operators_value_strings_operations(uint32_t item_id, l_fields_ device = device->next; } - e_scene_str_cmp_operators_t string_operator = ezlopi_scenes_strings_comparator_operators_get_enum(comparator_field->field_value.u_value.value_string); - - switch (string_operator) - { - case SCENES_STRINGS_OPERATORS_LESS: - { - TRACE_W("'SCENES_STRINGS_OPERATORS_LESS' not implemented!"); - break; - } - case SCENES_STRINGS_OPERATORS_GREATER: - { - TRACE_W("'SCENES_STRINGS_OPERATORS_GREATER' not implemented!"); - break; - } - case SCENES_STRINGS_OPERATORS_LESS_EQUAL: - { - TRACE_W("'SCENES_STRINGS_OPERATORS_LESS_EQUAL' not implemented!"); - break; - } - case SCENES_STRINGS_OPERATORS_GREATER_EQUAL: - { - TRACE_W("'SCENES_STRINGS_OPERATORS_GREATER_EQUAL' not implemented!"); - break; - } - case SCENES_STRINGS_OPERATORS_EQUAL: - { - TRACE_W("'SCENES_STRINGS_OPERATORS_EQUAL' not implemented!"); - break; - } - case SCENES_STRINGS_OPERATORS_NOT_EQUAL: - { - TRACE_W("'SCENES_STRINGS_OPERATORS_NOT_EQUAL' not implemented!"); - break; - } - case SCENES_STRINGS_OPERATORS_BEGINS_WITH: + if (NULL != item_value) { - TRACE_W("'SCENES_STRINGS_OPERATORS_BEGINS_WITH' not implemented!"); - break; - } - case SCENES_STRINGS_OPERATORS_ENDS_WITH: - { - TRACE_W("'SCENES_STRINGS_OPERATORS_ENDS_WITH' not implemented!"); - break; - } - case SCENES_STRINGS_OPERATORS_CONTAINS: - { - TRACE_W("'SCENES_STRINGS_OPERATORS_CONTAINS' not implemented!"); - break; - } - case SCENES_STRINGS_OPERATORS_LENGTH: - { - TRACE_W("'SCENES_STRINGS_OPERATORS_LENGTH' not implemented!"); - break; - } - case SCENES_STRINGS_OPERATORS_NOT_BEGIN: - { - TRACE_W("'SCENES_STRINGS_OPERATORS_NOT_BEGIN' not implemented!"); - break; - } - case SCENES_STRINGS_OPERATORS_NOT_END: - { - TRACE_W("'SCENES_STRINGS_OPERATORS_NOT_END' not implemented!"); - break; - } - case SCENES_STRINGS_OPERATORS_NOT_CONTAIN: - { - TRACE_W("'SCENES_STRINGS_OPERATORS_NOT_CONTAIN' not implemented!"); - break; - } - case SCENES_STRINGS_OPERATORS_NOT_LENGTH: - { - TRACE_W("'SCENES_STRINGS_OPERATORS_NOT_LENGTH' not implemented!"); - break; - } - default: - { - TRACE_E("'SCENES_STRINGS_OPERATORS_* [%d]' out of range!", string_operator); - break; - } + e_scene_str_cmp_operators_t string_operator = ezlopi_scenes_strings_comparator_operators_get_enum(comparator_field->field_value.u_value.value_string); + switch (string_operator) + { + case SCENES_STRINGS_OPERATORS_LESS: + { + ret = STR_OP_COMP(item_value, < , value_field->field_value.u_value.value_string); + break; + } + case SCENES_STRINGS_OPERATORS_GREATER: + { + ret = STR_OP_COMP(item_value, > , value_field->field_value.u_value.value_string); + break; + } + case SCENES_STRINGS_OPERATORS_LESS_EQUAL: + { + ret = STR_OP_COMP(item_value, <= , value_field->field_value.u_value.value_string); + break; + } + case SCENES_STRINGS_OPERATORS_GREATER_EQUAL: + { + ret = STR_OP_COMP(item_value, >= , value_field->field_value.u_value.value_string); + break; + } + case SCENES_STRINGS_OPERATORS_EQUAL: + { + ret = STR_OP_COMP(item_value, == , value_field->field_value.u_value.value_string); + break; + } + case SCENES_STRINGS_OPERATORS_NOT_EQUAL: + { + ret = STR_OP_COMP(item_value, != , value_field->field_value.u_value.value_string); + break; + } + case SCENES_STRINGS_OPERATORS_BEGINS_WITH: + { + char* str_pos = strstr(item_value, value_field->field_value.u_value.value_string); // finds out the position of first occurance + if (str_pos) + { + int diff = (str_pos - item_value); + ret = (0 == diff) ? 1 : 0; + } + break; + } + case SCENES_STRINGS_OPERATORS_NOT_BEGIN: + { + char* str_pos = strstr(item_value, value_field->field_value.u_value.value_string); // finds out the position of first occurance + if (str_pos) + { + int diff = (str_pos - item_value); + ret = (0 < diff) ? 1 : 0; + } + break; + } + case SCENES_STRINGS_OPERATORS_CONTAINS: + { + char* str_pos = strstr(item_value, value_field->field_value.u_value.value_string); // finds out the position of first occurance + if (str_pos) + { + int diff = (str_pos - item_value); + ret = (diff <= 0) ? 1 : 0; + } + break; + } + case SCENES_STRINGS_OPERATORS_NOT_CONTAIN: + { + char* str_pos = strstr(item_value, value_field->field_value.u_value.value_string); // finds out the position of first occurance + if (NULL == str_pos) + { + ret = 1; + } + break; + } + case SCENES_STRINGS_OPERATORS_ENDS_WITH: + { + char* last = ezlopi_scenes_laststr_comp(item_value, value_field->field_value.u_value.value_string); // finds out the position of last occurance + if (NULL != last) + { + ret = (strlen(value_field->field_value.u_value.value_string) == strlen(last)) ? 1 : 0; + } + break; + } + case SCENES_STRINGS_OPERATORS_NOT_END: + { + char* last = ezlopi_scenes_laststr_comp(item_value, value_field->field_value.u_value.value_string); // finds out the position of last occurance + if (NULL != last) + { + ret = (strlen(value_field->field_value.u_value.value_string) != strlen(last)) ? 1 : 0; + } + break; + } + case SCENES_STRINGS_OPERATORS_LENGTH: + { + ret = (value_field->field_value.u_value.value_double == strlen(item_value)); // int value comparision + break; + } + case SCENES_STRINGS_OPERATORS_NOT_LENGTH: + { + ret = (value_field->field_value.u_value.value_double != strlen(item_value)); // int value comparision + break; + } + default: + { + TRACE_E("'SCENES_STRINGS_OPERATORS_* [%d]' out of range!", string_operator); + break; + } + } } if (cj_item_value) { + if (item_value) + { + free(item_value); + } cJSON_Delete(cj_item_value); } } @@ -369,80 +434,192 @@ int ezlopi_scenes_operators_value_strings_operations(uint32_t item_id, l_fields_ return ret; } -/************* Values with Less ************/ -static const char* const ezlopi_scenes_value_with_less_cmp_operators_op[] = { -#define SCENES_VALUES_WITH_LESS_OPERATORS(OPERATOR, op, name, method) op, -#include "__operators_macros/__value_with_less_comparision_operators_macros.h" -#undef SCENES_VALUES_WITH_LESS_OPERATORS +#if 0 +int ezlopi_scenes_operators_value_expn_strings_operations(uint32_t expression_id, l_fields_v2_t* expression_field, l_fields_v2_t* comparator_field) +{ + int ret = 0; + if (expression_id && expression_field && comparator_field) + { + size_t expression_name_len = strlen(expression_field->field_value.u_value.value_string); + char* expression_name = (expression_field->field_value.u_value.value_string); // get the expression_name + if (expression_name) + { + s_ezlopi_expressions_t* curr_expr = ezlopi_scenes_expressions_get_head(); + while (curr_expr) + { + // find value representing 'item_id/expression_id' and then compare with value pointed by 'expression_field->field_value.u_value.value_string' ? + + // size_t tmp_exp_name_len = strlen(curr_expr->name); + // size_t cmp_len = (expression_name_len > tmp_exp_name_len) ? expression_name_len : tmp_exp_name_len; + // if (STR_OP_COMPcurr_expr->name, expression_name, cmp_len)) + // { + // break; + // } + curr_expr = curr_expr->next; + } + + // + + e_scene_str_cmp_operators_t string_operator = ezlopi_scenes_strings_comparator_operators_get_enum(comparator_field->field_value.u_value.value_string); + + switch (string_operator) + { + case SCENES_STRINGS_OPERATORS_LESS: + { + ret = (STR_OP_COMP(expression_name, < , expression_field->val); + break; + } + case SCENES_STRINGS_OPERATORS_GREATER: + { + ret = (STR_OP_COMP(expression_name, > , expression_field->val); + break; + } + case SCENES_STRINGS_OPERATORS_LESS_EQUAL: + { + ret = (STR_OP_COMP(expression_name, <= , expression_field->val); + break; + } + case SCENES_STRINGS_OPERATORS_GREATER_EQUAL: + { + ret = (STR_OP_COMP(expression_name, >= , expression_field->val); + break; + } + case SCENES_STRINGS_OPERATORS_EQUAL: + { + ret = (STR_OP_COMP(expression_name, == , expression_field->val); + break; + } + case SCENES_STRINGS_OPERATORS_NOT_EQUAL: + { + ret = (STR_OP_COMP(expression_name, != , expression_field->val); + break; + } + case SCENES_STRINGS_OPERATORS_BEGINS_WITH: + { + TRACE_W("'SCENES_STRINGS_OPERATORS_BEGINS_WITH' not implemented!"); + break; + } + case SCENES_STRINGS_OPERATORS_ENDS_WITH: + { + TRACE_W("'SCENES_STRINGS_OPERATORS_ENDS_WITH' not implemented!"); + break; + } + case SCENES_STRINGS_OPERATORS_CONTAINS: + { + TRACE_W("'SCENES_STRINGS_OPERATORS_CONTAINS' not implemented!"); + break; + } + case SCENES_STRINGS_OPERATORS_NOT_BEGIN: + { + TRACE_W("'SCENES_STRINGS_OPERATORS_NOT_BEGIN' not implemented!"); + break; + } + case SCENES_STRINGS_OPERATORS_NOT_END: + { + TRACE_W("'SCENES_STRINGS_OPERATORS_NOT_END' not implemented!"); + break; + } + case SCENES_STRINGS_OPERATORS_NOT_CONTAIN: + { + TRACE_W("'SCENES_STRINGS_OPERATORS_NOT_CONTAIN' not implemented!"); + break; + } + case SCENES_STRINGS_OPERATORS_LENGTH: + { + TRACE_W("'SCENES_STRINGS_OPERATORS_LENGTH' not implemented!"); // int comparision + break; + } + case SCENES_STRINGS_OPERATORS_NOT_LENGTH: + { + TRACE_W("'SCENES_STRINGS_OPERATORS_NOT_LENGTH' not implemented!"); // int comparision + break; + } + default: + { + TRACE_E("'SCENES_STRINGS_OPERATORS_* [%d]' out of range!", string_operator); + break; + } + } + } + } + + return ret; +} +#endif + +/************* Values in_array ************/ +static const char* const ezlopi_scenes_inarr_cmp_operators_op[] = { +#define SCENES_IN_ARRAY_OPERATORS(OPERATOR, op, name, method) op, +#include "__operators_macros/__in_array_comparision_operators_macros.h" +#undef SCENES_IN_ARRAY_OPERATORS }; -static const char* const ezlopi_scenes_value_with_less_cmp_operators_name[] = { -#define SCENES_VALUES_WITH_LESS_OPERATORS(OPERATOR, op, name, method) name, -#include "__operators_macros/__value_with_less_comparision_operators_macros.h" -#undef SCENES_VALUES_WITH_LESS_OPERATORS +static const char* const ezlopi_scenes_inarr_cmp_operators_name[] = { +#define SCENES_IN_ARRAY_OPERATORS(OPERATOR, op, name, method) name, +#include "__operators_macros/__in_array_comparision_operators_macros.h" +#undef SCENES_IN_ARRAY_OPERATORS }; -static const char* const ezlopi_scenes_value_with_less_cmp_operators_method[] = { -#define SCENES_VALUES_WITH_LESS_OPERATORS(OPERATOR, op, name, method) method, -#include "__operators_macros/__value_with_less_comparision_operators_macros.h" -#undef SCENES_VALUES_WITH_LESS_OPERATORS +static const char* const ezlopi_scenes_inarr_cmp_operators_method[] = { +#define SCENES_IN_ARRAY_OPERATORS(OPERATOR, op, name, method) method, +#include "__operators_macros/__in_array_comparision_operators_macros.h" +#undef SCENES_IN_ARRAY_OPERATORS }; -e_scene_value_with_less_cmp_operators_t ezlopi_scenes_value_with_less_comparator_operators_get_enum(char* operator_str) +e_scene_inarr_cmp_operators_t ezlopi_scenes_inarr_comparator_operators_get_enum(char* operator_inarr) { - e_scene_value_with_less_cmp_operators_t ret = SCENES_VALUES_WITH_LESS_OPERATORS_NONE + 1; - if (operator_str) + e_scene_inarr_cmp_operators_t ret = SCENES_IN_ARRAY_OPERATORS_NONE + 1; + if (operator_inarr) { - while ((ret <= SCENES_VALUES_WITH_LESS_OPERATORS_MAX) && ezlopi_scenes_value_with_less_cmp_operators_op[ret]) + while ((ret <= SCENES_IN_ARRAY_OPERATORS_MAX) && ezlopi_scenes_inarr_cmp_operators_op[ret]) { - if (0 == strcmp(ezlopi_scenes_value_with_less_cmp_operators_op[ret], operator_str)) + if (0 == strcmp(ezlopi_scenes_inarr_cmp_operators_op[ret], operator_inarr)) { break; } - ret++; } } - return ret; } -const char* ezlopi_scenes_value_with_less_comparator_operators_get_op(e_scene_value_with_less_cmp_operators_t operator) +const char* ezlopi_scenes_inarr_comparator_operators_get_op(e_scene_inarr_cmp_operators_t operator) { const char* ret = NULL; - if ((operator>= SCENES_VALUES_WITH_LESS_OPERATORS_NONE) && (operator= SCENES_IN_ARRAY_OPERATORS_NONE) && (operator SCENES_VALUES_WITH_LESS_OPERATORS_NONE) && (operator= SCENES_IN_ARRAY_OPERATORS_NONE) && (operator SCENES_VALUES_WITH_LESS_OPERATORS_NONE) && (operator= SCENES_IN_ARRAY_OPERATORS_NONE) && (operatorvaluedouble; + if (cJSON_IsString(cj_value)) + { + item_value = cJSON_GetStringValue(cj_value); + } } } @@ -470,20 +649,244 @@ int ezlopi_scenes_operators_value_with_less_operations(uint32_t item_id, l_field device = device->next; } - e_scene_value_with_less_cmp_operators_t value_with_less_operator = ezlopi_scenes_value_with_less_comparator_operators_get_enum(comparator_field->field_value.u_value.value_string); - - switch (value_with_less_operator) - { - case SCENES_VALUES_WITH_LESS_OPERATORS_LESS: + if (NULL != item_value) { - TRACE_W("'SCENES_VALUES_WITH_LESS_OPERATORS_LESS' not implemented!"); - break; + cJSON* iterator = NULL; + char* op_str = (NULL == operation_field) ? "in" : operation_field->field_value.u_value.value_string; + e_scene_str_cmp_operators_t string_operator = ezlopi_scenes_inarr_comparator_operators_get_enum(op_str); + switch (string_operator) + { + case SCENES_IN_ARRAY_OPERATORS_IN: + { + cJSON_ArrayForEach(iterator, value_field->field_value.u_value.cj_value) + { + if (cJSON_IsString(iterator)) + { + const char* string_item = cJSON_GetStringValue(iterator); + if (NULL != string_item) + { + if (STR_OP_COMP(item_value, == , string_item)) // check for all array elements ; if exists then break + { + ret = 1; + break; + } + } + } + } + break; + } + case SCENES_IN_ARRAY_OPERATORS_NOT_IN: + { + // iterate through the array elements + cJSON_ArrayForEach(iterator, value_field->field_value.u_value.cj_value) + { + if (cJSON_IsString(iterator)) + { + const char* string_item = cJSON_GetStringValue(iterator); + if (NULL != string_item) + { + if (STR_OP_COMP(item_value, == , string_item)) // check for all array elements ; if exists then break + { + ret = 0; + break; + } + else + { + ret = 1; + } + } + } + } + break; + } + + default: + { + TRACE_E("'SCENES_IN_ARRAY_OPERATORS_* [%d]' out of range!", string_operator); + break; + } + } } - case SCENES_VALUES_WITH_LESS_OPERATORS_GREATER: + + if (cj_item_value) { - TRACE_W("'SCENES_VALUES_WITH_LESS_OPERATORS_GREATER' not implemented!"); - break; - } + if (item_value) + { + free(item_value); + } + cJSON_Delete(cj_item_value); + } + } + + return ret; +} +#if 0 +int ezlopi_scenes_operators_value_expn_inarr_operations(uint32_t expression_id, l_fields_v2_t* expression_field, l_fields_v2_t* operation_field) +{ + int ret = 0; + if (expression_id && expression_field && operation_field) + { + size_t expression_name_len = strlen(expression_field->field_value.u_value.value_string); + char* expression_name = (expression_field->field_value.u_value.value_string); // get the expression_name + if (expression_name) + { + s_ezlopi_expressions_t* curr_expr = ezlopi_scenes_expressions_get_head(); + while (curr_expr) + { + // find value representing 'item_id/expression_id' and then compare with value pointed by 'expression_field->field_value.u_value.value_string' ? + + // if (STR_OP_COMP(curr_expr->name,==, expression_name)) // "string != NULL" + // { + // break; + // } + curr_expr = curr_expr->next; + } + + // + + e_scene_str_cmp_operators_t string_operator = ezlopi_scenes_inarr_comparator_operators_get_enum(operation_field->field_value.u_value.value_string); + + switch (string_operator) + { + case SCENES_STRINGS_OPERATORS_CONTAINS: + { + TRACE_W("'SCENES_STRINGS_OPERATORS_CONTAINS' not implemented!"); + break; + } + case SCENES_STRINGS_OPERATORS_NOT_CONTAIN: + { + TRACE_W("'SCENES_STRINGS_OPERATORS_NOT_CONTAIN' not implemented!"); + break; + } + default: + { + TRACE_E("'SCENES_STRINGS_OPERATORS_* [%d]' out of range!", string_operator); + break; + } + } + } + } + + return ret; +} +#endif + +/************* Values with Less ************/ + +static const char* const ezlopi_scenes_value_with_less_cmp_operators_op[] = { +#define SCENES_VALUES_WITH_LESS_OPERATORS(OPERATOR, op, name, method) op, +#include "__operators_macros/__value_with_less_comparision_operators_macros.h" +#undef SCENES_VALUES_WITH_LESS_OPERATORS +}; + +static const char* const ezlopi_scenes_value_with_less_cmp_operators_name[] = { +#define SCENES_VALUES_WITH_LESS_OPERATORS(OPERATOR, op, name, method) name, +#include "__operators_macros/__value_with_less_comparision_operators_macros.h" +#undef SCENES_VALUES_WITH_LESS_OPERATORS +}; + +static const char* const ezlopi_scenes_value_with_less_cmp_operators_method[] = { +#define SCENES_VALUES_WITH_LESS_OPERATORS(OPERATOR, op, name, method) method, +#include "__operators_macros/__value_with_less_comparision_operators_macros.h" +#undef SCENES_VALUES_WITH_LESS_OPERATORS +}; + +e_scene_value_with_less_cmp_operators_t ezlopi_scenes_value_with_less_comparator_operators_get_enum(char* operator_str) +{ + e_scene_value_with_less_cmp_operators_t ret = SCENES_VALUES_WITH_LESS_OPERATORS_NONE + 1; + if (operator_str) + { + while ((ret <= SCENES_VALUES_WITH_LESS_OPERATORS_MAX) && ezlopi_scenes_value_with_less_cmp_operators_op[ret]) + { + if (0 == strcmp(ezlopi_scenes_value_with_less_cmp_operators_op[ret], operator_str)) + { + break; + } + + ret++; + } + } + + return ret; +} + +const char* ezlopi_scenes_value_with_less_comparator_operators_get_op(e_scene_value_with_less_cmp_operators_t operator) +{ + const char* ret = NULL; + if ((operator>= SCENES_VALUES_WITH_LESS_OPERATORS_NONE) && (operator SCENES_VALUES_WITH_LESS_OPERATORS_NONE) && (operator SCENES_VALUES_WITH_LESS_OPERATORS_NONE) && (operatoritems; + while (item) + { + if (item->cloud_properties.item_id == item_id) + { + if (cj_item_value) + { + item->func(EZLOPI_ACTION_GET_EZLOPI_VALUE, item, (void*)cj_item_value, NULL); + cJSON* cj_value = cJSON_GetObjectItem(cj_item_value, ezlopi_value_str); + if (cj_value) + { + #warning "Krishna needs to complete this" + item_value = cj_value->valuedouble; + } + } + + break; + } + item = item->next; + } + device = device->next; + } + + e_scene_value_with_less_cmp_operators_t value_with_less_operator = ezlopi_scenes_value_with_less_comparator_operators_get_enum(comparator_field->field_value.u_value.value_string); + + switch (value_with_less_operator) + { + case SCENES_VALUES_WITH_LESS_OPERATORS_LESS: + { + TRACE_W("'SCENES_VALUES_WITH_LESS_OPERATORS_LESS' not implemented!"); + break; + } + case SCENES_VALUES_WITH_LESS_OPERATORS_GREATER: + { + TRACE_W("'SCENES_VALUES_WITH_LESS_OPERATORS_GREATER' not implemented!"); + break; + } case SCENES_VALUES_WITH_LESS_OPERATORS_LESS_EQUAL: { TRACE_W("'SCENES_VALUES_WITH_LESS_OPERATORS_LESS_EQUAL' not implemented!"); @@ -519,8 +922,9 @@ int ezlopi_scenes_operators_value_with_less_operations(uint32_t item_id, l_field return ret; } - +#endif /************* Values without less ************/ + static const char* const ezlopi_scenes_value_without_less_cmp_operators_op[] = { #define SCENES_VALUES_WITHOUT_LESS_OPERATORS(OPERATOR, op, name, method) op, #include "__operators_macros/__value_without_less_comparision_operators_macros.h" @@ -587,7 +991,7 @@ const char* ezlopi_scenes_value_without_less_comparator_operators_get_method(e_s } return ret; } - +#if 0 int ezlopi_scenes_operators_value_without_less_operations(uint32_t item_id, l_fields_v2_t* value_field, l_fields_v2_t* comparator_field) { int ret = 0; @@ -652,3 +1056,507 @@ int ezlopi_scenes_operators_value_without_less_operations(uint32_t item_id, l_fi return ret; } +#endif +/************* compareValues ************/ + +int ezlopi_scenes_operators_value_comparevalues_without_less_operations(uint32_t item_id, l_fields_v2_t* value_field, l_fields_v2_t* value_type_field, l_fields_v2_t* comparator_field) +{ + int ret = 0; + if (item_id && value_field && value_type_field && comparator_field) + { + cJSON* item_value = NULL; + + cJSON* cj_item_value = cJSON_CreateObject(); + l_ezlopi_device_t* device = ezlopi_device_get_head(); + while (device) + { + l_ezlopi_item_t* item = device->items; + while (item) + { + if (item->cloud_properties.item_id == item_id) + { + if (STR_OP_COMP(value_type_field->field_value.u_value.value_string, == , item->cloud_properties.value_type)) // bool == bool? + { + if (cj_item_value) + { + item->func(EZLOPI_ACTION_GET_EZLOPI_VALUE, item, (void*)cj_item_value, NULL); + item_value = cJSON_GetObjectItem(cj_item_value, ezlopi_value_str); // eg. double_type : 5.005 or string_type : "5.005" + } + } + else + { + ret = 0; // SCENES_WHEN_TYPE_MISMATCH error + } + break; + } + item = item->next; + } + device = device->next; + } + + if (NULL != item_value) + { // operating according to 'with-less or without-less' comparator + char* op_str = (NULL == comparator_field) ? "==" : comparator_field->field_value.u_value.value_string; + e_scene_value_without_less_cmp_operators_t value_without_less_operator = ezlopi_scenes_value_without_less_comparator_operators_get_enum(op_str); + + switch (value_without_less_operator) + { + case SCENES_VALUES_WITHOUT_LESS_OPERATORS_EQUAL: + { + + ret = ((item_value->type == cJSON_True) ? (true == value_field->field_value.u_value.value_bool) + : (item_value->type == cJSON_False) ? (false == value_field->field_value.u_value.value_bool) + : (item_value->type == cJSON_Number) ? (item_value->valuedouble == value_field->field_value.u_value.value_double) + : (item_value->type == cJSON_String) ? STR_OP_COMP(item_value->valuestring, == , value_field->field_value.u_value.value_string) + : 0); + + break; + } + case SCENES_VALUES_WITHOUT_LESS_OPERATORS_NOT_EQUAL: + { + + ret = ((item_value->type == cJSON_True) ? (true != value_field->field_value.u_value.value_bool) + : (item_value->type == cJSON_False) ? (false != value_field->field_value.u_value.value_bool) + : (item_value->type == cJSON_Number) ? (item_value->valuedouble != value_field->field_value.u_value.value_double) + : (item_value->type == cJSON_String) ? STR_OP_COMP(item_value->valuestring, != , value_field->field_value.u_value.value_string) + : 0); + + break; + } + + default: + { + TRACE_E("'SCENES_VALUES_WITHOUT_LESS_OPERATORS_* [%d]' out of range!", value_without_less_operator); + break; + } + } + } + + if (cj_item_value) + { + cJSON_Delete(cj_item_value); + } + } + + return ret; +} + +int ezlopi_scenes_operators_value_comparevalues_with_less_operations(uint32_t item_id, l_fields_v2_t* value_field, l_fields_v2_t* value_type_field, l_fields_v2_t* comparator_field) +{ + int ret = 0; + if (item_id && value_field && value_type_field && comparator_field) + { + cJSON* item_value = NULL; + + cJSON* cj_item_value = cJSON_CreateObject(); + l_ezlopi_device_t* device = ezlopi_device_get_head(); + while (device) + { + l_ezlopi_item_t* item = device->items; + while (item) + { + if (item->cloud_properties.item_id == item_id) // unique + { + if (STR_OP_COMP(value_type_field->field_value.u_value.value_string, == , item->cloud_properties.value_type)) // bool == bool? + { + if (cj_item_value) + { + item->func(EZLOPI_ACTION_GET_EZLOPI_VALUE, item, (void*)cj_item_value, NULL); + item_value = cJSON_GetObjectItem(cj_item_value, ezlopi_value_str); // "5.0" + } + } + else + { + ret = 0; // SCENES_WHEN_TYPE_MISMATCH error + } + break; + } + item = item->next; + } + device = device->next; + } + + if (NULL != item_value) + { // operating according to 'with-less or without-less' comparator + + char* op_str = (NULL == comparator_field) ? "==" : comparator_field->field_value.u_value.value_string; + e_scene_value_with_less_cmp_operators_t value_with_less_operator = ezlopi_scenes_value_with_less_comparator_operators_get_enum(op_str); + + switch (value_with_less_operator) + { + + case SCENES_VALUES_WITH_LESS_OPERATORS_LESS: + { + ret = ((item_value->type == cJSON_Number) ? (item_value->valuedouble < value_field->field_value.u_value.value_double) + : (item_value->type == cJSON_String) ? STR_OP_COMP(item_value->valuestring, < , value_field->field_value.u_value.value_string) + : 0); + if (0 == ret) + { + TRACE_E("Value type mis-matched!"); + } + break; + } + case SCENES_VALUES_WITH_LESS_OPERATORS_GREATER: + { + ret = ((item_value->type == cJSON_Number) ? (item_value->valuedouble > value_field->field_value.u_value.value_double) + : (item_value->type == cJSON_String) ? STR_OP_COMP(item_value->valuestring, > , value_field->field_value.u_value.value_string) + : 0); + if (0 == ret) + { + TRACE_E("Value type mis-matched!"); + } + + break; + } + case SCENES_VALUES_WITH_LESS_OPERATORS_LESS_EQUAL: + { + ret = ((item_value->type == cJSON_Number) ? (item_value->valuedouble <= value_field->field_value.u_value.value_double) + : (item_value->type == cJSON_String) ? STR_OP_COMP(item_value->valuestring, <= , value_field->field_value.u_value.value_string) + : 0); + if (0 == ret) + { + TRACE_E("Value type mis-matched!"); + } + + break; + } + case SCENES_VALUES_WITH_LESS_OPERATORS_GREATER_EQUAL: + { + ret = ((item_value->type == cJSON_Number) ? (item_value->valuedouble >= value_field->field_value.u_value.value_double) + : (item_value->type == cJSON_String) ? STR_OP_COMP(item_value->valuestring, >= , value_field->field_value.u_value.value_string) + : 0); + if (0 == ret) + { + TRACE_E("Value type mis-matched!"); + } + + break; + } + + case SCENES_VALUES_WITH_LESS_OPERATORS_EQUAL: + { + ret = ((item_value->type == cJSON_True) ? (true == value_field->field_value.u_value.value_bool) + : (item_value->type == cJSON_False) ? (false == value_field->field_value.u_value.value_bool) + : (item_value->type == cJSON_Number) ? (item_value->valuedouble == value_field->field_value.u_value.value_double) + : (item_value->type == cJSON_String) ? STR_OP_COMP(item_value->valuestring, == , value_field->field_value.u_value.value_string) + : 0); + if (0 == ret) + { + TRACE_E("Value type mis-matched!"); + } + + break; + } + + case SCENES_VALUES_WITH_LESS_OPERATORS_NOT_EQUAL: + { + ret = ((item_value->type == cJSON_True) ? (true != value_field->field_value.u_value.value_bool) + : (item_value->type == cJSON_False) ? (false != value_field->field_value.u_value.value_bool) + : (item_value->type == cJSON_Number) ? (item_value->valuedouble != value_field->field_value.u_value.value_double) + : (item_value->type == cJSON_String) ? STR_OP_COMP(item_value->valuestring, != , value_field->field_value.u_value.value_string) + : 0); + if (0 == ret) + { + TRACE_E("Value type mis-matched!"); + } + + break; + } + default: + { + TRACE_E("'SCENES_VALUES_WITH_LESS_OPERATORS_* [%d]' out of range!", value_with_less_operator); + break; + } + } + } + + if (cj_item_value) + { + cJSON_Delete(cj_item_value); + } + } + + return ret; +} + +/************* NUMERIC RANGE *************/ +int ezlopi_scenes_operators_value_number_range_operations(uint32_t item_id, l_fields_v2_t* start_value_field, l_fields_v2_t* end_value_field, l_fields_v2_t* comparator_field) +{ + int ret = 0; + if (item_id && start_value_field && end_value_field) + { + cJSON* item_value = NULL; + cJSON* cj_item_value = cJSON_CreateObject(); + l_ezlopi_device_t* device = ezlopi_device_get_head(); + while (device) + { + l_ezlopi_item_t* item = device->items; + while (item) + { + if (item->cloud_properties.item_id == item_id) // find the correct " item " within the device + { + if (cj_item_value) + { + item->func(EZLOPI_ACTION_GET_EZLOPI_VALUE, item, (void*)cj_item_value, NULL); + cJSON* item_valuetype = cJSON_GetObjectItem(cj_item_value, ezlopi_valueType_str); + const char* str_item_type = NULL; + if (item_valuetype && cJSON_IsString(item_valuetype) && (NULL != (str_item_type = cJSON_GetStringValue(item_valuetype)))) + { + const char* tmp_valuetype = ""; + if ((start_value_field->value_type > EZLOPI_VALUE_TYPE_NONE) && (start_value_field->value_type < EZLOPI_VALUE_TYPE_MAX)) + { + tmp_valuetype = ezlopi_scenes_value_numeric_range_value_types[start_value_field->value_type]; // bool ? token ? int ? + } + if (STR_OP_COMP(tmp_valuetype, == , str_item_type)) // 'int' == 'int'? + { + //now check if scale matches + cJSON* item_scale = cJSON_GetObjectItem(cj_item_value, ezlopi_scale_str); + const char* str_scale_tmp = NULL; + if (item_scale && cJSON_IsString(item_scale) && (NULL != (str_scale_tmp = cJSON_GetStringValue(item_scale)))) + { + if (STR_OP_COMP(start_value_field->scale, == , str_scale_tmp)) // 'NULL' == 'NULL' + { + cJSON* cj_value = cJSON_GetObjectItem(cj_item_value, ezlopi_value_str); // extract the value from " item " within the device + if (cj_value) + { // extract the item_value ; + item_value = cj_value; // here the value maybe (int , float , string , bool) + } + } + else + { + TRACE_E("Scale didnot match.."); + } + } + } + } + } + break; + } + item = item->next; + } + device = device->next; + } + + if (NULL != item_value) + { + char* op_str = (NULL == comparator_field) ? "between" : comparator_field->field_value.u_value.value_string; + + switch (ezlopi_scenes_numeric_comparator_operators_get_enum(op_str)) + { + + case SCENES_NUM_COMP_OPERATORS_BETWEEN: + { + if (item_value->type == cJSON_Number) + { + ret = ((item_value->valuedouble >= start_value_field->field_value.u_value.value_double) && + (item_value->valuedouble <= end_value_field->field_value.u_value.value_double)) + ? 1 + : 0; + } + else if (item_value->type == cJSON_String) + { + ret = ((STR_OP_COMP(item_value->valuestring, >= , start_value_field->field_value.u_value.value_string)) && + (STR_OP_COMP(item_value->valuestring, <= , end_value_field->field_value.u_value.value_string))) + ? 1 + : 0; + } + else + { + TRACE_E("Value type mis-matched!"); + } + break; + } + case SCENES_NUM_COMP_OPERATORS_NOT_BETWEEN: + { + if (item_value->type == cJSON_Number) + { + ret = ((item_value->valuedouble < start_value_field->field_value.u_value.value_double) && + (item_value->valuedouble > end_value_field->field_value.u_value.value_double)) + ? 1 + : 0; + } + else if (item_value->type == cJSON_String) + { + ret = ((STR_OP_COMP(item_value->valuestring, < , start_value_field->field_value.u_value.value_string)) && + (STR_OP_COMP(item_value->valuestring, > , end_value_field->field_value.u_value.value_string))) + ? 1 + : 0; + } + else + { + TRACE_E("Value type mis-matched!"); + } + break; + } + + default: + { + break; + } + } + } + if (cj_item_value) + { + cJSON_Delete(cj_item_value); + } + } + + return ret; +} + +/************* Has atleast one dictornary Value *************/ +int ezlopi_scenes_operators_has_atleastone_dictionary_value_operations(uint32_t item_id, l_fields_v2_t* value_field) +{ + int ret = 0; + if (item_id && value_field) + { + cJSON* item_value = NULL; + cJSON* cj_item_value = cJSON_CreateObject(); + l_ezlopi_device_t* device = ezlopi_device_get_head(); + while (device) + { + l_ezlopi_item_t* item = device->items; + while (item) + { + if (item->cloud_properties.item_id == item_id) + { + if (cj_item_value) + { + item->func(EZLOPI_ACTION_GET_EZLOPI_VALUE, item, (void*)cj_item_value, NULL); + cJSON* cj_valuetype = cJSON_GetObjectItem(cj_item_value, ezlopi_valueType_str); // first check the item_type -> 'valueType' + const char* str_item_type = NULL; + if (cj_valuetype && cJSON_IsString(cj_valuetype) && (NULL != (str_item_type = cJSON_GetStringValue(cj_valuetype)))) // type => dictionary + { + // " ezlopi_cloud_value_type_str.c " + + // const char *str_item_type = ""; + // if ((value_field->value_type > EZLOPI_VALUE_TYPE_NONE) && (value_field->value_type < EZLOPI_VALUE_TYPE_MAX)) + // { + // str_item_type = ezlopi_scenes_value_numeric_range_value_types[value_field->value_type]; // must return "dictionary" + // } + + if (STR_OP_COMP("dictionary", == , str_item_type)) // 'dictionary' == 'dictionary'? + { + cJSON* cj_value = cJSON_GetObjectItem(cj_item_value, ezlopi_value_str); // item_value -> dictionary ; [array or object] + if (cj_value) + { + item_value = cj_value; + } + } + } + } + + break; + } + item = item->next; + } + device = device->next; + } + + if (NULL != item_value) + { + if (cJSON_IsObject(item_value)) + { + // Check if ["value":"low_battery"] key is present + cJSON* dictionaryValue = cJSON_GetObjectItem(item_value, value_field->field_value.u_value.value_string); + if (NULL != dictionaryValue) // if the "eg. low_battery" element exists within the dictionary + { + ret = 1; + } + } + } + if (cj_item_value) + { + cJSON_Delete(cj_item_value); + } + } + + return ret; +} + +/************* isDictornary Changed *************/ +int ezlopi_scenes_operators_is_dictionary_changed_operations(l_scenes_list_v2_t* scene_node, uint32_t item_id, l_fields_v2_t* key_field, l_fields_v2_t* operation_field) +{ + int ret = 0; + if (item_id && key_field && operation_field) + { + cJSON* item_value = NULL; + cJSON* cj_item_value = cJSON_CreateObject(); + + l_ezlopi_device_t* device = ezlopi_device_get_head(); + while (device) + { + l_ezlopi_item_t* item = device->items; + while (item) + { + if (item->cloud_properties.item_id == item_id) + { + if (cj_item_value) + { + item->func(EZLOPI_ACTION_GET_EZLOPI_VALUE, item, (void*)cj_item_value, NULL); + cJSON* cj_valuetype = cJSON_GetObjectItem(cj_item_value, ezlopi_valueType_str); // first check the item_type -> 'valueType' + const char* str_item_type = NULL; + if (cj_valuetype && cJSON_IsString(cj_valuetype) && (NULL != (str_item_type = cJSON_GetStringValue(cj_valuetype)))) // type => dictionary + { + if (STR_OP_COMP("dictionary", == , str_item_type)) // 'dictionary' == 'dictionary'? + { + cJSON* cj_value = cJSON_GetObjectItem(cj_item_value, ezlopi_value_str); // item_value -> dictionary ; [array or object] + if (cj_value) + { + item_value = cj_value; + } + } + } + } + + break; + } + item = item->next; + } + device = device->next; + } + + if (NULL != item_value) + { + if (cJSON_IsObject(item_value)) // c + { + if (0 == strncmp("added", operation_field->field_value.u_value.value_string, 6)) + { + // Check if ["key":"key_1"] key is present + cJSON* dictionaryValue = cJSON_GetObjectItem(item_value, key_field->field_value.u_value.value_string); + if (NULL != dictionaryValue) // if the "eg. key_1" element exists within the dictionary + { + ret = 1; + } + } + else if (0 == strncmp("removed", operation_field->field_value.u_value.value_string, 8)) + { + // Check if ["key":"key_1"] key is absent + cJSON* dictionaryValue = cJSON_GetObjectItem(item_value, key_field->field_value.u_value.value_string); + if (NULL == dictionaryValue) // if the "eg. key_1" element exists within the dictionary + { + ret = 1; + } + } + else if (0 == strncmp("updated", operation_field->field_value.u_value.value_string, 8)) + { + // Check if ["key":"key_1"] key is present and its elemnt + cJSON* dictionaryValue = cJSON_GetObjectItem(item_value, key_field->field_value.u_value.value_string); + if (NULL != dictionaryValue) // if the "eg. key_1" element exists within the dictionary + { + cJSON* last_dictionary_item = (cJSON*)scene_node->when_block->fields->user_arg; + ret = cJSON_Compare(last_dictionary_item, item_value, 0); + } + } + + // if the item exists ; Store current item_value into 'scene_node->when_block->fields->user_arg' + scene_node->when_block->fields->user_arg = (void*)item_value; + } + } + if (cj_item_value) + { + cJSON_Delete(cj_item_value); + } + } + return ret; +} \ No newline at end of file diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_operators.h b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_operators.h index d983af693..39c9868cf 100755 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_operators.h +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_operators.h @@ -2,6 +2,7 @@ #define _EZLOPI_CORE_SCENES_OPERATORS_H_ #include +#include #include "ezlopi_core_scenes_v2.h" @@ -19,6 +20,13 @@ typedef enum e_scene_str_cmp_operators #undef SCENES_STRINGS_OPERATORS } e_scene_str_cmp_operators_t; +typedef enum e_scene_inarr_cmp_operators +{ +#define SCENES_IN_ARRAY_OPERATORS(OPERATOR, op, name, method) SCENES_IN_ARRAY_OPERATORS_##OPERATOR, +#include "__operators_macros/__in_array_comparision_operators_macros.h" +#undef SCENES_IN_ARRAY_OPERATORS +} e_scene_inarr_cmp_operators_t; + typedef enum e_scene_value_with_less_cmp_operators { #define SCENES_VALUES_WITH_LESS_OPERATORS(OPERATOR, op, name, method) SCENES_VALUES_WITH_LESS_OPERATORS_##OPERATOR, @@ -34,35 +42,57 @@ typedef enum e_scene_value_without_less_cmp_operators } e_scene_value_without_less_cmp_operators_t; // Numeric Operators -e_scene_num_cmp_operators_t ezlopi_scenes_numeric_comparator_operators_get_enum(char *operator_str); -const char *ezlopi_scenes_numeric_comparator_operators_get_op(e_scene_num_cmp_operators_t operator); -const char *ezlopi_scenes_numeric_comparator_operators_get_name(e_scene_num_cmp_operators_t operator); -const char *ezlopi_scenes_numeric_comparator_operators_get_method(e_scene_num_cmp_operators_t operator); +e_scene_num_cmp_operators_t ezlopi_scenes_numeric_comparator_operators_get_enum(char* operator_str); +const char* ezlopi_scenes_numeric_comparator_operators_get_op(e_scene_num_cmp_operators_t operator); +const char* ezlopi_scenes_numeric_comparator_operators_get_name(e_scene_num_cmp_operators_t operator); +const char* ezlopi_scenes_numeric_comparator_operators_get_method(e_scene_num_cmp_operators_t operator); -int ezlopi_scenes_operators_value_number_operations(uint32_t item_id, l_fields_v2_t *value_field, l_fields_v2_t *comparator_field); +int ezlopi_scenes_operators_value_number_operations(uint32_t item_id, l_fields_v2_t* value_field, l_fields_v2_t* comparator_field); // Strings Operators -e_scene_str_cmp_operators_t ezlopi_scenes_strings_comparator_operators_get_enum(char *operator_str); -const char *ezlopi_scenes_strings_comparator_operators_get_op(e_scene_str_cmp_operators_t operator); -const char *ezlopi_scenes_strings_comparator_operators_get_name(e_scene_str_cmp_operators_t operator); -const char *ezlopi_scenes_strings_comparator_operators_get_method(e_scene_str_cmp_operators_t operator); +e_scene_str_cmp_operators_t ezlopi_scenes_strings_comparator_operators_get_enum(char* operator_str); +const char* ezlopi_scenes_strings_comparator_operators_get_op(e_scene_str_cmp_operators_t operator); +const char* ezlopi_scenes_strings_comparator_operators_get_name(e_scene_str_cmp_operators_t operator); +const char* ezlopi_scenes_strings_comparator_operators_get_method(e_scene_str_cmp_operators_t operator); + +int ezlopi_scenes_operators_value_strings_operations(uint32_t item_id, l_fields_v2_t* value_field, l_fields_v2_t* comparator_field); +// int ezlopi_scenes_operators_value_expn_strings_operations(uint32_t item_id, l_fields_v2_t *value_field, l_fields_v2_t *comparator_field); + +// InArray Operators +e_scene_inarr_cmp_operators_t ezlopi_scenes_inarr_comparator_operators_get_enum(char* operator_inarr); +const char* ezlopi_scenes_inarr_comparator_operators_get_op(e_scene_inarr_cmp_operators_t operator); +const char* ezlopi_scenes_inarr_comparator_operators_get_name(e_scene_inarr_cmp_operators_t operator); +const char* ezlopi_scenes_inarr_comparator_operators_get_method(e_scene_inarr_cmp_operators_t operator); -int ezlopi_scenes_operators_value_strings_operations(uint32_t item_id, l_fields_v2_t *value_field, l_fields_v2_t *comparator_field); +int ezlopi_scenes_operators_value_inarr_operations(uint32_t item_id, l_fields_v2_t* value_field, l_fields_v2_t* comparator_field); +// int ezlopi_scenes_operators_value_expn_inarr_operations(uint32_t item_id, l_fields_v2_t *value_field, l_fields_v2_t *comparator_field); // Value with less Operators -e_scene_value_with_less_cmp_operators_t ezlopi_scenes_value_with_less_comparator_operators_get_enum(char *operator_str); -const char *ezlopi_scenes_value_with_less_comparator_operators_get_op(e_scene_value_with_less_cmp_operators_t operator); -const char *ezlopi_scenes_value_with_less_comparator_operators_get_name(e_scene_value_with_less_cmp_operators_t operator); -const char *ezlopi_scenes_value_with_less_comparator_operators_get_method(e_scene_value_with_less_cmp_operators_t operator); +e_scene_value_with_less_cmp_operators_t ezlopi_scenes_value_with_less_comparator_operators_get_enum(char* operator_str); +const char* ezlopi_scenes_value_with_less_comparator_operators_get_op(e_scene_value_with_less_cmp_operators_t operator); +const char* ezlopi_scenes_value_with_less_comparator_operators_get_name(e_scene_value_with_less_cmp_operators_t operator); +const char* ezlopi_scenes_value_with_less_comparator_operators_get_method(e_scene_value_with_less_cmp_operators_t operator); -int ezlopi_scenes_operators_value_with_less_operations(uint32_t item_id, l_fields_v2_t *value_field, l_fields_v2_t *comparator_field); +int ezlopi_scenes_operators_value_with_less_operations(uint32_t item_id, l_fields_v2_t* value_field, l_fields_v2_t* comparator_field); // Value without less Operators -e_scene_value_without_less_cmp_operators_t ezlopi_scenes_value_without_less_comparator_operators_get_enum(char *operator_str); -const char *ezlopi_scenes_value_without_less_comparator_operators_get_op(e_scene_value_without_less_cmp_operators_t operator); -const char *ezlopi_scenes_value_without_less_comparator_operators_get_name(e_scene_value_without_less_cmp_operators_t operator); -const char *ezlopi_scenes_value_without_less_comparator_operators_get_method(e_scene_value_without_less_cmp_operators_t operator); +e_scene_value_without_less_cmp_operators_t ezlopi_scenes_value_without_less_comparator_operators_get_enum(char* operator_str); +const char* ezlopi_scenes_value_without_less_comparator_operators_get_op(e_scene_value_without_less_cmp_operators_t operator); +const char* ezlopi_scenes_value_without_less_comparator_operators_get_name(e_scene_value_without_less_cmp_operators_t operator); +const char* ezlopi_scenes_value_without_less_comparator_operators_get_method(e_scene_value_without_less_cmp_operators_t operator); + +int ezlopi_scenes_operators_value_without_less_operations(uint32_t item_id, l_fields_v2_t* value_field, l_fields_v2_t* comparator_field); + +// CompareValues Operators 'without-less' (default) +int ezlopi_scenes_operators_value_comparevalues_without_less_operations(uint32_t item_id, l_fields_v2_t* value_field, l_fields_v2_t* value_type_field, l_fields_v2_t* comparator_field); +int ezlopi_scenes_operators_value_comparevalues_with_less_operations(uint32_t item_id, l_fields_v2_t* value_field, l_fields_v2_t* value_type_field, l_fields_v2_t* comparator_field); + +// CompareNumberRange Operators +int ezlopi_scenes_operators_value_number_range_operations(uint32_t item_id, l_fields_v2_t* start_value_field, l_fields_v2_t* end_value_field, l_fields_v2_t* comparator_field); -int ezlopi_scenes_operators_value_without_less_operations(uint32_t item_id, l_fields_v2_t *value_field, l_fields_v2_t *comparator_field); +// HasAtleastOneDictionaryValue +int ezlopi_scenes_operators_has_atleastone_dictionary_value_operations(uint32_t item_id, l_fields_v2_t* value_field); +// IsDictornaryChanged +int ezlopi_scenes_operators_is_dictionary_changed_operations(l_scenes_list_v2_t* scene_node, uint32_t item_id, l_fields_v2_t* key_field, l_fields_v2_t* operation_field); -#endif // _EZLOPI_CORE_SCENES_OPERATORS_H_ +#endif // _EZLOPI_CORE_SCENES_OPERATORS_H_ \ No newline at end of file diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_print.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_print.c index 2c8cd40ed..db3d1365f 100755 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_print.c +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_print.c @@ -39,14 +39,14 @@ void ezlopi_print_fields(l_fields_v2_t* fields) case EZLOPI_VALUE_TYPE_INT: case EZLOPI_VALUE_TYPE_HOUSE_MODE_ID: { - TRACE_D("\t\t\t|-- value: %f", fields->field_value.u_value.value_double); - // TRACE_D("\t\t\t|-- value: %f", fields->value.value_double); + TRACE_D("\t\t\t|-- value: %d", (int)fields->field_value.u_value.value_double); + // TRACE_D("\t\t\t|-- value: %f", fields->field_value.u_value.value_double); break; } case EZLOPI_VALUE_TYPE_BOOL: { TRACE_D("\t\t\t|-- value: [%d]%s", fields->field_value.u_value.value_bool, fields->field_value.u_value.value_bool ? ezlopi_true_str : ezlopi_false_str); - // TRACE_D("\t\t\t|-- value: [%d]%s", fields->value.value_bool, fields->value.value_bool ? ezlopi_true_str : ezlopi_false_str); + // TRACE_D("\t\t\t|-- value: [%d]%s", fields->field_value.u_value.value_bool, fields->field_value.u_value.value_bool ? ezlopi_true_str : ezlopi_false_str); break; } case EZLOPI_VALUE_TYPE_FLOAT: @@ -55,16 +55,11 @@ void ezlopi_print_fields(l_fields_v2_t* fields) break; } case EZLOPI_VALUE_TYPE_STRING: - { - TRACE_D("\t\t\t|-- value: %s", fields->field_value.u_value.value_string); - break; - } case EZLOPI_VALUE_TYPE_ITEM: - { - TRACE_D("\t\t\t|-- value: %s", fields->field_value.u_value.value_string); - break; - } + case EZLOPI_VALUE_TYPE_24_HOURS_TIME: case EZLOPI_VALUE_TYPE_INTERVAL: + case EZLOPI_VALUE_TYPE_HMS_INTERVAL: + case EZLOPI_VALUE_TYPE_SCENEID: { TRACE_D("\t\t\t|-- value: %s", fields->field_value.u_value.value_string); break; @@ -74,19 +69,38 @@ void ezlopi_print_fields(l_fields_v2_t* fields) ezlopi_print_when_blocks((l_when_block_v2_t*)fields->field_value.u_value.when_block); break; } + case EZLOPI_VALUE_TYPE_CREDENTIAL: + case EZLOPI_VALUE_TYPE_DICTIONARY: + case EZLOPI_VALUE_TYPE_ARRAY: + case EZLOPI_VALUE_TYPE_24_HOURS_TIME_ARRAY: + case EZLOPI_VALUE_TYPE_INT_ARRAY: case EZLOPI_VALUE_TYPE_HOUSE_MODE_ID_ARRAY: { CJSON_TRACE("\t\t\t|-- value", fields->field_value.u_value.cj_value); break; } - case EZLOPI_VALUE_TYPE_DICTIONARY: - case EZLOPI_VALUE_TYPE_ARRAY: + case EZLOPI_VALUE_TYPE_ENUM: + case EZLOPI_VALUE_TYPE_TOKEN: + { + if (VALUE_TYPE_STRING == fields->field_value.e_type) + { + TRACE_D("\t\t\t|-- value: %s", fields->field_value.u_value.value_string); + } + else if (VALUE_TYPE_CJSON == fields->field_value.e_type) + { + CJSON_TRACE("\t\t\t|-- value", fields->field_value.u_value.cj_value); + } + else + { + TRACE_W("Value type not Implemented!, value_type: %d", fields->value_type); + } + break; + } case EZLOPI_VALUE_TYPE_RGB: case EZLOPI_VALUE_TYPE_CAMERA_STREAM: case EZLOPI_VALUE_TYPE_USER_CODE: case EZLOPI_VALUE_TYPE_WEEKLY_INTERVAL: case EZLOPI_VALUE_TYPE_DAILY_INTERVAL: - case EZLOPI_VALUE_TYPE_TOKEN: case EZLOPI_VALUE_TYPE_BUTTON_STATE: case EZLOPI_VALUE_TYPE_USER_LOCK_OPERATION: case EZLOPI_VALUE_TYPE_USER_CODE_ACTION: @@ -134,10 +148,6 @@ void ezlopi_print_fields(l_fields_v2_t* fields) case EZLOPI_VALUE_TYPE_REACTIVE_POWER_CONSUMPTION: case EZLOPI_VALUE_TYPE_DEVICE: case EZLOPI_VALUE_TYPE_EXPRESSION: - case EZLOPI_VALUE_TYPE_24_HOURS_TIME: - case EZLOPI_VALUE_TYPE_24_HOURS_TIME_ARRAY: - case EZLOPI_VALUE_TYPE_INT_ARRAY: - case EZLOPI_VALUE_TYPE_HMS_INTERVAL: case EZLOPI_VALUE_TYPE_NONE: case EZLOPI_VALUE_TYPE_MAX: { diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_scripts.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_scripts.c index c4b5bb03a..18d37832b 100755 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_scripts.c +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_scripts.c @@ -18,30 +18,30 @@ #include "ezlopi_cloud_constants.h" -static l_ezlopi_scenes_script_t *script_head = NULL; +static l_ezlopi_scenes_script_t* script_head = NULL; typedef struct s_lua_scripts_modules { - char *name; + char* name; lua_CFunction func; } s_lua_scripts_modules_t; static void __scripts_nvs_parse(void); -static void __script_process(void *arg); +static void __script_process(void* arg); static void __scripts_process_runner(void); -static void __load_custom_libs(lua_State *lua_state); -static void __run_script(l_ezlopi_scenes_script_t *script_node); +static void __load_custom_libs(lua_State* lua_state); +static void __run_script(l_ezlopi_scenes_script_t* script_node); static void __scripts_remove_id_and_update_list(uint32_t script_id); -static const char *__script_report(lua_State *lua_state, int status); -static void __exit_script_hook(lua_State *lua_state, lua_Debug *ar); -static l_ezlopi_scenes_script_t *__scripts_create_node(uint32_t script_id, cJSON *cj_script); +static const char* __script_report(lua_State* lua_state, int status); +static void __exit_script_hook(lua_State* lua_state, lua_Debug* ar); +static l_ezlopi_scenes_script_t* __scripts_create_node(uint32_t script_id, cJSON* cj_script); -l_ezlopi_scenes_script_t *ezlopi_scenes_scripts_get_head(void) +l_ezlopi_scenes_script_t* ezlopi_scenes_scripts_get_head(void) { return script_head; } -void ezlopi_scenes_scripts_stop(l_ezlopi_scenes_script_t *script_node) +void ezlopi_scenes_scripts_stop(l_ezlopi_scenes_script_t* script_node) { if (script_node && script_node->script_handle) { @@ -51,7 +51,7 @@ void ezlopi_scenes_scripts_stop(l_ezlopi_scenes_script_t *script_node) void ezlopi_scenes_scripts_stop_by_id(uint32_t script_id) { - l_ezlopi_scenes_script_t *script_node = script_head; + l_ezlopi_scenes_script_t* script_node = script_head; while (script_node) { if (script_node->id == script_id) @@ -65,7 +65,7 @@ void ezlopi_scenes_scripts_stop_by_id(uint32_t script_id) void ezlopi_scenes_scripts_delete_by_id(uint32_t script_id) { - l_ezlopi_scenes_script_t *script_to_delete = NULL; + l_ezlopi_scenes_script_t* script_to_delete = NULL; if (script_head->id == script_id) { script_to_delete = script_head; @@ -73,7 +73,7 @@ void ezlopi_scenes_scripts_delete_by_id(uint32_t script_id) } else { - l_ezlopi_scenes_script_t *curr_script = script_head; + l_ezlopi_scenes_script_t* curr_script = script_head; while (curr_script->next) { if (curr_script->next->id == script_id) @@ -104,12 +104,23 @@ void ezlopi_scenes_scripts_delete_by_id(uint32_t script_id) } } -uint32_t ezlopi_scenes_scripts_add_to_head(uint32_t script_id, cJSON *cj_script) +void ezlopi_scenes_scripts_factory_info_reset(void) +{ + l_ezlopi_scenes_script_t* curr_script = ezlopi_scenes_scripts_get_head(); + + while (curr_script) + { + ezlopi_scenes_scripts_delete_by_id(curr_script->id); // auto-script_head shift + curr_script = ezlopi_scenes_scripts_get_head(); + } +} + +uint32_t ezlopi_scenes_scripts_add_to_head(uint32_t script_id, cJSON* cj_script) { uint32_t new_script_id = 0; if (script_head) { - l_ezlopi_scenes_script_t *curr_script = script_head; + l_ezlopi_scenes_script_t* curr_script = script_head; while (curr_script->next) { curr_script = curr_script->next; @@ -135,7 +146,7 @@ uint32_t ezlopi_scenes_scripts_add_to_head(uint32_t script_id, cJSON *cj_script) void ezlopi_scenes_scripts_run_by_id(uint32_t script_id) { - l_ezlopi_scenes_script_t *curr_script = script_head; + l_ezlopi_scenes_script_t* curr_script = script_head; while (curr_script) { if (script_id == curr_script->id) @@ -150,9 +161,9 @@ void ezlopi_scenes_scripts_run_by_id(uint32_t script_id) } } -void ezlopi_scenes_scripts_update(cJSON *cj_script) +void ezlopi_scenes_scripts_update(cJSON* cj_script) { - cJSON *cj_script_id = cJSON_DetachItemFromObject(cj_script, ezlopi__id_str); + cJSON* cj_script_id = cJSON_DetachItemFromObject(cj_script, ezlopi__id_str); if (cj_script_id) { @@ -160,7 +171,7 @@ void ezlopi_scenes_scripts_update(cJSON *cj_script) { uint32_t script_id = strtoul(cj_script_id->valuestring, NULL, 16); - l_ezlopi_scenes_script_t *script_node = script_head; + l_ezlopi_scenes_script_t* script_node = script_head; while (script_node) { if (script_id == script_node->id) @@ -176,7 +187,7 @@ void ezlopi_scenes_scripts_update(cJSON *cj_script) } { - cJSON *cj_name = cJSON_GetObjectItem(cj_script, ezlopi_name_str); + cJSON* cj_name = cJSON_GetObjectItem(cj_script, ezlopi_name_str); if (cj_name && cj_name->valuestring) { uint32_t len = strlen(cj_name->valuestring) + 1; @@ -186,7 +197,7 @@ void ezlopi_scenes_scripts_update(cJSON *cj_script) } { - cJSON *cj_code = cJSON_GetObjectItem(cj_script, ezlopi_code_str); + cJSON* cj_code = cJSON_GetObjectItem(cj_script, ezlopi_code_str); if (cj_code && cj_code->valuestring) { uint32_t len = strlen(cj_code->valuestring) + 1; @@ -195,7 +206,7 @@ void ezlopi_scenes_scripts_update(cJSON *cj_script) } } - char *script_to_update = cJSON_Print(cj_script); + char* script_to_update = cJSON_Print(cj_script); if (script_to_update) { cJSON_Minify(script_to_update); @@ -220,7 +231,7 @@ void ezlopi_scenes_scripts_init(void) __scripts_process_runner(); } -static void __run_script(l_ezlopi_scenes_script_t *script_node) +static void __run_script(l_ezlopi_scenes_script_t* script_node) { if (script_node->code) { @@ -230,7 +241,7 @@ static void __run_script(l_ezlopi_scenes_script_t *script_node) static void __scripts_process_runner(void) { - l_ezlopi_scenes_script_t *script_node = script_head; + l_ezlopi_scenes_script_t* script_node = script_head; while (script_node) { __run_script(script_node); @@ -238,10 +249,10 @@ static void __scripts_process_runner(void) } } -static void __script_process(void *arg) +static void __script_process(void* arg) { - l_ezlopi_scenes_script_t *script_node = (l_ezlopi_scenes_script_t *)arg; - lua_State *lua_state = luaL_newstate(); + l_ezlopi_scenes_script_t* script_node = (l_ezlopi_scenes_script_t*)arg; + lua_State* lua_state = luaL_newstate(); if (lua_state) { luaL_openlibs(lua_state); @@ -252,8 +263,8 @@ static void __script_process(void *arg) int tmp_ret = luaL_loadstring(lua_state, script_node->code); if (tmp_ret) { -#warning "Krishna needs to check this." - const char *script_report = __script_report(lua_state, tmp_ret); + #warning "Krishna needs to check this." + const char* script_report = __script_report(lua_state, tmp_ret); if (script_report) { TRACE_E("Error in '%s' -> %s", script_node->name, script_report); @@ -263,7 +274,7 @@ static void __script_process(void *arg) tmp_ret = lua_pcall(lua_state, 0, 1, 0); if (tmp_ret) { - const char *script_report = __script_report(lua_state, tmp_ret); + const char* script_report = __script_report(lua_state, tmp_ret); if (script_report) { TRACE_E("Error in '%s' -> %s", script_node->name, script_report); @@ -286,22 +297,22 @@ static void __script_process(void *arg) static void __scripts_add_script_id(uint32_t script_id) { uint32_t script_ids_str_free = true; - char *script_ids_str = ezlopi_nvs_read_scenes_scripts(); + char* script_ids_str = ezlopi_nvs_read_scenes_scripts(); if (NULL == script_ids_str) { script_ids_str = "[]"; // don't free in this case script_ids_str_free = false; } - cJSON *cj_script_ids = cJSON_Parse(script_ids_str); + cJSON* cj_script_ids = cJSON_Parse(script_ids_str); if (cj_script_ids) { - cJSON *cj_script_id = cJSON_CreateNumber(script_id); + cJSON* cj_script_id = cJSON_CreateNumber(script_id); if (cj_script_id) { if (cJSON_AddItemToArray(cj_script_ids, cj_script_id)) { - char *script_ids_str_updated = cJSON_Print(cj_script_ids); + char* script_ids_str_updated = cJSON_Print(cj_script_ids); if (script_ids_str_updated) { cJSON_Minify(script_ids_str_updated); @@ -326,16 +337,16 @@ static void __scripts_add_script_id(uint32_t script_id) static void __scripts_remove_id_and_update_list(uint32_t script_id) { - char *scripts_ids_str = ezlopi_nvs_read_scenes_scripts(); + char* scripts_ids_str = ezlopi_nvs_read_scenes_scripts(); if (scripts_ids_str) { - cJSON *cj_scripts_ids = cJSON_Parse(scripts_ids_str); + cJSON* cj_scripts_ids = cJSON_Parse(scripts_ids_str); if (cj_scripts_ids) { int array_size = cJSON_GetArraySize(cj_scripts_ids); for (int i = 0; i < array_size; i++) { - cJSON *cj_script_id = cJSON_GetArrayItem(cj_scripts_ids, i); + cJSON* cj_script_id = cJSON_GetArrayItem(cj_scripts_ids, i); if (cj_script_id && cj_script_id->valuedouble) { if (script_id == cj_script_id->valuedouble) @@ -343,7 +354,7 @@ static void __scripts_remove_id_and_update_list(uint32_t script_id) TRACE_D("Removing (%d: %08x) script from list!", i, script_id); cJSON_DeleteItemFromArray(cj_scripts_ids, i); - char *scripts_ids_str_updated = cJSON_Print(cj_scripts_ids); + char* scripts_ids_str_updated = cJSON_Print(cj_scripts_ids); if (scripts_ids_str_updated) { cJSON_Minify(scripts_ids_str_updated); @@ -366,17 +377,17 @@ static void __scripts_remove_id_and_update_list(uint32_t script_id) static void __scripts_nvs_parse(void) { - char *script_ids = ezlopi_nvs_read_scenes_scripts(); + char* script_ids = ezlopi_nvs_read_scenes_scripts(); if (script_ids) { - cJSON *cj_script_ids = cJSON_Parse(script_ids); + cJSON* cj_script_ids = cJSON_Parse(script_ids); if (cj_script_ids) { int array_size = cJSON_GetArraySize(cj_script_ids); for (int i = 0; i < array_size; i++) { - cJSON *cj_script_id = cJSON_GetArrayItem(cj_script_ids, i); + cJSON* cj_script_id = cJSON_GetArrayItem(cj_script_ids, i); if (cj_script_id && cj_script_id->valuedouble) { uint32_t script_id = (uint32_t)(cj_script_id->valuedouble); @@ -385,10 +396,10 @@ static void __scripts_nvs_parse(void) char script_id_str[32]; snprintf(script_id_str, sizeof(script_id_str), "%08x", script_id); - char *script_str = ezlopi_nvs_read_str(script_id_str); + char* script_str = ezlopi_nvs_read_str(script_id_str); if (script_str) { - cJSON *cj_script = cJSON_Parse(script_str); + cJSON* cj_script = cJSON_Parse(script_str); if (cj_script) { ezlopi_scenes_scripts_add_to_head(script_id, cj_script); @@ -410,14 +421,14 @@ static void __scripts_nvs_parse(void) } } -static l_ezlopi_scenes_script_t *__scripts_create_node(uint32_t script_id, cJSON *cj_script) +static l_ezlopi_scenes_script_t* __scripts_create_node(uint32_t script_id, cJSON* cj_script) { - l_ezlopi_scenes_script_t *new_script = NULL; + l_ezlopi_scenes_script_t* new_script = NULL; if (cj_script) { - cJSON *cj_script_name = cJSON_GetObjectItem(cj_script, ezlopi_name_str); - cJSON *cj_script_code = cJSON_GetObjectItem(cj_script, ezlopi_code_str); + cJSON* cj_script_name = cJSON_GetObjectItem(cj_script, ezlopi_name_str); + cJSON* cj_script_code = cJSON_GetObjectItem(cj_script, ezlopi_code_str); if (cj_script_name && cj_script_name->valuestring && cj_script_code && cj_script_code->string) { @@ -428,7 +439,7 @@ static l_ezlopi_scenes_script_t *__scripts_create_node(uint32_t script_id, cJSON else { script_id = ezlopi_cloud_generate_script_id(); - char *script_str = cJSON_Print(cj_script); + char* script_str = cJSON_Print(cj_script); if (script_str) { cJSON_Minify(script_str); @@ -440,7 +451,7 @@ static l_ezlopi_scenes_script_t *__scripts_create_node(uint32_t script_id, cJSON } } - new_script = (l_ezlopi_scenes_script_t *)malloc(sizeof(l_ezlopi_scenes_script_t)); + new_script = (l_ezlopi_scenes_script_t*)malloc(sizeof(l_ezlopi_scenes_script_t)); if (new_script) { memset(new_script, 0, sizeof(l_ezlopi_scenes_script_t)); @@ -449,14 +460,14 @@ static l_ezlopi_scenes_script_t *__scripts_create_node(uint32_t script_id, cJSON new_script->state = SCRIPT_STATE_NONE; uint32_t script_name_size = strlen(cj_script_name->valuestring) + 1; - new_script->name = (char *)malloc(script_name_size); + new_script->name = (char*)malloc(script_name_size); if (new_script->name) { snprintf(new_script->name, script_name_size, "%s", cj_script_name->valuestring); } uint32_t script_code_size = strlen(cj_script_code->valuestring) + 1; - new_script->code = (char *)malloc(script_code_size); + new_script->code = (char*)malloc(script_code_size); if (new_script->code) { snprintf(new_script->code, script_code_size, "%s", cj_script_code->valuestring); @@ -470,20 +481,20 @@ static l_ezlopi_scenes_script_t *__scripts_create_node(uint32_t script_id, cJSON return new_script; } -static void __exit_script_hook(lua_State *lua_state, lua_Debug *ar) +static void __exit_script_hook(lua_State* lua_state, lua_Debug* ar) { lua_sethook(lua_state, __exit_script_hook, LUA_MASKLINE, 0); luaL_error(lua_state, "Exited from software call"); } -static const char *__script_report(lua_State *lua_state, int status) +static const char* __script_report(lua_State* lua_state, int status) { if (status == LUA_OK) { return NULL; } - const char *msg = lua_tostring(lua_state, -1); + const char* msg = lua_tostring(lua_state, -1); lua_pop(lua_state, 1); return msg; } @@ -495,7 +506,7 @@ static s_lua_scripts_modules_t lua_scripts_modules[] = { {.name = NULL, .func = NULL}, }; -static void __load_custom_libs(lua_State *lua_state) +static void __load_custom_libs(lua_State* lua_state) { uint32_t idx = 0; while (lua_scripts_modules[idx].name && lua_scripts_modules[idx].func) diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_scripts.h b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_scripts.h index cfb69a6e1..2b345729b 100755 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_scripts.h +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_scripts.h @@ -15,25 +15,27 @@ typedef enum e_script_state typedef struct l_ezlopi_scenes_script { uint32_t id; - char *name; - char *code; + char* name; + char* code; e_script_state_t state; - void *script_handle; + void* script_handle; - struct l_ezlopi_scenes_script *next; + struct l_ezlopi_scenes_script* next; } l_ezlopi_scenes_script_t; void ezlopi_scenes_scripts_init(void); -l_ezlopi_scenes_script_t *ezlopi_scenes_scripts_get_head(void); -uint32_t ezlopi_scenes_scripts_add_to_head(uint32_t script_id, cJSON *cj_script); +l_ezlopi_scenes_script_t* ezlopi_scenes_scripts_get_head(void); +uint32_t ezlopi_scenes_scripts_add_to_head(uint32_t script_id, cJSON* cj_script); -void ezlopi_scenes_scripts_update(cJSON *cj_script); +void ezlopi_scenes_scripts_update(cJSON* cj_script); void ezlopi_scenes_scripts_stop_by_id(uint32_t script_id); -void ezlopi_scenes_scripts_stop(l_ezlopi_scenes_script_t *script_node); +void ezlopi_scenes_scripts_stop(l_ezlopi_scenes_script_t* script_node); void ezlopi_scenes_scripts_run_by_id(uint32_t script_id); void ezlopi_scenes_scripts_delete_by_id(uint32_t script_id); +void ezlopi_scenes_scripts_factory_info_reset(void); + #endif // _EZLOPI_CORE_SCENES_SCRIPTS_H_ diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_status_changed.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_status_changed.c index 7ce7e10d3..88685bbcb 100644 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_status_changed.c +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_status_changed.c @@ -91,6 +91,7 @@ const char* ezlopi_scenes_status_to_string(e_scene_status_v2_t scene_status) ret = "EZLOPI_SCENE_STATUS_STOPPED"; break; } + #warning "need to add status_failed"; default: { ret = "EZLOPI_SCENE_STATUS_NONE"; diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_then_methods.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_then_methods.c index 3b7c8c828..e58844356 100755 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_then_methods.c +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_then_methods.c @@ -1,15 +1,22 @@ #include "ezlopi_util_trace.h" +#include "ezlopi_core_nvs.h" +#include "ezlopi_core_http.h" +#include "ezlopi_core_reset.h" #include "ezlopi_core_devices.h" +#include "ezlopi_core_event_group.h" +#include "ezlopi_core_factory_info.h" #include "ezlopi_core_scenes_scripts.h" #include "ezlopi_core_scenes_then_methods.h" #include "ezlopi_core_scenes_status_changed.h" #include "ezlopi_service_meshbot.h" +#include "ezlopi_core_scenes_then_methods_helper_func.h" #include "ezlopi_cloud_constants.h" int ezlopi_scene_then_set_item_value(l_scenes_list_v2_t* curr_scene, void* arg) { + TRACE_W(" Set_item_value "); int ret = 0; uint32_t item_id = 0; cJSON* cj_params = cJSON_CreateObject(); @@ -86,7 +93,54 @@ int ezlopi_scene_then_set_item_value(l_scenes_list_v2_t* curr_scene, void* arg) int ezlopi_scene_then_set_device_armed(l_scenes_list_v2_t* curr_scene, void* arg) { TRACE_W("Warning: then-method not implemented!"); - return 0; + int ret = 0; + if (curr_scene) + { + uint32_t device_id = 0; + bool device_armed = false; + l_action_block_v2_t* curr_then = (l_action_block_v2_t*)arg; + if (curr_then) + { + l_fields_v2_t* curr_field = curr_then->fields; + while (curr_field) + { + if (0 == strncmp(curr_field->name, "device", 7)) + { + device_id = strtoul(curr_field->field_value.u_value.value_string, NULL, 16); + } + else if (0 == strncmp(curr_field->name, "deviceFlag", 11)) + { + if (EZLOPI_VALUE_TYPE_BOOL == curr_field->value_type) + { + device_armed = curr_field->field_value.u_value.value_bool; + } + } + curr_field = curr_field->next; + } + + if (device_id) + { + l_ezlopi_device_t* curr_device = ezlopi_device_get_head(); + while (curr_device) + { + if (device_id == curr_device->cloud_properties.device_id) + { + s_ezlopi_cloud_controller_t* controller_info = ezlopi_device_get_controller_information(); + if (controller_info) + { + #warning "we need to change from 'controller' to 'device_id' specific" + controller_info->armed = (device_armed) ? true : false; + } + break; + } + curr_device = curr_device->next; + } + } + } + + } + + return ret; } int ezlopi_scene_then_send_cloud_abstract_command(l_scenes_list_v2_t* curr_scene, void* arg) { @@ -100,13 +154,56 @@ int ezlopi_scene_then_switch_house_mode(l_scenes_list_v2_t* curr_scene, void* ar } int ezlopi_scene_then_send_http_request(l_scenes_list_v2_t* curr_scene, void* arg) { - TRACE_W("Warning: then-method not implemented!"); - return 0; + TRACE_W(" send_http "); + int ret = 0; + l_action_block_v2_t* curr_then = (l_action_block_v2_t*)arg; + if (curr_then) + { + s_ezlopi_core_http_mbedtls_t* tmp_http_data = (s_ezlopi_core_http_mbedtls_t*)malloc(sizeof(s_ezlopi_core_http_mbedtls_t)); + if (tmp_http_data) + { + memset(tmp_http_data, 0, sizeof(s_ezlopi_core_http_mbedtls_t)); + l_fields_v2_t* curr_field = curr_then->fields; + + const s_sendhttp_method_t __sendhttp_method[] = { + {.field_name = "request", .field_func = parse_http_request_type}, + {.field_name = "url", .field_func = parse_http_url}, + {.field_name = "credential", .field_func = parse_http_creds}, + {.field_name = "contentType", .field_func = parse_http_content_type}, + {.field_name = "content", .field_func = parse_http_content}, + {.field_name = "headers", .field_func = parse_http_headers}, + {.field_name = "skipSecurity", .field_func = parse_http_skipsecurity}, + {.field_name = NULL, .field_func = NULL}, + }; + + while (NULL != curr_field) // fields + { + for (uint8_t i = 0; i < ((sizeof(__sendhttp_method) / sizeof(__sendhttp_method[i]))); i++) + { + if (0 == strncmp(__sendhttp_method[i].field_name, curr_field->name, strlen(__sendhttp_method[i].field_name) + 1)) + { + (__sendhttp_method[i].field_func)(tmp_http_data, curr_field); + break; + } + } + curr_field = curr_field->next; + } + // now to trigger http_request and extract the response. + tmp_http_data->response = NULL; + tmp_http_data->response_maxlen = 0; + ezlopi_core_http_mbedtls_req(tmp_http_data); // Returns:- [response_buffer = &Memory_block] + free_http_mbedtls_struct(tmp_http_data); + + free(tmp_http_data); + } + } + + return ret; } int ezlopi_scene_then_run_custom_script(l_scenes_list_v2_t* curr_scene, void* arg) { + TRACE_W(" run_custom_script "); int ret = 0; - uint32_t script_id = 0; l_action_block_v2_t* curr_then = (l_action_block_v2_t*)arg; if (curr_then) @@ -138,8 +235,9 @@ int ezlopi_scene_then_run_plugin_script(l_scenes_list_v2_t* curr_scene, void* ar } int ezlopi_scene_then_run_scene(l_scenes_list_v2_t* curr_scene, void* arg) { + TRACE_W(" run_scene "); int ret = 0; - uint32_t sceneID = 0; + uint32_t sceneId = 0; bool execute_else_condition = false; l_action_block_v2_t* curr_then = (l_action_block_v2_t*)arg; if (curr_then) @@ -151,7 +249,7 @@ int ezlopi_scene_then_run_scene(l_scenes_list_v2_t* curr_scene, void* arg) { if (curr_field->field_value.e_type == VALUE_TYPE_STRING) { - sceneID = strtoul(curr_field->field_value.u_value.value_string, NULL, 16); + sceneId = strtoul(curr_field->field_value.u_value.value_string, NULL, 16); } else { @@ -189,12 +287,12 @@ int ezlopi_scene_then_run_scene(l_scenes_list_v2_t* curr_scene, void* arg) if (execute_else_condition) { TRACE_D("Executing else condition"); - ezlopi_meshbot_execute_scene_else_action_group(sceneID); + ezlopi_meshbot_execute_scene_else_action_group(sceneId); } else { - TRACE_D("Executing scene, id: %d", sceneID); - ezlopi_scenes_service_run_by_id(sceneID); + TRACE_D("Executing scene, id: %d", sceneId); + ezlopi_scenes_service_run_by_id(sceneId); } } else @@ -273,13 +371,70 @@ int ezlopi_scene_then_reset_scene_latches(l_scenes_list_v2_t* curr_scene, void* } int ezlopi_scene_then_reboot_hub(l_scenes_list_v2_t* curr_scene, void* arg) { - TRACE_W("Warning: then-method not implemented!"); - return 0; + TRACE_W(" reboot_hub "); + int ret = 0; + l_action_block_v2_t* curr_then = (l_action_block_v2_t*)arg; + if (curr_then && curr_scene) + { + TRACE_E("Rebooting ESP......................... "); + EZPI_CORE_reboot(); + } + return ret; } int ezlopi_scene_then_reset_hub(l_scenes_list_v2_t* curr_scene, void* arg) { - TRACE_W("Warning: then-method not implemented!"); - return 0; + TRACE_W(" reset_hub "); + int ret = 0; + cJSON* cj_params = cJSON_CreateObject(); + + if (cj_params) + { + l_action_block_v2_t* curr_then = (l_action_block_v2_t*)arg; + if (curr_then) + { + l_fields_v2_t* curr_field = curr_then->fields; + while (curr_field) + { + if (0 == strncmp(curr_field->name, "type", 5)) + { + if ((EZLOPI_VALUE_TYPE_ENUM == curr_field->value_type) && (NULL != curr_field->field_value.u_value.value_string)) + { + TRACE_S("value: %s", curr_field->field_value.u_value.value_string); + if (0 == strncmp(curr_field->field_value.u_value.value_string, "factory", 8)) + { + TRACE_E("Factory Reseting ESP......................... "); + // clear the settings realated to scenes, devices, items, rooms,etc + ezlopi_scenes_scripts_factory_info_reset(); + ezlopi_device_factory_info_reset(); + ezlopi_nvs_scenes_factory_info_reset(); // 'nvs' partitions + + ezlopi_factory_info_v3_scenes_factory_soft_reset(); // 'ID' partition :- 'wifi' sector + TRACE_E("Rebooting ESP......................... "); + EZPI_CORE_reboot(); + } + else if (0 == strncmp(curr_field->field_value.u_value.value_string, "soft", 5)) + { + ezlopi_nvs_scenes_soft_reset(); + + ezlopi_factory_info_v3_scenes_factory_soft_reset(); // 'ID' partition :- 'wifi' sector + TRACE_E("Rebooting ESP......................... "); + EZPI_CORE_reboot(); + } + else if (0 == strncmp(curr_field->field_value.u_value.value_string, "hard", 5)) + { + #warning "hard reset not in documention."; + EZPI_CORE_factory_restore(); + } + } + } + + curr_field = curr_field->next; + } + } + + cJSON_Delete(cj_params); + } + return ret; } int ezlopi_scene_then_cloud_api(l_scenes_list_v2_t* curr_scene, void* arg) { diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_then_methods_helper_func.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_then_methods_helper_func.c new file mode 100644 index 000000000..8278b7162 --- /dev/null +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_then_methods_helper_func.c @@ -0,0 +1,336 @@ +#include +#include "ezlopi_util_trace.h" +#include "ezlopi_core_http.h" +#include "ezlopi_core_scenes_v2.h" +#include "ezlopi_core_scenes_then_methods_helper_func.h" + +#define STR_SIZE(str) ((NULL != str) ? (strlen(str)) : 0) + +/** + * @brief Frees an address => '*ptr', pointing to an occupied address in heap. + */ +#define FREE_PTR_IF_NOT_NULL(ptr) \ + { \ + if (ptr) \ + { \ + free(ptr); \ + ptr = NULL; \ + } \ + } + + /** + * @brief This funtion is called, only to reallocate a '*header' of custom_structure 's_ezlopi_core_http_mbedtls_t' + * + * @param tmp_http_data [ Pointer to (s_ezlopi_core_http_mbedtls_t*) block of memory. ] + * @param append_size [ Size of 'string' to be appended. ] + * @param append_str [ 'string_literal' to be appended. ] + * @return int [ Fail ==> returns Old-size / Success ==> returns New-size ] + */ +static int __ezlopi_core_scenes_then_sendhttp_relloc_header(s_ezlopi_core_http_mbedtls_t* tmp_http_data, int append_size, const char* append_str) +{ + int ret = (int)tmp_http_data->header_maxlen; // Assign Old-block size as default + int new_size = append_size + (ret + 1); + + uint8_t retry = 5; + do + { + if (1 == ezlopi_core_http_dyna_relloc(&(tmp_http_data->header), new_size)) // rellocate: 'tmp_http_data->header' with 'new_size' + { + snprintf((tmp_http_data->header) + strlen(tmp_http_data->header), append_size, "%s", append_str); + ret = new_size; // return new memory-block size + // TRACE_I("Append Successful: Header[size: %d , occupied: %d]", ret, STR_SIZE(tmp_http_data->header)); + break; + } + else + { + TRACE_E("Append_Failed... ; returning original header_contents [RETRY:%d]", retry); + retry--; + } + } while (retry > 0); + return ret; +} +/** + * @brief Function to extract "web_host" from "field_value_string". + */ +static void __ezlopi_core_scenes_then_sendhttp_parse_host_name(s_ezlopi_core_http_mbedtls_t* tmp_http_data, const char* field_value_string) +{ + if (NULL != field_value_string) + { + const char* start = strstr(field_value_string, "://"); + if (start != NULL) + { + // TRACE_W("Here! fresh webserver"); + start += 3; + int length = 0; + char* end = strchr(start, '/'); + if (end != NULL) + { + length = (end - start); + if (length > 0) + { + length++; // include null character + char* tmp_string = malloc(sizeof(char) * length); // tmp_string != NULL + if (tmp_string) + { + bzero(tmp_string, sizeof(char) * length); + snprintf(tmp_string, length, "%s", start); + // TRACE_I("web_host_name : %s", tmp_string); + tmp_http_data->web_server_maxlen = (uint16_t)ezlopi_core_http_mem_malloc(&(tmp_http_data->web_server), tmp_string); + free(tmp_string); + } + } + } + else + { + const char* ptr = field_value_string; + length = (int)strlen(field_value_string) - (int)(start - ptr); + if (length > 0) + { + length++; // include null character + char* tmp_string = malloc(sizeof(char) * length); // tmp_string != NULL + if (tmp_string) + { + bzero(tmp_string, sizeof(char) * length); + snprintf(tmp_string, length, "%s", (ptr + ((int)(start - ptr)))); + // TRACE_I("web_host_name : %s", tmp_string); + tmp_http_data->web_server_maxlen = (uint16_t)ezlopi_core_http_mem_malloc(&(tmp_http_data->web_server), tmp_string); + free(tmp_string); + } + } + } + } + } +} +/** + * @brief Function to Clear and Malloc the header_member (within 's_ezlopi_core_http_mbedtls_t') only. + * @return Size of content in 's_ezlopi_core_http_mbedtls_t'->header + */ +static int __ezlopi_core_scenes_then_create_fresh_header(s_ezlopi_core_http_mbedtls_t* tmp_http_data) +{ + int ret = STR_SIZE(tmp_http_data->header); + + if ((NULL == tmp_http_data->header) && (0 == ret)) + { + // TRACE_W("Here! fresh header init"); + tmp_http_data->header_maxlen = (uint16_t)ezlopi_core_http_mem_malloc(&(tmp_http_data->header), "\r\0"); + ret = STR_SIZE(tmp_http_data->header); + // TRACE_W("Here!! Created fresh header-> [capacity: %d] , [occupied: %d]", tmp_http_data->header_maxlen, ret); + } + return ret; +} +/** + * @brief Function to append values to header_member (within 's_ezlopi_core_http_mbedtls_t') only. + */ +static void __ezlopi_core_scenes_then_append_to_header(s_ezlopi_core_http_mbedtls_t* tmp_http_data, const char* str1, const char* str2) +{ + int append_size = (STR_SIZE(str1) + 4 + STR_SIZE(str2)) + 6; + int max_allowed = ezlopi_core_http_calc_empty_bufsize(tmp_http_data->header, (tmp_http_data->header_maxlen), append_size); + if (max_allowed > 0) + { + snprintf(tmp_http_data->header + STR_SIZE(tmp_http_data->header), max_allowed, "%s: %s\r\n", str1, str2); + } + else // We reallocate:- 'tmp_http_data->header' + { + char* append_str = malloc(sizeof(char) * append_size); // append_str != NULL + if (append_str) + { + bzero(append_str, sizeof(char) * append_size); + snprintf(append_str, append_size, "%s: %s\r\n", str1, str2); + + //----------------------------------------------------------------------------------- + // TRACE_D("Append_str: %s[%d] ", append_str, append_size); + // TRACE_D("-> Before => Realloc_Header:-[capacity:%d (occupied:%d)]->[needed:%d]", tmp_http_data->header_maxlen, STR_SIZE(tmp_http_data->header), append_size); + tmp_http_data->header_maxlen = (uint16_t)__ezlopi_core_scenes_then_sendhttp_relloc_header(tmp_http_data, append_size, append_str); + // TRACE_D("-> After => Realloc_Header:-[capacity:%d (occupied:%d)]", tmp_http_data->header_maxlen, STR_SIZE(tmp_http_data->header)); + //----------------------------------------------------------------------------------- + free(append_str); + } + } +} + +//------------------------------- ezlopi_scene_then_sendhttp_request ----------------------------------------------- +void parse_http_request_type(s_ezlopi_core_http_mbedtls_t* tmp_http_data, l_fields_v2_t* curr_field) +{ + const char* field_value_string = curr_field->field_value.u_value.value_string; + if ((EZLOPI_VALUE_TYPE_STRING == curr_field->value_type) && (NULL != field_value_string)) + { + if (0 == strncmp(curr_field->field_value.u_value.value_string, "GET", 4)) + { + tmp_http_data->method = HTTP_METHOD_GET; + } + else if (0 == strncmp(curr_field->field_value.u_value.value_string, "POST", 5)) + { + tmp_http_data->method = HTTP_METHOD_POST; + } + else if (0 == strncmp(curr_field->field_value.u_value.value_string, "PUT", 4)) + { + tmp_http_data->method = HTTP_METHOD_PUT; + } + else if (0 == strncmp(curr_field->field_value.u_value.value_string, "DELETE", 7)) + { + tmp_http_data->method = HTTP_METHOD_DELETE; + } + else + { + TRACE_E("The given http_req method is not implemented yet"); + } + } +} +void parse_http_url(s_ezlopi_core_http_mbedtls_t* tmp_http_data, l_fields_v2_t* curr_field) +{ + const char* field_value_string = curr_field->field_value.u_value.value_string; + if ((EZLOPI_VALUE_TYPE_STRING == curr_field->value_type) && (NULL != field_value_string)) + { + // TRACE_W("Here! fresh url"); + tmp_http_data->url_maxlen = (uint16_t)ezlopi_core_http_mem_malloc(&(tmp_http_data->url), field_value_string); + if (tmp_http_data->url_maxlen > 0) + { + tmp_http_data->web_port = ((NULL != strstr(field_value_string, "https")) ? 443 : 80); + //-------------------------------------------- + __ezlopi_core_scenes_then_sendhttp_parse_host_name(tmp_http_data, field_value_string); + //-------------------------------------------- + + int content_size = __ezlopi_core_scenes_then_create_fresh_header(tmp_http_data); + if (content_size > 0) // if this characters exsists in the 'tmp_http_data->header' + { + // 1. adding 'host' to header-buffer + // TRACE_W("Appending!! webserver -> header"); + __ezlopi_core_scenes_then_append_to_header(tmp_http_data, "Host", tmp_http_data->web_server); + } + else + { + TRACE_E("Failed Creating header for 'Host:'"); + } + } + } +} +void parse_http_content_type(s_ezlopi_core_http_mbedtls_t* tmp_http_data, l_fields_v2_t* curr_field) +{ + const char* field_value_string = curr_field->field_value.u_value.value_string; + if ((EZLOPI_VALUE_TYPE_STRING == curr_field->value_type) && (NULL != field_value_string)) + { + // TRACE_W("Here! content-type"); + if (STR_SIZE(field_value_string) > 0) + { + int content_size = __ezlopi_core_scenes_then_create_fresh_header(tmp_http_data); + if (content_size > 0) // if this characters exsists in the 'tmp_http_data->header' + { + // 2. adding 'Content-Type' to header-buffer + // TRACE_W("Appending!! content-type -> header"); + __ezlopi_core_scenes_then_append_to_header(tmp_http_data, "Content-Type", field_value_string); + } + else + { + TRACE_E("Failed Creating header for 'Content-Type:'"); + } + } + // else + // { + // TRACE_E("ERR : Content-Type ==> STRLEN[%d]", STR_SIZE(field_value_string)); + // } + } +} +void parse_http_content(s_ezlopi_core_http_mbedtls_t* tmp_http_data, l_fields_v2_t* curr_field) +{ + const char* field_value_string = curr_field->field_value.u_value.value_string; + if ((EZLOPI_VALUE_TYPE_STRING == curr_field->value_type) && (NULL != field_value_string)) + { + // TRACE_W("Here! fresh content"); + tmp_http_data->content_maxlen = (uint16_t)ezlopi_core_http_mem_malloc(&(tmp_http_data->content), field_value_string); + if (tmp_http_data->content_maxlen > 0) + { + int content_size = __ezlopi_core_scenes_then_create_fresh_header(tmp_http_data); + if (content_size > 0) // if this characters exsists in the 'tmp_http_data->header' + { + // TRACE_W("Appending!! content_length -> header"); + uint16_t i = (int)strlen(field_value_string); + if (i > 0) + { + char str[10]; + snprintf(str, 10, "%d", (int)i); // write length value in string + str[10] = '\0'; + // 3. adding 'Content-Length' to header-buffer + __ezlopi_core_scenes_then_append_to_header(tmp_http_data, "Content-Length", str); + } + } + else + { + TRACE_E("Failed Creating header for 'Content-Length:'"); + } + } + } +} +void parse_http_headers(s_ezlopi_core_http_mbedtls_t* tmp_http_data, l_fields_v2_t* curr_field) +{ + const cJSON* cj_value = curr_field->field_value.u_value.cj_value; + if ((EZLOPI_VALUE_TYPE_DICTIONARY == curr_field->value_type) && cJSON_IsObject(cj_value)) + { + // TRACE_W("Here! headers"); + int content_size = __ezlopi_core_scenes_then_create_fresh_header(tmp_http_data); + if (content_size > 0) // if this characters exsists in the 'tmp_http_data->header' + { + // TRACE_W("Appending!! headers -> header"); + cJSON* header = (cj_value->child); + while (header) + { + if ((NULL != header->string) && (NULL != header->valuestring)) + { + // 4. adding 'remaining' to header-buffer + __ezlopi_core_scenes_then_append_to_header(tmp_http_data, header->string, header->valuestring); + } + header = header->next; + } + } + else + { + TRACE_E("Failed Creating header for 'Headers:'"); + } + } +} +void parse_http_skipsecurity(s_ezlopi_core_http_mbedtls_t* tmp_http_data, l_fields_v2_t* curr_field) +{ + // TRACE_W("Here! skipsecurity"); + if (EZLOPI_VALUE_TYPE_BOOL == curr_field->value_type) + { + tmp_http_data->skip_cert_common_name_check = curr_field->field_value.u_value.value_bool; + int content_size = __ezlopi_core_scenes_then_create_fresh_header(tmp_http_data); + if (content_size > 0) // if this characters exsists in the 'tmp_http_data->header' + { + // 5. adding 'skip_security' to header-buffer + // TRACE_W("Appending!! skipsecurity -> header"); + __ezlopi_core_scenes_then_append_to_header(tmp_http_data, "skipSecurity", ((curr_field->field_value.u_value.value_bool) ? "true" : "false")); + } + else + { + TRACE_E("Failed Creating header for 'skipSecurity:'"); + } + } +} +void parse_http_creds(s_ezlopi_core_http_mbedtls_t* tmp_http_data, l_fields_v2_t* curr_field) +{ + const cJSON* cj_value = curr_field->field_value.u_value.cj_value; + if ((EZLOPI_VALUE_TYPE_CREDENTIAL == curr_field->value_type) && cJSON_IsObject(cj_value)) + { + cJSON* userItem = cJSON_GetObjectItem(cj_value, "user"); + cJSON* passwordItem = cJSON_GetObjectItem(cj_value, "password"); + if ((NULL != userItem) && (NULL != passwordItem)) + { + const char* userValue = cJSON_GetStringValue(userItem); + const char* passValue = cJSON_GetStringValue(passwordItem); + + // TRACE_W("Here! credential"); + tmp_http_data->username_maxlen = (uint16_t)ezlopi_core_http_mem_malloc(&(tmp_http_data->username), userValue); + tmp_http_data->password_maxlen = (uint16_t)ezlopi_core_http_mem_malloc(&(tmp_http_data->password), passValue); + } + } +} +void free_http_mbedtls_struct(s_ezlopi_core_http_mbedtls_t* config) +{ + FREE_PTR_IF_NOT_NULL(config->url); + FREE_PTR_IF_NOT_NULL(config->web_server); + FREE_PTR_IF_NOT_NULL(config->header); + FREE_PTR_IF_NOT_NULL(config->content); + FREE_PTR_IF_NOT_NULL(config->username); + FREE_PTR_IF_NOT_NULL(config->password); + FREE_PTR_IF_NOT_NULL(config->response); +} diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_then_methods_helper_func.h b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_then_methods_helper_func.h new file mode 100644 index 000000000..26f4a1287 --- /dev/null +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_then_methods_helper_func.h @@ -0,0 +1,21 @@ +#ifndef _EZLOPI_CORE_SCENES_THEN_METHODS_HELPER_FUNCTIONS_H_ +#define _EZLOPI_CORE_SCENES_THEN_METHODS_HELPER_FUNCTIONS_H_ + +#include "ezlopi_core_http.h" + +typedef struct s_sendhttp_method +{ + const char *field_name; + void (*field_func)(s_ezlopi_core_http_mbedtls_t *tmp_http_data, l_fields_v2_t *curr_field); +} s_sendhttp_method_t; + +void parse_http_request_type(s_ezlopi_core_http_mbedtls_t *tmp_http_data, l_fields_v2_t *curr_field); +void parse_http_url(s_ezlopi_core_http_mbedtls_t *tmp_http_data, l_fields_v2_t *curr_field); +void parse_http_content(s_ezlopi_core_http_mbedtls_t *tmp_http_data, l_fields_v2_t *curr_field); +void parse_http_content_type(s_ezlopi_core_http_mbedtls_t *tmp_http_data, l_fields_v2_t *curr_field); +void parse_http_headers(s_ezlopi_core_http_mbedtls_t *tmp_http_data, l_fields_v2_t *curr_field); +void parse_http_skipsecurity(s_ezlopi_core_http_mbedtls_t *tmp_http_data, l_fields_v2_t *curr_field); +void parse_http_creds(s_ezlopi_core_http_mbedtls_t *tmp_http_data, l_fields_v2_t *curr_field); +void free_http_mbedtls_struct(s_ezlopi_core_http_mbedtls_t *config); + +#endif /*_EZLOPI_CORE_SCENES_THEN_METHODS_HELPER_FUNCTIONS_H_*/ \ No newline at end of file diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_v2.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_v2.c index a64f777c7..c1c759ee2 100644 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_v2.c +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_v2.c @@ -317,7 +317,6 @@ int ezlopi_scenes_enable_disable_id_from_list_v2(uint32_t _id, bool enabled_flag } } } - cJSON_Delete(cj_scene_id_list); } free(scenes_id_list_str); @@ -868,6 +867,11 @@ static void _______fields_get_value(l_fields_v2_t* field, cJSON* cj_value) switch (field->value_type) { + case EZLOPI_VALUE_TYPE_ARRAY: + case EZLOPI_VALUE_TYPE_24_HOURS_TIME: + case EZLOPI_VALUE_TYPE_24_HOURS_TIME_ARRAY: + case EZLOPI_VALUE_TYPE_INT_ARRAY: + case EZLOPI_VALUE_TYPE_HMS_INTERVAL: case EZLOPI_VALUE_TYPE_HOUSE_MODE_ID_ARRAY: { field->field_value.e_type = VALUE_TYPE_CJSON; diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_value_types.h b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_value_types.h index a26bfbb20..c81a701ad 100755 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_value_types.h +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_value_types.h @@ -4,6 +4,7 @@ EZLOPI_VALUE_TYPE(INT, "int") EZLOPI_VALUE_TYPE(BOOL, "bool") EZLOPI_VALUE_TYPE(FLOAT, "float") EZLOPI_VALUE_TYPE(STRING, "string") +EZLOPI_VALUE_TYPE(CREDENTIAL, "credential") EZLOPI_VALUE_TYPE(DICTIONARY, "dictionary") EZLOPI_VALUE_TYPE(ARRAY, "array") EZLOPI_VALUE_TYPE(RGB, "rgb") @@ -11,6 +12,7 @@ EZLOPI_VALUE_TYPE(CAMERA_STREAM, "cameraStream") EZLOPI_VALUE_TYPE(USER_CODE, "userCode") EZLOPI_VALUE_TYPE(WEEKLY_INTERVAL, "weekly_interval") EZLOPI_VALUE_TYPE(DAILY_INTERVAL, "daily_interval") +EZLOPI_VALUE_TYPE(ENUM, "enum") EZLOPI_VALUE_TYPE(TOKEN, "token") EZLOPI_VALUE_TYPE(BUTTON_STATE, "button_state") EZLOPI_VALUE_TYPE(USER_LOCK_OPERATION, "user_lock_operation") @@ -69,6 +71,6 @@ EZLOPI_VALUE_TYPE(HMS_INTERVAL, "hms_interval") EZLOPI_VALUE_TYPE(BLOCKS, "blocks") EZLOPI_VALUE_TYPE(HOUSE_MODE_ID_ARRAY, "houseModeId_array") EZLOPI_VALUE_TYPE(HOUSE_MODE_ID, "houseModeId") -EZLOPI_VALUE_TYPE(SCENEID, "sceneID") +EZLOPI_VALUE_TYPE(SCENEID, "sceneId") // EZLOPI_VALUE_TYPE(MAX, NULL) \ No newline at end of file diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_when_methods.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_when_methods.c index 0df8671a6..7527c617f 100755 --- a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_when_methods.c +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_when_methods.c @@ -1,14 +1,23 @@ - +#include #include "ezlopi_util_trace.h" -#include "ezlopi_cloud_constants.h" #include "ezlopi_core_modes.h" +#include "ezlopi_core_sntp.h" +#include "ezlopi_core_ota.h" +#include "ezlopi_core_http.h" #include "ezlopi_core_devices.h" +#include "ezlopi_core_event_group.h" #include "ezlopi_core_scenes_operators.h" +#include "ezlopi_core_websocket_client.h" #include "ezlopi_core_scenes_when_methods.h" +#include "ezlopi_core_scenes_status_changed.h" +#include "ezlopi_core_scenes_when_methods_helper_functions.h" + +#include "ezlopi_cloud_constants.h" int ezlopi_scene_when_is_item_state(l_scenes_list_v2_t* scene_node, void* arg) { + //TRACE_W(" is_item_state "); int ret = 0; l_when_block_v2_t* when_block = (l_when_block_v2_t*)arg; if (when_block) @@ -107,6 +116,7 @@ int ezlopi_scene_when_is_item_state(l_scenes_list_v2_t* scene_node, void* arg) int ezlopi_scene_when_is_interval(l_scenes_list_v2_t* scene_node, void* arg) { + //TRACE_W(" is_interval "); int ret = 0; if (scene_node) @@ -164,26 +174,207 @@ int ezlopi_scene_when_is_button_state(l_scenes_list_v2_t* scene_node, void* arg) int ezlopi_scene_when_is_sun_state(l_scenes_list_v2_t* scene_node, void* arg) { - TRACE_W("Warning: when-method 'is_sun_state' not implemented!"); - return 0; + //TRACE_W(" is_SunState "); + int ret = 0; + l_when_block_v2_t* when_block = (l_when_block_v2_t*)arg; + if (when_block && scene_node) + { + time_t rawtime = 0; + time(&rawtime); + struct tm* info; + info = localtime(&rawtime); + + // list of function for extracting field parameter + const s_issunstate_method_t __issunstate_field[] = { + {.field_name = "sunrise", .field_func = issunstate_get_suntime}, + {.field_name = "sunset", .field_func = issunstate_get_suntime}, + {.field_name = "time", .field_func = issunstate_get_offs_tmval}, + {.field_name = "weekdays", .field_func = issunstate_eval_weekdays}, + {.field_name = "days", .field_func = issunstate_eval_days}, + {.field_name = "range", .field_func = issunstate_eval_range}, + {.field_name = NULL, .field_func = NULL}, + }; + + // Condition checker + uint8_t flag_check = 0; + l_fields_v2_t* curr_field = when_block->fields; + while (NULL != curr_field) + { + for (uint8_t i = 0; i < ((sizeof(__issunstate_field) / sizeof(__issunstate_field[i]))); i++) + { + if (0 == strncmp(__issunstate_field[i].field_name, curr_field->name, strlen(__issunstate_field[i].field_name) + 1)) + { + flag_check |= (__issunstate_field[i].field_func)(scene_node, curr_field, info, ((0 == i) ? 1 : (1 == i) ? 2 + : 0)); + break; + } + } + curr_field = curr_field->next; + } + // Now check the flag results + ret = issunstate_check_flag_result(scene_node, info, flag_check); + } + return ret; } int ezlopi_scene_when_is_date(l_scenes_list_v2_t* scene_node, void* arg) { - TRACE_W("Warning: when-method 'is_date' not implemented!"); - return 0; + //TRACE_W(" isDate "); + int ret = 0; + l_when_block_v2_t* when_block = (l_when_block_v2_t*)arg; + if (when_block && scene_node) + { + time_t rawtime = 0; + time(&rawtime); + struct tm* info; + info = localtime(&rawtime); + if (2 == info->tm_sec) // nth sec mark + { + // list of field function to extract the respective parameters + const s_isdate_method_t __isdate_func[] = { + {.field_name = "type", .field_func = isdate_type_check}, + {.field_name = "time", .field_func = isdate_tm_check}, + {.field_name = "weekdays", .field_func = isdate_weekdays_check}, + {.field_name = "days", .field_func = isdate_mdays_check}, + {.field_name = "weeks", .field_func = isdate_year_weeks_check}, + {.field_name = NULL, .field_func = NULL}, + }; + uint8_t flag_check = 0; + e_isdate_modes_t mode_type = ISDATE_UNDEFINED_MODE; + l_fields_v2_t* curr_field = when_block->fields; + while (NULL != curr_field) + { + for (uint8_t i = 0; i < ((sizeof(__isdate_func) / sizeof(__isdate_func[i]))); i++) + { + if (0 == strncmp(__isdate_func[i].field_name, curr_field->name, strlen(__isdate_func[i].field_name) + 1)) + { + flag_check |= (__isdate_func[i].field_func)(&mode_type, info, curr_field); // bit0 - bit3 + break; + } + } + curr_field = curr_field->next; + } + ret = isdate_check_flag_result(mode_type, flag_check); + // Output Filter based on date+time of activation + // TRACE_S("mode[%d], isDate:- FLAG_STATUS: %#x", mode_type, flag_check); + } + } + return ret; } int ezlopi_scene_when_is_once(l_scenes_list_v2_t* scene_node, void* arg) { - TRACE_W("Warning: when-method 'is_once' not implemented!"); - return 0; + //TRACE_W(" isOnce "); + int ret = 0; + l_when_block_v2_t* when_block = (l_when_block_v2_t*)arg; + if (when_block && scene_node) + { + time_t rawtime = 0; + time(&rawtime); + struct tm* info; + info = localtime(&rawtime); + + if (4 == info->tm_sec) // nth sec mark + { + // list of funciton to check validity of each field values + const s_isonce_method_t __isonce_method[] = { + {.field_name = "time", .field_func = isonce_tm_check}, + {.field_name = "day", .field_func = isonce_day_check}, + {.field_name = "month", .field_func = isonce_month_check}, + {.field_name = "year", .field_func = isonce_year_check}, + {.field_name = NULL, .field_func = NULL}, + }; + uint8_t flag_check = 0; + l_fields_v2_t* curr_field = when_block->fields; + while (curr_field) + { + for (uint8_t i = 0; i < ((sizeof(__isonce_method) / sizeof(__isonce_method[i]))); i++) + { + if (0 == strncmp(__isonce_method[i].field_name, curr_field->name, strlen(__isonce_method[i].field_name) + 1)) + { + flag_check |= (__isonce_method[i].field_func)(curr_field, info); + break; + } + } + curr_field = curr_field->next; + } + + // Output Filter based on date & time + ret = isonce_check_flag_result(scene_node, flag_check); + // TRACE_S("isOnce :- FLAG_STATUS: 0x0%x", flag_check); + } + } + return ret; } int ezlopi_scene_when_is_date_range(l_scenes_list_v2_t* scene_node, void* arg) { - TRACE_W("Warning: when-method 'is_date_range' not implemented!"); - return 0; + //TRACE_W(" isDate_range "); + int ret = 0; + l_when_block_v2_t* when_block = (l_when_block_v2_t*)arg; + if (when_block && scene_node) + { + time_t rawtime = 0; + time(&rawtime); + struct tm* info; + info = localtime(&rawtime); + + if (6 == info->tm_sec) // nth sec mark + { + // Default values : start and end times. + struct tm start = { + .tm_hour = 0, + .tm_min = 0, + }; + struct tm end = { + .tm_hour = 23, + .tm_min = 59, + }; + + // field function pointers + const s_isdate_range_method_t _isdate_range_fields[] = { + {.field_name = "startTime", .field_func = isdate_range_get_tm}, + {.field_name = "startDay", .field_func = isdate_range_get_startday}, + {.field_name = "startMonth", .field_func = isdate_range_get_startmonth}, + {.field_name = "startYear", .field_func = isdate_range_get_startyear}, + {.field_name = "endTime", .field_func = isdate_range_get_tm}, + {.field_name = "endDay", .field_func = isdate_range_get_endday}, + {.field_name = "endMonth", .field_func = isdate_range_get_endmonth}, + {.field_name = "endYear", .field_func = isdate_range_get_endyear}, + {.field_name = NULL, .field_func = NULL}, + }; + l_fields_v2_t* curr_field = when_block->fields; + while (curr_field) + { + for (int i = 0; i < ((sizeof(_isdate_range_fields) / sizeof(_isdate_range_fields[i]))); i++) + { + if (0 == strncmp(_isdate_range_fields[i].field_name, curr_field->name, strlen(_isdate_range_fields[i].field_name) + 1)) + { + (_isdate_range_fields[i].field_func)(curr_field, ((i < 4) ? &start : &end)); + break; + } + } + curr_field = curr_field->next; + } + + // Check for time,day,month and year validity + uint8_t(*isdate_range_check_flags[])(struct tm* start, struct tm* end, struct tm* info) = { + isdate_range_check_tm, + isdate_range_check_day, + isdate_range_check_month, + isdate_range_check_year, + }; + uint8_t flag_check = 0; + for (uint8_t i = 0; i < ISDATE_RANGE_MAX; i++) + { + flag_check |= isdate_range_check_flags[i](&start, &end, info); + } + + ret = isdate_range_check_flag_result(flag_check); + TRACE_S("isdate_range flag_check [0x0%x]", flag_check); + } + } + return ret; } int ezlopi_scene_when_is_user_lock_operation(l_scenes_list_v2_t* scene_node, void* arg) @@ -194,6 +385,7 @@ int ezlopi_scene_when_is_user_lock_operation(l_scenes_list_v2_t* scene_node, voi int ezlopi_scene_when_is_house_mode_changed_to(l_scenes_list_v2_t* scene_node, void* arg) { + //TRACE_W(" isHouse_mode "); int ret = 0; l_when_block_v2_t* when_block = (l_when_block_v2_t*)arg; @@ -242,8 +434,67 @@ int ezlopi_scene_when_is_house_mode_changed_from(l_scenes_list_v2_t* scene_node, int ezlopi_scene_when_is_device_state(l_scenes_list_v2_t* scene_node, void* arg) { + // TRACE_W(" isDevice_state. "); TRACE_W("Warning: when-method 'is_device_state' not implemented!"); - return 0; + int ret = 0; +#if 0 + l_when_block_v2_t* when_block = (l_when_block_v2_t*)arg; + if (when_block && scene_node) + { + uint32_t device_id = 0; + bool value_armed = false; + bool value_reachable = false; + + l_fields_v2_t* curr_field = when_block->fields; + while (curr_field) + { + if (0 == strncmp(curr_field->name, "device", 7)) + { + if (EZLOPI_VALUE_TYPE_DEVICE == curr_field->value_type && (NULL != curr_field->field_value.u_value.value_string)) + { + device_id = strtoul(curr_field->field_value.u_value.value_string, NULL, 16); + } + } + else if (0 == strncmp(curr_field->name, "armed", 6)) + { + if (EZLOPI_VALUE_TYPE_BOOL == curr_field->value_type) + { + value_armed = curr_field->field_value.u_value.value_bool; + } + } + else if (0 == strncmp(curr_field->name, "reachable", 10)) + { + if (EZLOPI_VALUE_TYPE_BOOL == curr_field->value_type) + { + value_reachable = curr_field->field_value.u_value.value_bool; + } + } + curr_field = curr_field->next; + } + if (device_id) + { + l_ezlopi_device_t* curr_device = ezlopi_device_get_head(); + while (curr_device) + { + if (device_id == curr_device->cloud_properties.device_id) + { + s_ezlopi_cloud_controller_t* controller_info = ezlopi_device_get_controller_information(); + if (controller_info) + { + #warning "we need to change from 'controller' to 'device_id' specific"; + ret = ((value_armed == controller_info->armed) ? 1 : 0); + ret = ((value_reachable == controller_info->service_notification) ? 1 : 0); + } + } + + curr_device = curr_device->next; + } + } + #warning "need to check device_group condition"; + } + +#endif + return ret; } int ezlopi_scene_when_is_network_state(l_scenes_list_v2_t* scene_node, void* arg) @@ -254,8 +505,83 @@ int ezlopi_scene_when_is_network_state(l_scenes_list_v2_t* scene_node, void* arg int ezlopi_scene_when_is_scene_state(l_scenes_list_v2_t* scene_node, void* arg) { - TRACE_W("Warning: when-method 'is_scene_state' not implemented!"); - return 0; + // TRACE_W(" isScene_state "); + // TRACE_W("Warning: when-method 'is_scene_state' not implemented!"); + int ret = 0; +#if 0 + l_when_block_v2_t* when_block = (l_when_block_v2_t*)arg; + if (when_block && scene_node) + { + uint32_t scene_id = 0; + l_fields_v2_t* value_field = NULL; + + l_fields_v2_t* curr_field = when_block->fields; + while (curr_field) + { + if (0 == strncmp(curr_field->name, "scene", 6)) + { + if (EZLOPI_VALUE_TYPE_SCENEID == curr_field->value_type && (NULL != curr_field->field_value.u_value.value_string)) + { + scene_id = strtoul(curr_field->field_value.u_value.value_string, NULL, 16); + // TRACE_E("scene_id : %d", scene_id); + } + } + else if (0 == strncmp(curr_field->name, "state", 6)) + { + if (EZLOPI_VALUE_TYPE_TOKEN == curr_field->value_type && (NULL != curr_field->field_value.u_value.value_string)) + { + value_field = curr_field; + } + } + curr_field = curr_field->next; + } + + if (scene_id && value_field) + { + + l_scenes_list_v2_t* curr_scene = ezlopi_scenes_get_scenes_head_v2(); + while (curr_scene) + { + if (curr_scene->_id == scene_id) + { + if (0 == strncmp("any_result", value_field->field_value.u_value.value_string, 11)) + { + ret = 1; + } + else if (0 == strncmp("scene_enabled", value_field->field_value.u_value.value_string, 14)) + { + ret = (true == curr_scene->enabled) ? 1 : 0; + } + else if (0 == strncmp("scene_disabled", value_field->field_value.u_value.value_string, 14)) + { + ret = (false == curr_scene->enabled) ? 1 : 0; + } + else if (0 == strncmp("finished", value_field->field_value.u_value.value_string, 9)) + { + ret = (EZLOPI_SCENE_STATUS_STOP == curr_scene->status) ? 1 : 0; + } + else if (0 == strncmp("partially_finished", value_field->field_value.u_value.value_string, 19)) + { + ret = (EZLOPI_SCENE_STATUS_RUNNING == curr_scene->status) ? 1 : 0; + } + else if (0 == strncmp("stopped", value_field->field_value.u_value.value_string, 8)) + { + ret = (EZLOPI_SCENE_STATUS_STOPPED == curr_scene->status) ? 1 : 0; + } + #warning "need to add 'FAILED' status for scene"; + // else if (0 == strncmp("failed", value_field->field_value.u_value.value_string, 7)) + // { + // ret = (false == curr_scene->enabled)? 1:0; + // } + TRACE_E("scene_state : %s , ret = %d", ezlopi_scenes_status_to_string(curr_scene->status), ret); + break; + } + curr_scene = curr_scene->next; + } + } + } +#endif + return ret; } int ezlopi_scene_when_is_group_state(l_scenes_list_v2_t* scene_node, void* arg) @@ -266,8 +592,40 @@ int ezlopi_scene_when_is_group_state(l_scenes_list_v2_t* scene_node, void* arg) int ezlopi_scene_when_is_cloud_state(l_scenes_list_v2_t* scene_node, void* arg) { - TRACE_W("Warning: when-method 'is_cloud_state' not implemented!"); - return 0; + //TRACE_W(" isCloud_state "); + int ret = 0; + l_when_block_v2_t* when_block = (l_when_block_v2_t*)arg; + if (when_block && scene_node) + { + l_fields_v2_t* value_field = NULL; + l_fields_v2_t* curr_field = when_block->fields; + while (curr_field) + { + if (0 == strncmp(curr_field->name, "state", 6)) + { + if (EZLOPI_VALUE_TYPE_TOKEN == curr_field->value_type && (NULL != curr_field->field_value.u_value.value_string)) + { + value_field = curr_field; + } + } + curr_field = curr_field->next; + } + + if (value_field) + { + if (0 < ezlopi_event_group_wait_for_event(EZLOPI_EVENT_NMA_REG, 100, false)) + { + ret = (0 == strncmp(value_field->field_value.u_value.value_string, "connected", 10)); + // TRACE_S("NMA_CONNECTED, ret = %d", ret); + } + else + { + ret = (0 == strncmp(value_field->field_value.u_value.value_string, "disconnected", 14)); + // TRACE_S("NMA_DISCONNECTED, ret = %d", ret); + } + } + } + return ret; } int ezlopi_scene_when_is_battery_state(l_scenes_list_v2_t* scene_node, void* arg) @@ -284,6 +642,7 @@ int ezlopi_scene_when_is_battery_level(l_scenes_list_v2_t* scene_node, void* arg int ezlopi_scene_when_compare_numbers(l_scenes_list_v2_t* scene_node, void* arg) { + //TRACE_W(" Compare_num "); int ret = 0; l_when_block_v2_t* when_block = (l_when_block_v2_t*)arg; @@ -322,50 +681,431 @@ int ezlopi_scene_when_compare_numbers(l_scenes_list_v2_t* scene_node, void* arg) int ezlopi_scene_when_compare_number_range(l_scenes_list_v2_t* scene_node, void* arg) { - TRACE_W("Warning: when-method 'number_range' not implemented!"); - return 0; + //TRACE_W(" Compare_num_range "); + // TRACE_W("Warning: when-method 'compare_number_range' not implemented!"); + int ret = 0; + // #if 0 + l_when_block_v2_t* when_block = (l_when_block_v2_t*)arg; + + if (when_block && scene_node) + { + uint32_t item_id = 0; + + l_fields_v2_t* start_value_field = NULL; + l_fields_v2_t* end_value_field = NULL; + + l_fields_v2_t* comparator_field = NULL; + + l_fields_v2_t* curr_field = when_block->fields; + while (curr_field) + { + if (0 == strncmp(curr_field->name, "item", 5)) + { + if (EZLOPI_VALUE_TYPE_ITEM == curr_field->value_type && (NULL != (curr_field->field_value.u_value.value_string))) + { + item_id = strtoul(curr_field->field_value.u_value.value_string, NULL, 16); + } + } + else if (0 == strncmp(curr_field->name, "comparator", 11)) + { + if (EZLOPI_VALUE_TYPE_STRING == curr_field->value_type && (NULL != (curr_field->field_value.u_value.value_string))) + { + comparator_field = curr_field; + } + } + else if (0 == strncmp(curr_field->name, "startValue", 11)) + { + start_value_field = curr_field;//contains the 'type' , 'value' & 'scale' + } + else if (0 == strncmp(curr_field->name, "endValue", 9)) + { + end_value_field = curr_field;//contains the 'type' , 'value' & 'scale' + } + curr_field = curr_field->next; + } + + if (item_id && start_value_field && end_value_field && comparator_field) + { + // check if both 'value_type' and 'scales' match. + if ((start_value_field->value_type == end_value_field->value_type) && + (0 == strcmp(start_value_field->scale, end_value_field->scale))) + { + ret = ezlopi_scenes_operators_value_number_range_operations(item_id, start_value_field, end_value_field, comparator_field); + } + } + } + // #endif + return ret; } int ezlopi_scene_when_compare_strings(l_scenes_list_v2_t* scene_node, void* arg) { - TRACE_W("Warning: when-method 'compare_strings' not implemented!"); - return 0; + //TRACE_W(" Compare_strings "); + // TRACE_W("Warning: when-method 'compare_strings' not implemented!"); + int ret = 0; + // #if 0 + l_when_block_v2_t* when_block = (l_when_block_v2_t*)arg; + if (when_block && scene_node) + { + uint32_t item_id = 0; + // l_fields_v2_t *expression_field = NULL; + l_fields_v2_t* value_field = NULL; + l_fields_v2_t* comparator_field = NULL; + + l_fields_v2_t* curr_field = when_block->fields; + while (curr_field) + { + if (0 == strncmp(curr_field->name, "item", 5)) + { + if (EZLOPI_VALUE_TYPE_ITEM == curr_field->value_type && (NULL != (curr_field->field_value.u_value.value_string))) + { + item_id = strtoul(curr_field->field_value.u_value.value_string, NULL, 16); // item or expression_id + } + } + else if (0 == strncmp(curr_field->name, "comparator", 11)) + { + if (EZLOPI_VALUE_TYPE_STRING == curr_field->value_type && (NULL != (curr_field->field_value.u_value.value_string))) + { + comparator_field = curr_field; + } + } + else if (0 == strncmp(curr_field->name, ezlopi_value_str, 6)) + { + if (EZLOPI_VALUE_TYPE_STRING == curr_field->value_type && NULL != curr_field->field_value.u_value.value_string) + { + value_field = curr_field; // this field has string + } + // else if (EZLOPI_VALUE_TYPE_EXPRESSION == curr_field->value_type && NULL != curr_field->value.value_string) + // { + // expression_field = curr_field; // this field has expression_name + // } + } + curr_field = curr_field->next; + } + + if (item_id && value_field && comparator_field) // only for item_value 'string comparisions' + { + ret = ezlopi_scenes_operators_value_strings_operations(item_id, value_field, comparator_field); + } + // else if (item_id && expression_field && comparator_field) // only for expression 'string comparisions' + // { + // // ret = ezlopi_scenes_operators_value_expn_strings_operations(item_id, value_field, comparator_field); + // } + } + // #endif + return ret; } int ezlopi_scene_when_string_operation(l_scenes_list_v2_t* scene_node, void* arg) { - TRACE_W("Warning: when-method 'string_operation' not implemented!"); - return 0; + //TRACE_W(" Compare_string_op "); + // TRACE_W("Warning: when-method 'string_operation' not implemented!"); + int ret = 0; + // #if 0 + l_when_block_v2_t* when_block = (l_when_block_v2_t*)arg; + if (when_block && scene_node) + { + uint32_t item_id = 0; + // l_fields_v2_t *expression_field = NULL; + l_fields_v2_t* value_field = NULL; + l_fields_v2_t* operation_field = NULL; + + l_fields_v2_t* curr_field = when_block->fields; + while (curr_field) + { + if (0 == strncmp(curr_field->name, "item", 5)) + { + if (EZLOPI_VALUE_TYPE_ITEM == curr_field->value_type && (NULL != (curr_field->field_value.u_value.value_string))) + { + item_id = strtoul(curr_field->field_value.u_value.value_string, NULL, 16); // ID extraction [item or expression] + } + } + else if (0 == strncmp(curr_field->name, "operation", 10)) + { + if (EZLOPI_VALUE_TYPE_STRING == curr_field->value_type && (NULL != (curr_field->field_value.u_value.value_string))) + { + operation_field = curr_field; + } + } + else if (0 == strncmp(curr_field->name, ezlopi_value_str, 6)) + { + if (EZLOPI_VALUE_TYPE_STRING == curr_field->value_type && NULL != curr_field->field_value.u_value.value_string) + { + value_field = curr_field; // this field has string + } + else if (EZLOPI_VALUE_TYPE_INT == curr_field->value_type) + { + value_field = curr_field; // this field has double/int value + } + } + curr_field = curr_field->next; + } + + if (item_id && value_field && operation_field) // only for item_value 'string comparisions' + { + ret = ezlopi_scenes_operators_value_strings_operations(item_id, value_field, operation_field); + } + // else if (item_id && expression_field && operation_field) // only for expression 'string comparisions' + // { + // // ret = ezlopi_scenes_operators_value_expn_strings_operations(item_id, value_field, operation_field); + // } + } + // #endif + return ret; } int ezlopi_scene_when_in_array(l_scenes_list_v2_t* scene_node, void* arg) { - TRACE_W("Warning: when-method 'in_array' not implemented!"); - return 0; + // //TRACE_W(" Compare_inArray "); + // TRACE_W("Warning: when-method 'in_array' not implemented!"); + int ret = 0; + // #if 0 + l_when_block_v2_t* when_block = (l_when_block_v2_t*)arg; + if (when_block && scene_node) + { + uint32_t item_id = 0; + // l_fields_v2_t *expression_field = NULL; + l_fields_v2_t* value_field = NULL; + l_fields_v2_t* operation_field = NULL; + + l_fields_v2_t* curr_field = when_block->fields; + while (curr_field) + { + if (0 == strncmp(curr_field->name, "item", 5)) + { + if (EZLOPI_VALUE_TYPE_ITEM == curr_field->value_type && (NULL != (curr_field->field_value.u_value.value_string))) + { + item_id = strtoul(curr_field->field_value.u_value.value_string, NULL, 16); // ID extraction [item or expression] + } + } + else if (0 == strncmp(curr_field->name, ezlopi_value_str, 6)) + { + if (EZLOPI_VALUE_TYPE_ARRAY == curr_field->value_type && (cJSON_IsArray(curr_field->field_value.u_value.cj_value))) + { + value_field = curr_field; + } + } + else if (0 == strncmp(curr_field->name, "operation", 10)) + { + if (EZLOPI_VALUE_TYPE_STRING == curr_field->value_type && (NULL != (curr_field->field_value.u_value.value_string))) + { + operation_field = curr_field; + } + } + curr_field = curr_field->next; + } + + if (item_id && value_field) // only for item_value 'string comparisions' + { + ret = ezlopi_scenes_operators_value_inarr_operations(item_id, value_field, operation_field); + } + // else if (item_id && expression_field && operation_field) // only for expression 'string comparisions' + // { + // ret = ezlopi_scenes_operators_value_expn_inarr_operations(item_id, value_field, operation_field); + // } + } + // #endif + return ret; } int ezlopi_scene_when_compare_values(l_scenes_list_v2_t* scene_node, void* arg) { - TRACE_W("Warning: when-method 'compare_values' not implemented!"); - return 0; + //TRACE_W(" Compare_values "); + // TRACE_W("Warning: when-method 'is_group_state' not implemented!"); + int ret = 0; + // #if 0 + l_when_block_v2_t* when_block = (l_when_block_v2_t*)arg; + if (when_block && scene_node) + { + uint32_t item_id = 0; + l_fields_v2_t* value_type_field = NULL; + l_fields_v2_t* value_field = NULL; + l_fields_v2_t* comparator_field = NULL; + // l_fields_v2_t *expression_field = NULL; + + l_fields_v2_t* curr_field = when_block->fields; + while (curr_field) + { + if (0 == strncmp(curr_field->name, "item", 5)) + { + if (EZLOPI_VALUE_TYPE_ITEM == curr_field->value_type && (NULL != (curr_field->field_value.u_value.value_string))) + { + item_id = strtoul(curr_field->field_value.u_value.value_string, NULL, 16); // ID extraction [item or expression] + } + } + + else if (0 == strncmp(curr_field->name, ezlopi_value_type_str, 11)) + { + if (EZLOPI_VALUE_TYPE_STRING == curr_field->value_type && (NULL != (curr_field->field_value.u_value.value_string))) + { + value_type_field = curr_field; + } + } + else if (0 == strncmp(curr_field->name, ezlopi_value_str, 6)) + { + if (EZLOPI_VALUE_TYPE_STRING == curr_field->value_type && (NULL != (curr_field->field_value.u_value.value_string))) + { + value_field = curr_field; + } + } + else if (0 == strncmp(curr_field->name, "comparator", 11)) + { + if (EZLOPI_VALUE_TYPE_STRING == curr_field->value_type && (NULL != (curr_field->field_value.u_value.value_string))) + { + comparator_field = curr_field; + } + } + curr_field = curr_field->next; + } + + if (item_id && value_field && value_type_field) // only for item_value 'string comparisions' + { + ret = ezlopi_scenes_operators_value_comparevalues_with_less_operations(item_id, value_field, value_type_field, comparator_field); + } + // else if (item_id && expression_field ) // only for expression 'string comparisions' + // { + // ret = ezlopi_scenes_operators_expn_comparevalues_with_less_operations(item_id, value_field, comparator_field); + // } + } + // #endif + return ret; } int ezlopi_scene_when_has_atleast_one_dictionary_value(l_scenes_list_v2_t* scene_node, void* arg) { - TRACE_W("Warning: when-method 'has_atleast_one_dictionary_value' not implemented!"); - return 0; + //TRACE_W(" atleast_one_diction_val "); + TRACE_W("Warning: when-method 'atleast_one_dictionary_value' not implemented!"); + int ret = 0; +#if 0 + l_when_block_v2_t* when_block = (l_when_block_v2_t*)arg; + if (scene_node && when_block) + { + uint32_t item_id = 0; + l_fields_v2_t* value_field = NULL; + + l_fields_v2_t* curr_field = when_block->fields; + while (curr_field) + { + if (0 == strncmp(curr_field->name, "item", 5)) + { + if (EZLOPI_VALUE_TYPE_ITEM == curr_field->value_type && (NULL != (curr_field->field_value.u_value.value_string))) + { + item_id = strtoul(curr_field->field_value.u_value.value_string, NULL, 16); + } + } + else if (0 == strncmp(curr_field->name, ezlopi_value_str, 6)) + { + if (EZLOPI_VALUE_TYPE_TOKEN == curr_field->value_type && (NULL != (curr_field->field_value.u_value.value_string))) + { + value_field = curr_field; // this contains "options [array]" & 'value': to be checked + } + } + curr_field = curr_field->next; + } + + // now to extract the + if (item_id && value_field) + { + ret = ezlopi_scenes_operators_has_atleastone_dictionary_value_operations(item_id, value_field); + } + } +#endif + return ret; } int ezlopi_scene_when_is_firmware_update_state(l_scenes_list_v2_t* scene_node, void* arg) { - TRACE_W("Warning: when-method 'is_firmware_update_state' not implemented!"); - return 0; + //TRACE_W(" firmware_update "); + TRACE_W("Warning: when-method 'firmware_update_state' not implemented!"); + int ret = 0; +#if 0 + l_when_block_v2_t* when_block = (l_when_block_v2_t*)arg; + if (scene_node && when_block) + { + uint32_t item_id = 0; + char* state_value = NULL; + + l_fields_v2_t* curr_field = when_block->fields; + while (curr_field) + { + if (0 == strncmp(curr_field->name, "state", 6)) + { + if (EZLOPI_VALUE_TYPE_TOKEN == curr_field->value_type && (NULL != (curr_field->field_value.u_value.value_string))) + { + state_value = curr_field->field_value.u_value.value_string; // started / updating / done + } + } + curr_field = curr_field->next; + } + + // now to extract the + if (item_id && (NULL != state_value)) + { + if (0 == strncmp("done", state_value, 5) && (0 == __get_ota_state())) + { + ret = 1; + } + else if (0 == strncmp("started", state_value, 8) && (1 == __get_ota_state())) + { + ret = 1; + } + else if (0 == strncmp("updating", state_value, 9) && (2 == __get_ota_state())) + { + ret = 1; + } + } + } +#endif + return ret; } int ezlopi_scene_when_is_dictionary_changed(l_scenes_list_v2_t* scene_node, void* arg) { + //TRACE_W(" isDictionary_changed "); TRACE_W("Warning: when-method 'is_dictionary_changed' not implemented!"); - return 0; + int ret = 0; +#if 0 + l_when_block_v2_t* when_block = (l_when_block_v2_t*)arg; + if (scene_node && when_block) + { + uint32_t item_id = 0; + l_fields_v2_t* key_field = NULL; + l_fields_v2_t* operation_field = NULL; + + l_fields_v2_t* curr_field = when_block->fields; + while (curr_field) + { + if (0 == strncmp(curr_field->name, "item", 5)) + { + if (EZLOPI_VALUE_TYPE_ITEM == curr_field->value_type && (NULL != (curr_field->field_value.u_value.value_string))) + { + item_id = strtoul(curr_field->field_value.u_value.value_string, NULL, 16); + } + } + else if (0 == strncmp(curr_field->name, "key", 4)) + { + if (EZLOPI_VALUE_TYPE_TOKEN == curr_field->value_type && (NULL != (curr_field->field_value.u_value.value_string))) + { + key_field = curr_field; // this contains "options [array]" & 'value': to be checked + } + } + else if (0 == strncmp(curr_field->name, "operation", 10)) + { + if (EZLOPI_VALUE_TYPE_TOKEN == curr_field->value_type && (NULL != (curr_field->field_value.u_value.value_string))) + { + operation_field = curr_field; // this contains "options [array]" & 'value': to be checked + } + } + curr_field = curr_field->next; + } + + if (item_id && key_field && operation_field) + { + ret = ezlopi_scenes_operators_is_dictionary_changed_operations(scene_node, item_id, key_field, operation_field); + } + } +#endif + return ret; } int ezlopi_scene_when_is_detected_in_hot_zone(l_scenes_list_v2_t* scene_node, void* arg) @@ -414,7 +1154,7 @@ int ezlopi_scene_when_not(l_scenes_list_v2_t* scene_node, void* arg) if (scene_method) { // iterate through all '_when_blocks_' - ret &= !(scene_method(scene_node, (void*)value_when_block)); // if all the block-calls are false, then return 1; + ret = !(scene_method(scene_node, (void*)value_when_block)); // if all the block-calls are false, then return 1; } value_when_block = value_when_block->next; diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_when_methods_helper_functions.c b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_when_methods_helper_functions.c new file mode 100644 index 000000000..75401fe8e --- /dev/null +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_when_methods_helper_functions.c @@ -0,0 +1,960 @@ +#include "ezlopi_util_trace.h" +#include "ezlopi_core_http.h" +#include "ezlopi_core_scenes_v2.h" +#include "ezlopi_core_scenes_when_methods_helper_functions.h" + +//------------------------------- ezlopi_scene_when_is_date --------------------------------------------- + +static uint8_t isdate_check_endweek_conditon(e_isdate_modes_t mode_type, struct tm* info) +{ + uint8_t ret = 0; + static uint8_t _last_day_of_curr_month = 0; + static int _starting_date_of_last_week = -1; + // filter out the first 22 days ; which do-not lie in last week of the month + if (info->tm_mday > 22) + { + // 1. Find out the 'valid' starting date of last week ( return -1 , if invalid ) + if (-1 == _starting_date_of_last_week) + { + //------------------------------------------------------------------- + // 1.1 find the nearest-prev sunday and assign it. + // for this calculation dont change default 'info->tm_wday' -> '0-6' + switch (info->tm_wday) + { + case 1: // monday + _starting_date_of_last_week = info->tm_mday - 1; + break; + case 2: // tuesday + _starting_date_of_last_week = info->tm_mday - 2; + break; + case 3: // wednasday + _starting_date_of_last_week = info->tm_mday - 3; + break; + case 4: // thursday + _starting_date_of_last_week = info->tm_mday - 4; + break; + case 5: // friday + _starting_date_of_last_week = info->tm_mday - 5; + break; + case 6: // saturday + _starting_date_of_last_week = info->tm_mday - 6; + break; + default: + _starting_date_of_last_week = info->tm_mday; + break; + } + TRACE_I("sunday :%dth_Day ", _starting_date_of_last_week); + //------------------------------------------------------------------- + // 1.2 validate the generated sunday number + switch (info->tm_mon) + { + case 1: // FEB + { + int year = info->tm_year + 1900; + if ((0 == (year % 4)) && ((0 == (year % 400)) || (0 != (year % 100)))) + { + _starting_date_of_last_week = ((29 - _starting_date_of_last_week) < 7) ? _starting_date_of_last_week : -1; // if this sunday's day_num lies within last 7-days of the month ; return this sunday's date + _last_day_of_curr_month = 29; + } + else // non-leap years + { + _starting_date_of_last_week = ((28 - _starting_date_of_last_week) < 7) ? _starting_date_of_last_week : -1; // if this sunday's day_num lies within last 7-days of the month ; return this sunday's date + _last_day_of_curr_month = 28; + } + + break; + } + case 3: // APR + case 5: // JUN + case 8: // SEP + case 10: // NOV + { + _starting_date_of_last_week = ((30 - _starting_date_of_last_week) < 7) ? _starting_date_of_last_week : -1; + _last_day_of_curr_month = 30; + break; + } + default: // JAN , MAR , MAY , JULY , AUG , OCT , DEC + { + _starting_date_of_last_week = ((31 - _starting_date_of_last_week) < 7) ? _starting_date_of_last_week : -1; + _last_day_of_curr_month = 31; + break; + } + } + } + + // 2. Now to compare today's date and produce result ( if not -1 ) + if (-1 != _starting_date_of_last_week) + { + // TRACE_S(" Last week of [%d] starts from [%d] :", info->tm_mon, _starting_date_of_last_week); + if (ISDATE_YEAR_WEEKS_MODE == mode_type) // last week of the year + { + if ((11 == info->tm_mon) && (info->tm_mday >= _starting_date_of_last_week)) + { + if (info->tm_mday >= _last_day_of_curr_month) + { // refresh the calculation flag '_starting_date_of_last_week' + _starting_date_of_last_week = -1; + } + ret = (1 << 3); + } + } + else if (ISDATE_WEEKS_MODE == mode_type) // last week of the month + { + if (info->tm_mday >= _starting_date_of_last_week) + { + if (info->tm_mday >= _last_day_of_curr_month) + { // refresh the calculation flag '_starting_date_of_last_week' + _starting_date_of_last_week = -1; + } + ret = (1 << 3); + } + } + } + } + return ret; +} +static uint8_t isdate_find_nth_week_curr_month(struct tm* info) +{ + // 2. find the fisrt day in this month + uint8_t tmp_week_num = 1; // starts with 1 ; since are already in one of the week-count + // for this calculation dont change default 'info->tm_wday' -> '0-6' + int tmp_weekday_of_curr_month = (info->tm_wday); // 0-6 ; sun = 0 + for (uint8_t i = (info->tm_mday); i > 1; i--) // total_days_in_curr_month - 1 + { + if (1 == tmp_weekday_of_curr_month) // if 'monday' ; add count + { + tmp_week_num++; + } + tmp_weekday_of_curr_month--; + if (0 > tmp_weekday_of_curr_month) + { + tmp_weekday_of_curr_month = 6; // sunday -> saturday + } + } + // TRACE_S("First day in current month = %d", tmp_weekday_of_curr_month); + // TRACE_S("[1-7] : %dth_Day lies in week[%dth] of the current month", (info->tm_wday), tmp_week_num); + return tmp_week_num; +} + +uint8_t isdate_type_check(e_isdate_modes_t* mode_type, struct tm* info, l_fields_v2_t* curr_field) +{ + const char* field_type_name[] = { + "daily", + "weekly", + "monthly", + "weeks", + "yearWeeks", + }; + if ((EZLOPI_VALUE_TYPE_STRING == curr_field->value_type) && (NULL != curr_field->field_value.u_value.value_string)) + { + const char* check_type_name = curr_field->field_value.u_value.value_string; + for (uint8_t t = 0; t < 5; t++) + { + if (0 == strncmp(field_type_name[t], check_type_name, strlen(check_type_name) + 1)) + { + *mode_type = (e_isdate_modes_t)t; // daily , weekly , monthly,... // 0-4 + break; + } + } + } + return 0; +} +uint8_t isdate_tm_check(e_isdate_modes_t* mode_type, struct tm* info, l_fields_v2_t* curr_field) +{ + uint8_t ret = 0; + cJSON* cj_time_arr = curr_field->field_value.u_value.cj_value; + if (cj_time_arr && (cJSON_Array == cj_time_arr->type)) + { + ret |= (1 << 4); + char field_hr_mm[10] = { 0 }; + strftime(field_hr_mm, 10, "%H:%M", info); + field_hr_mm[9] = '\0'; + // TRACE_S("[field_hr_mm: %s]", field_hr_mm); + + int array_size = cJSON_GetArraySize(cj_time_arr); + for (int i = 0; i < array_size; i++) + { + cJSON* array_item = cJSON_GetArrayItem(cj_time_arr, i); + if (array_item && cJSON_IsString(array_item)) + { + // TRACE_S("Time activate_%d: %s, [field_hr_mm: %s]", i, array_item->valuestring, field_hr_mm); + if (0 == strncmp(array_item->valuestring, field_hr_mm, 10)) + { + ret |= (1 << 0); // One of the TIME-condition has been met. + break; + } + } + } + if (!array_size) // if we are given : -"value" : [] + { + TRACE_S("Time activate :- [00:00], [field_hr_mm: %s]", field_hr_mm); + if (0 == strncmp(field_hr_mm, "00:00", 10)) // 24-hr format + { + ret |= (1 << 0); // TIME-condition "00:00" has been met. + } + } + } + return ret; +} +uint8_t isdate_weekdays_check(e_isdate_modes_t* mode_type, struct tm* info, l_fields_v2_t* curr_field) +{ + uint8_t ret = 0; + cJSON* cj_weekdays_arr = curr_field->field_value.u_value.cj_value; + if (cj_weekdays_arr && (cJSON_Array == cj_weekdays_arr->type)) + { + ret |= (1 << 5); + // Only for comparisions dont change 'info->tm_wday' -> 'sun:0,mon:1, ... , sat:6' to 'sun:7,mon:1, ... ,sat:6' + int field_weekdays = (0 == (info->tm_wday)) ? 7 : (info->tm_wday); // sunday => 0+1 ... saturday => 6+1 + + int array_size = cJSON_GetArraySize(cj_weekdays_arr); + for (int i = 0; i < array_size; i++) + { + cJSON* array_item = cJSON_GetArrayItem(cj_weekdays_arr, i); + if (array_item && cJSON_IsNumber(array_item)) + { + // TRACE_S("Weekdays activate_[%d]: %d, [field_weekdays: %d]", i, (int)(array_item->valuedouble), field_weekdays); + if ((int)(array_item->valuedouble) == field_weekdays) + { + ret |= (1 << 1); // One of the WEEKDAYS-condition has been met. + break; + } + } + } + } + return ret; +} +uint8_t isdate_mdays_check(e_isdate_modes_t* mode_type, struct tm* info, l_fields_v2_t* curr_field) +{ + uint8_t ret = 0; + cJSON* cj_days_arr = curr_field->field_value.u_value.cj_value; + if (cj_days_arr && (cJSON_Array == cj_days_arr->type)) + { + ret |= (1 << 6); + int array_size = cJSON_GetArraySize(cj_days_arr); + int field_days = info->tm_mday; // 1-31 + + for (int i = 0; i < array_size; i++) + { + cJSON* array_item = cJSON_GetArrayItem(cj_days_arr, i); + if (array_item && cJSON_IsNumber(array_item)) + { + TRACE_S("Days activate_%d: %d, [field_days: %d]", i, (int)(array_item->valuedouble), field_days); + if ((int)(array_item->valuedouble) == field_days) + { + ret |= (1 << 2); // One of the DAYS-condition has been met. + break; + } + } + } + } + return ret; +} + +uint8_t isdate_year_weeks_check(e_isdate_modes_t* mode_type, struct tm* info, l_fields_v2_t* curr_field) +{ + uint8_t ret = 0; + cJSON* cj_weeks_arr = curr_field->field_value.u_value.cj_value; + if (cj_weeks_arr && (cJSON_Array == cj_weeks_arr->type)) + { + ret |= (1 << 7); + int array_size = cJSON_GetArraySize(cj_weeks_arr); + for (int i = 0; i < array_size; i++) + { + // extract ;- [1,4,5,23,6,9,...,-1] + cJSON* array_item = cJSON_GetArrayItem(cj_weeks_arr, i); + if (array_item && cJSON_IsNumber(array_item)) + { + if (-1 == (int)(array_item->valuedouble)) // for case :- '-1' + { + if (0 != (ret = isdate_check_endweek_conditon(*mode_type, info))) // ret = (1<<3), if last-week confirmed + { + TRACE_I("Weeks_condition : '-1' has been satisfied ; ret = %#x", ret); + break; + } + } + else // for case :- 'n' + { + char field_weeks[10] = { 0 }; // week_value extracted from ESP32. + char week_val[10] = { 0 }; // week_value given to us from cloud. + + // reducing array values by -1, for easier comparison ::==> [1_54]--->[0_53] or [1_6]-->[0_5] + snprintf(week_val, 10, "%d", (int)(array_item->valuedouble - 1)); + week_val[9] = '\0'; + + if (ISDATE_YEAR_WEEKS_MODE == *mode_type) + { + strftime(field_weeks, 10, "%W", info); // [First day => Monday] ; Week number within (00-53) + field_weeks[9] = '\0'; + } + else if (ISDATE_WEEKS_MODE == *mode_type) + { + int tmp_week = isdate_find_nth_week_curr_month(info); // return the current week-number with 'monday' as first day + snprintf(field_weeks, 10, "%d", tmp_week); + field_weeks[9] = '\0'; + } + + if (0 == strncmp(week_val, field_weeks, 10)) // comparsion in string formats only + { + ret |= (1 << 3); // One of the TIME-condition has been met. + TRACE_I("Weeks_condition '%sth week' [reqd : %s] has been satisfied ; ret = (1<<3)", field_weeks, week_val); + break; + } + } + } + } + } + return ret; +} +int isdate_check_flag_result(e_isdate_modes_t mode_type, uint8_t flag_check) +{ + int ret = 0; + const uint8_t TIME_FLAG = (1 << 0); + const uint8_t WEEKDAYS_FLAG = (1 << 1); + const uint8_t DAYS_FLAG = (1 << 2); + const uint8_t WEEKS_FLAG = (1 << 3); + const uint8_t MASK_FOR_TIME_ARG = (1 << 4); + const uint8_t MASK_FOR_WEEKDAYS_ARG = (1 << 5); + const uint8_t MASK_FOR_DAYS_ARG = (1 << 6); + const uint8_t MASK_FOR_WEEKS_ARG = (1 << 7); + switch (mode_type) + { + case ISDATE_DAILY_MODE: + { + if (((flag_check & MASK_FOR_TIME_ARG) && (flag_check & TIME_FLAG))) + { + TRACE_W("here! daily-time"); + ret = 1; + } + break; + } + case ISDATE_WEEKLY_MODE: + { + if ((((flag_check & MASK_FOR_TIME_ARG) && (flag_check & TIME_FLAG)) && + ((flag_check & MASK_FOR_WEEKDAYS_ARG) && (flag_check & WEEKDAYS_FLAG)))) + { + TRACE_W("here! week_days and time"); + ret = 1; + } + break; + } + case ISDATE_MONTHLY_MODE: + { + if ((((flag_check & MASK_FOR_TIME_ARG) && (flag_check & TIME_FLAG)) && + ((flag_check & MASK_FOR_DAYS_ARG) && (flag_check & DAYS_FLAG)))) + { + TRACE_W("here! month_days and time"); + ret = 1; + } + break; + } + case ISDATE_WEEKS_MODE: + case ISDATE_YEAR_WEEKS_MODE: + { + if (((flag_check & MASK_FOR_TIME_ARG) && (flag_check & TIME_FLAG)) && + ((flag_check & MASK_FOR_WEEKS_ARG) && (flag_check & WEEKS_FLAG))) + { + TRACE_W("here! week and time"); + ret = 1; + } + break; + } + default: + { + break; + } + } + return ret; +} + +//------------------------------- ezlopi_scene_when_is_once ------------------------------------------ +uint8_t isonce_tm_check(l_fields_v2_t* curr_field, struct tm* info) +{ + uint8_t flag_check = 0; + if ((EZLOPI_VALUE_TYPE_24_HOURS_TIME == curr_field->value_type) && (NULL != curr_field->field_value.u_value.value_string)) + { + char field_hr_mm[10] = { 0 }; + strftime(field_hr_mm, 10, "%H:%M", info); + field_hr_mm[9] = '\0'; + + if (0 == strncmp(curr_field->field_value.u_value.value_string, field_hr_mm, 10)) + { + flag_check |= (1 << 0); // One of the TIME-condition has been met. + } + } + return flag_check; +} +uint8_t isonce_day_check(l_fields_v2_t* curr_field, struct tm* info) +{ + uint8_t flag_check = 0; + if (EZLOPI_VALUE_TYPE_INT == curr_field->value_type) + { + if ((int)(curr_field->field_value.u_value.value_double) == info->tm_mday) + { + flag_check |= (1 << 1); + } + } + return flag_check; +} +uint8_t isonce_month_check(l_fields_v2_t* curr_field, struct tm* info) +{ + uint8_t flag_check = 0; + if (EZLOPI_VALUE_TYPE_INT == curr_field->value_type) + { + if ((int)(curr_field->field_value.u_value.value_double) == (info->tm_mon + 1)) + { + flag_check |= (1 << 2); + } + } + return flag_check; +} +uint8_t isonce_year_check(l_fields_v2_t* curr_field, struct tm* info) +{ + uint8_t flag_check = 0; + if (EZLOPI_VALUE_TYPE_INT == curr_field->value_type) + { + if ((int)(curr_field->field_value.u_value.value_double) == (info->tm_year + 1900)) + { + flag_check |= (1 << 3); + } + } + return flag_check; +} +int isonce_check_flag_result(l_scenes_list_v2_t* scene_node, uint8_t flag_check) +{ + int ret = 0; + const uint8_t TIME_FLAG = (1 << 0); + const uint8_t DAY_FLAG = (1 << 1); + const uint8_t MONTH_FLAG = (1 << 2); + const uint8_t YEAR_FLAG = (1 << 3); + + if ((flag_check & TIME_FLAG) && (flag_check & DAY_FLAG) && (flag_check & MONTH_FLAG) && (flag_check & YEAR_FLAG)) + { + TRACE_W("here! once and time"); + // now to disable the scene and also store in ezlopi_nvs + scene_node->enabled = false; + ezlopi_scenes_enable_disable_id_from_list_v2(scene_node->_id, false); + ret = 1; + } + return ret; +} + +//------------------------------- ezlopi_scene_when_is_SunState --------------------------------------- + +typedef enum e_issunstate_offset +{ + ISSUNSTATE_INTIME_MODE = 0, + ISSUNSTATE_BEFORE_MODE, + ISSUNSTATE_AFTER_MODE, + ISSUNSTATE_UNDEFINED, +} e_issunstate_offset_t; +typedef struct s_sunstate_data +{ + uint8_t sunstate_mode; // [sunrise=1,sunset=2,0=NULL] + e_issunstate_offset_t tmoffs_type; // [intime=0,before=1,after=2] + int curr_tm_day; // today's day number + struct tm choosen_suntime; // unique suntime + struct tm defined_moment; // offset+suntime +} s_sunstate_data_t; + +static void issunsate_update_sunstate_tm(int tm_mday, s_sunstate_data_t* user_data) +{ + if (tm_mday && user_data) + { + // send httprequest to 'sunrisesunset.io' // use the latitude and longitude from NVS + char tmp_url[] = "https://api.sunrisesunset.io/json?lat=27.700769&lng=85.300140"; + char tmp_headers[] = "Host: api.sunrisesunset.io\r\nAccept: */*\r\nConnection: close\r\n"; + char tmp_web_server[] = "api.sunrisesunset.io"; + + // char tmp_url[] = "https://official-joke-api.appspot.com/random_joke"; + // char tmp_headers[] = "Host: official-joke-api.appspot.com\r\nAccept: */*\r\nConnection: close\r\n"; + // char tmp_web_server[] = "official-joke-api.appspot.com"; + + s_ezlopi_core_http_mbedtls_t tmp_config = { + .method = HTTP_METHOD_GET, + .url = tmp_url, + .url_maxlen = sizeof(tmp_url), + .web_port = 443, + .header = tmp_headers, + .header_maxlen = sizeof(tmp_headers), + .web_server = tmp_web_server, + .web_server_maxlen = sizeof(tmp_web_server), + .response = NULL, + .response_maxlen = 0, + }; + /*Make API call here and extract the suntime[according to 'user_data->sunstate_mode']*/ + + + ezlopi_core_http_mbedtls_req(&tmp_config); + // e.g. after valid extraction + user_data->curr_tm_day = tm_mday; // this stores day for which data is extracted + user_data->choosen_suntime.tm_hour = 5 + 12; // 24-hr + user_data->choosen_suntime.tm_min = 48; + user_data->choosen_suntime.tm_sec = 42; + + // now check if sunset and sunrise time are not zero + if ((0 == user_data->choosen_suntime.tm_hour) && + (0 == user_data->choosen_suntime.tm_min) && + (0 == user_data->choosen_suntime.tm_sec)) + { + TRACE_E(" Failed... clearing 'sunrise/sunset tm_mday'.. "); + user_data->curr_tm_day = 0; + } + } +} +static void issunstate_add_offs(e_issunstate_offset_t tmoffs_type, struct tm* choosen_suntime, struct tm* defined_moment, const char* tm_offs_val) +{ + if (choosen_suntime && defined_moment && tm_offs_val) // choosen_suntime => sunrise or sunset + { + // Default values to store start and end boundries + struct tm tmp_time = { 0 }; + + // Nox, extract & add :'tm_offs_val' + char time_diff[10]; + snprintf(time_diff, 10, "%s", tm_offs_val); + time_diff[9] = '\0'; + char* ptr1 = NULL; + char* ptr2 = NULL; + if (0 != strlen(time_diff)) + { + tmp_time.tm_hour = strtoul(time_diff, &ptr1, 10); + if (NULL != ptr1) + { + tmp_time.tm_min = strtoul(ptr1 + 1, &ptr2, 10); + if (NULL != ptr2) + { + tmp_time.tm_sec = strtoul(ptr2 + 1, NULL, 10); + } + else // only has minutes and seconds + { + tmp_time.tm_sec = tmp_time.tm_min; + tmp_time.tm_min = tmp_time.tm_hour; + tmp_time.tm_hour = 0; + } + } + else // only has seconds + { + tmp_time.tm_sec = tmp_time.tm_hour; + tmp_time.tm_min = 0; + tmp_time.tm_hour = 0; + } + } + // Combined 'tm_offs_val' & 'curr_suntime' + switch (tmoffs_type) + { + case ISSUNSTATE_INTIME_MODE: + { + TRACE_S("offset : Intime"); + defined_moment->tm_hour = choosen_suntime->tm_hour; + defined_moment->tm_min = choosen_suntime->tm_min; + defined_moment->tm_sec = choosen_suntime->tm_sec; + break; + } + case ISSUNSTATE_BEFORE_MODE: + { + TRACE_S("offset : Before"); + defined_moment->tm_hour = (choosen_suntime->tm_hour - tmp_time.tm_hour); + defined_moment->tm_hour = (defined_moment->tm_hour < 0) ? (24 + defined_moment->tm_hour) : defined_moment->tm_hour; // check the hour-range + defined_moment->tm_min = (choosen_suntime->tm_min - tmp_time.tm_min); + defined_moment->tm_min = (defined_moment->tm_min < 0) ? (60 + defined_moment->tm_min) : defined_moment->tm_min; // check the min-range + defined_moment->tm_sec = (choosen_suntime->tm_sec - tmp_time.tm_sec); + defined_moment->tm_sec = (defined_moment->tm_sec < 0) ? (60 + defined_moment->tm_sec) : defined_moment->tm_sec; // check the sec-range + break; + } + case ISSUNSTATE_AFTER_MODE: + { + TRACE_S("offset : After"); + defined_moment->tm_hour = (choosen_suntime->tm_hour + tmp_time.tm_hour); + defined_moment->tm_hour = (defined_moment->tm_hour > 23) ? (defined_moment->tm_hour - 24) : defined_moment->tm_hour; // check the hour-range + defined_moment->tm_min = (choosen_suntime->tm_min + tmp_time.tm_min); + defined_moment->tm_min = (defined_moment->tm_min > 59) ? (defined_moment->tm_min - 60) : defined_moment->tm_min; // check the min-range + defined_moment->tm_sec = (choosen_suntime->tm_sec + tmp_time.tm_sec); + defined_moment->tm_sec = (defined_moment->tm_sec > 59) ? (defined_moment->tm_sec - 60) : defined_moment->tm_sec; // check the sec-range + break; + } + case ISSUNSTATE_UNDEFINED: + { + TRACE_D(" INVALID isSunState_offset_type ... No time-offset added."); + break; + } + } + } +} + +uint8_t issunstate_get_suntime(l_scenes_list_v2_t* scene_node, l_fields_v2_t* curr_field, struct tm* info, uint8_t curr_sunstate_mode) +{ + uint8_t flag_check = 0; + /*Extract today's suntime via API call*/ + if ((EZLOPI_VALUE_TYPE_STRING == curr_field->value_type) && (NULL != curr_field->field_value.u_value.value_string)) + { + flag_check |= (1 << 4); // indicates 'MASK_TIME_FLAG' + + // 1. check for valid data within 'user_arg' + + if (NULL == (scene_node->when_block->fields->user_arg)) + { + s_sunstate_data_t* data = (s_sunstate_data_t*)malloc(sizeof(s_sunstate_data_t)); + if (data) + { + memset(data, 0, sizeof(s_sunstate_data_t)); + scene_node->when_block->fields->user_arg = (void*)data; + // TRACE_D("created user_data..."); + } + else + { + TRACE_E("failed to create user_data..."); + return 0; + } + } + // 2. Recalculate suntime for new-day or null + s_sunstate_data_t* user_data = (s_sunstate_data_t*)(scene_node->when_block->fields->user_arg); + if (user_data && (info->tm_mday != user_data->curr_tm_day)) + { + // TRACE_S("curr_day = [%d] ; [%dth]", info->tm_mday, user_data->curr_tm_day); + user_data->sunstate_mode = curr_sunstate_mode; // this sets target sunstate for curr meshbot + issunsate_update_sunstate_tm(info->tm_mday, user_data); // assign 'curr_day' & 'suntime' only + user_data->tmoffs_type = (0 == strncmp(curr_field->field_value.u_value.value_string, "intime", 7)) ? ISSUNSTATE_INTIME_MODE + : (0 == strncmp(curr_field->field_value.u_value.value_string, "before", 7)) ? ISSUNSTATE_BEFORE_MODE + : (0 == strncmp(curr_field->field_value.u_value.value_string, "after", 6)) ? ISSUNSTATE_AFTER_MODE + : ISSUNSTATE_UNDEFINED; + // 3. check if, curr_tm_day has been updated successfully + if ((0 == user_data->curr_tm_day) || + (0 == user_data->sunstate_mode) || + (ISSUNSTATE_UNDEFINED == user_data->tmoffs_type)) // if the curr_day or sunstate or offset is not set properly; + { + TRACE_E(" API extraction unsuccesful... Reseting user_args"); + free(scene_node->when_block->fields->user_arg); // reset the day + return 0; + } + TRACE_W("update_day = [%d][%dth] , offset[%d] : intime=0,before=1,after=2,undefined=3 , SunState[%d] : sunrise=1,sunset=2", info->tm_mday, user_data->curr_tm_day, user_data->tmoffs_type, user_data->sunstate_mode); + } + } + return flag_check; +} +uint8_t issunstate_get_offs_tmval(l_scenes_list_v2_t* scene_node, l_fields_v2_t* curr_field, struct tm* info, uint8_t curr_sunstate_mode) +{ + uint8_t flag_check = 0; + if ((EZLOPI_VALUE_TYPE_HMS_INTERVAL == curr_field->value_type) && (NULL != curr_field->field_value.u_value.value_string)) + { + s_sunstate_data_t* user_data = (s_sunstate_data_t*)(scene_node->when_block->fields->user_arg); + if ((user_data) && (0 != user_data->sunstate_mode)) + { + if ((0 == user_data->defined_moment.tm_hour) && + (0 == user_data->defined_moment.tm_min) && + (0 == user_data->defined_moment.tm_sec)) + { + TRACE_D(".... Adding offset: +/- (hh:mm:ss) ...."); + issunstate_add_offs(user_data->tmoffs_type, &(user_data->choosen_suntime), &(user_data->defined_moment), curr_field->field_value.u_value.value_string); + TRACE_S("\nSunMode[%d]{sunrise=1,sunset=2,0=NULL},\nChoosen_suntime(hh:mm:ss = %d:%d:%d),\ndefined_moment(hh:mm:ss = %d:%d:%d),\nOffset(%s)\n", + user_data->sunstate_mode, + user_data->choosen_suntime.tm_hour, + user_data->choosen_suntime.tm_min, + user_data->choosen_suntime.tm_sec, + user_data->defined_moment.tm_hour, + user_data->defined_moment.tm_min, + user_data->defined_moment.tm_sec, + curr_field->field_value.u_value.value_string); + } + } + } + return flag_check; +} +uint8_t issunstate_eval_weekdays(l_scenes_list_v2_t* scene_node, l_fields_v2_t* curr_field, struct tm* info, uint8_t curr_sunstate_mode) +{ + uint8_t flag_check = 0; + if ((EZLOPI_VALUE_TYPE_INT_ARRAY == curr_field->value_type) && (curr_field)) + { + flag_check |= (1 << 5); // indicates : weekdays + flag_check |= isdate_weekdays_check(NULL, info, curr_field); // checks condition : (1 << 1) + } + return flag_check; +} +uint8_t issunstate_eval_days(l_scenes_list_v2_t* scene_node, l_fields_v2_t* curr_field, struct tm* info, uint8_t curr_sunstate_mode) +{ + uint8_t flag_check = 0; + if ((EZLOPI_VALUE_TYPE_INT_ARRAY == curr_field->value_type) && (curr_field)) + { + flag_check |= (1 << 6); // indicates : month_days + flag_check |= isdate_mdays_check(NULL, info, curr_field); // checks condition : (1 << 2) + } + return flag_check; +} +uint8_t issunstate_eval_range(l_scenes_list_v2_t* scene_node, l_fields_v2_t* curr_field, struct tm* info, uint8_t curr_sunstate_mode) +{ + uint8_t flag_check = 0; + if ((EZLOPI_VALUE_TYPE_TOKEN == curr_field->value_type) && (NULL != curr_field->field_value.u_value.value_string)) + { + s_sunstate_data_t* user_data = (s_sunstate_data_t*)(scene_node->when_block->fields->user_arg); + if ((user_data) && (0 != user_data->sunstate_mode)) + { + // TRACE_S("checking midnight range offset"); + flag_check |= (1 << 7); // indicates : midnight-range + flag_check |= issunstate_check_mdrn(user_data->sunstate_mode, curr_field->field_value.u_value.value_string, info, &(user_data->defined_moment)); + } + } + return flag_check; +} +uint8_t issunstate_check_mdrn(uint8_t sunstate_mode, const char* range_type, struct tm* info, struct tm* defined_moment) +{ + uint8_t ret = 0; + if (sunstate_mode && range_type && info && defined_moment) + { + if (0 == strncmp(range_type, "at", 3)) // at desired moment + { + if ((info->tm_hour == defined_moment->tm_hour) && + (info->tm_min == defined_moment->tm_min) && + (info->tm_sec == defined_moment->tm_sec)) + { + ret = (1 << 3); + } + } + else if (0 == strncmp(range_type, "after", 6)) // all time after defined moment till midnight of current day + { + + if ((info->tm_hour < 24) && (info->tm_hour > defined_moment->tm_hour)) + { + ret = (1 << 3); + } + else if (((info->tm_hour < 24) && (info->tm_hour == defined_moment->tm_hour)) && + ((info->tm_min < 60) && (info->tm_min >= defined_moment->tm_min)) && + ((info->tm_sec < 60) && (info->tm_sec > defined_moment->tm_sec))) + { + ret = (1 << 3); + } + } + else if (0 == strncmp(range_type, "before", 7)) // all time after midnight till defined moment; + { + if ((info->tm_hour >= 0) && (info->tm_hour < defined_moment->tm_hour)) + { + ret = (1 << 3); + } + else if (((info->tm_hour >= 0) && (info->tm_hour == defined_moment->tm_hour)) && + ((info->tm_min >= 0) && (info->tm_min <= defined_moment->tm_min)) && + ((info->tm_sec >= 0) && (info->tm_sec <= defined_moment->tm_sec))) + { + ret = (1 << 3); + } + } + } + return ret; +} + +int issunstate_check_flag_result(l_scenes_list_v2_t* scene_node, struct tm* info, uint8_t flag_check) +{ + int ret = 0; + const uint8_t TIME_FLAG = (1 << 0); + const uint8_t WEEKDAYS_FLAG = (1 << 1); + const uint8_t DAYS_FLAG = (1 << 2); + const uint8_t MIDNIGHT_FLAG = (1 << 3); + const uint8_t MASK_TIME_FLAG = (1 << 4); + const uint8_t MASK_WEEKDAYS_FLAG = (1 << 5); + const uint8_t MASK_DAYS_FLAG = (1 << 6); + const uint8_t MASK_MIDNIGHT_FLAG = (1 << 7); + s_sunstate_data_t* user_data = (s_sunstate_data_t*)(scene_node->when_block->fields->user_arg); + if (user_data) + { + if ((0 != user_data->curr_tm_day) && (0 != user_data->sunstate_mode) && (flag_check & MASK_TIME_FLAG)) // defined_moment should have the current day + { + // 1. Set 'time-flag', when defined moment is matched : [sunrise/sunset_moment + offsets (if any)] + if ((info->tm_hour == user_data->defined_moment.tm_hour) && + (info->tm_min == user_data->defined_moment.tm_min) && + (info->tm_sec == user_data->defined_moment.tm_sec)) + { + flag_check |= TIME_FLAG; + } + // 2. Identify :- Daily or Monthly+weeekdays case + if (!(flag_check & MASK_DAYS_FLAG) && !(flag_check & MASK_WEEKDAYS_FLAG)) // without 'month_days' or 'week_days' condition + { + switch (flag_check) + { + case (MASK_MIDNIGHT_FLAG | MIDNIGHT_FLAG): // daily + midnight time? + case (TIME_FLAG): // daily + exact time? + { + ret = 1; + break; + } + default: + { + ret = 0; + break; + } + } + } + else // (flag_check & MASK_DAYS_FLAG) || (flag_check & MASK_WEEKDAYS_FLAG) // month_days + week_days conditons + { + // Output filter for triggered in sunset/sunrise time + switch (flag_check) + { + case ((MASK_DAYS_FLAG | DAYS_FLAG) | (MASK_WEEKDAYS_FLAG | WEEKDAYS_FLAG) | (MASK_MIDNIGHT_FLAG | MIDNIGHT_FLAG)): // mdays+weekday+midnight + case ((MASK_DAYS_FLAG | DAYS_FLAG) | (MASK_WEEKDAYS_FLAG | WEEKDAYS_FLAG) | (TIME_FLAG)): // mdays+weekday+exact + case ((MASK_DAYS_FLAG | DAYS_FLAG) | (MASK_MIDNIGHT_FLAG | MIDNIGHT_FLAG)): // mdays+midnight + case ((MASK_DAYS_FLAG | DAYS_FLAG) | (TIME_FLAG)): // mdays +exact + case ((MASK_WEEKDAYS_FLAG | WEEKDAYS_FLAG) | (MASK_MIDNIGHT_FLAG | MIDNIGHT_FLAG)): // weekday+midnight + case ((MASK_WEEKDAYS_FLAG | WEEKDAYS_FLAG) | (TIME_FLAG)): // weekday+exact + { + ret = 1; + break; + } + default: + { + ret = 0; // don't activate if above conditions aren't satisfied + break; + } + } + } + } + // TRACE_S("offset[%d](intime=0,before=1,after=2,undefined=3) , SunState[%d](sunrise=1,sunset=2) , FLAG_STATUS: %#x", (int)user_data->tmoffs_type, user_data->sunstate_mode, flag_check); + } + + return ret; +} +//--------------------------- ezlopi_scene_when_is_date_range ---------------------------------------- +void isdate_range_get_tm(l_fields_v2_t* curr_field, struct tm* tmp_tm) +{ + if ((EZLOPI_VALUE_TYPE_24_HOURS_TIME == curr_field->value_type) && (NULL != curr_field->field_value.u_value.value_string)) + { + char time[10]; + snprintf(time, 10, "%s", curr_field->field_value.u_value.value_string); + time[9] = '\0'; + char* ptr = NULL; + if (0 != strlen(time)) + { + tmp_tm->tm_hour = strtoul(time, &ptr, 10); + tmp_tm->tm_min = strtoul(ptr + 1, NULL, 10); + } + } +} +void isdate_range_get_startday(l_fields_v2_t* curr_field, struct tm* tmp_tm) +{ + if (EZLOPI_VALUE_TYPE_INT == curr_field->value_type) + { + tmp_tm->tm_mday = (curr_field->field_value.u_value.value_double) ? (int)(curr_field->field_value.u_value.value_double) : 1; + } +} +void isdate_range_get_endday(l_fields_v2_t* curr_field, struct tm* tmp_tm) +{ + if (EZLOPI_VALUE_TYPE_INT == curr_field->value_type) + { + tmp_tm->tm_mday = (curr_field->field_value.u_value.value_double) ? (int)(curr_field->field_value.u_value.value_double) : 31; + } +} +void isdate_range_get_startmonth(l_fields_v2_t* curr_field, struct tm* tmp_tm) +{ + if (EZLOPI_VALUE_TYPE_INT == curr_field->value_type) + { + tmp_tm->tm_mon = (curr_field->field_value.u_value.value_double) ? (int)(curr_field->field_value.u_value.value_double) : 1; + } +} +void isdate_range_get_endmonth(l_fields_v2_t* curr_field, struct tm* tmp_tm) +{ + if (EZLOPI_VALUE_TYPE_INT == curr_field->value_type) + { + tmp_tm->tm_mon = (curr_field->field_value.u_value.value_double) ? (int)(curr_field->field_value.u_value.value_double) : 12; + } +} +void isdate_range_get_startyear(l_fields_v2_t* curr_field, struct tm* tmp_tm) +{ + if (EZLOPI_VALUE_TYPE_INT == curr_field->value_type) + { + tmp_tm->tm_year = (curr_field->field_value.u_value.value_double) ? (int)(curr_field->field_value.u_value.value_double) : 1; + } +} +void isdate_range_get_endyear(l_fields_v2_t* curr_field, struct tm* tmp_tm) +{ + if (EZLOPI_VALUE_TYPE_INT == curr_field->value_type) + { + tmp_tm->tm_year = (curr_field->field_value.u_value.value_double) ? (int)(curr_field->field_value.u_value.value_double) : 2147483647; + } +} + +uint8_t isdate_range_check_tm(struct tm* start, struct tm* end, struct tm* info) +{ + uint8_t ret = 0; + // first confirm if the time range has positive or negative difference (end - start) + if ((end->tm_hour - start->tm_hour) > 0) + { + if ((info->tm_hour == start->tm_hour) && (info->tm_min >= start->tm_min)) + { + ret |= (1 << 0); + goto end; + } + else if ((info->tm_hour == end->tm_hour) && (info->tm_min <= end->tm_min)) + { + ret |= (1 << 0); + goto end; + } + else if ((info->tm_hour > start->tm_hour) && (info->tm_hour < end->tm_hour)) + { + ret |= (1 << 0); + goto end; + } + } + else + { // for inverted hours [ie. end(say): 2pm / start(say): 5pm ; take 'mday' into consideration] + if ((info->tm_mday >= start->tm_mday) && (info->tm_mday <= end->tm_mday)) + { + if (((info->tm_hour >= start->tm_hour) && (info->tm_hour <= end->tm_hour))) + { + ret |= (1 << 0); + } + } + else + { + TRACE_S("Invalid day-orders : start[%d] vs end[%d]", start->tm_mday, end->tm_mday); + } + } +end: + return ret; +} +uint8_t isdate_range_check_day(struct tm* start, struct tm* end, struct tm* info) +{ + uint8_t ret = 0; + if ((info->tm_mday >= start->tm_mday) && (info->tm_mday <= end->tm_mday)) + { + ret |= (1 << 1); + } + else + { + TRACE_S("Invalid day-orders : start[%d] vs end[%d]", start->tm_mday, end->tm_mday); + } + return ret; +} +uint8_t isdate_range_check_month(struct tm* start, struct tm* end, struct tm* info) +{ + uint8_t ret = 0; + if (((info->tm_mon + 1) >= start->tm_mon) && ((info->tm_mon + 1) <= end->tm_mon)) + { + ret |= (1 << 2); + } + else + { + TRACE_S("Invalid month-orders : start[%d] vs end[%d]", start->tm_mon, end->tm_mon); + } + return ret; +} +uint8_t isdate_range_check_year(struct tm* start, struct tm* end, struct tm* info) +{ + uint8_t ret = 0; + if (((info->tm_year + 1900) >= start->tm_year) && ((info->tm_year + 1900) <= end->tm_year)) + { + ret |= (1 << 2); + } + else + { + TRACE_S("Invalid year-orders : start[%d] vs end[%d]", start->tm_year, end->tm_year); + } + return ret; +} +int isdate_range_check_flag_result(uint8_t flag_check) +{ + const uint8_t TIME_FLAG = (1 << 0); + const uint8_t DAY_FLAG = (1 << 1); + const uint8_t MONTH_FLAG = (1 << 2); + const uint8_t YEAR_FLAG = (1 << 3); + + int ret = 0; + if ((flag_check & TIME_FLAG) && (flag_check & DAY_FLAG) && (flag_check & MONTH_FLAG) && (flag_check & YEAR_FLAG)) + { + ret = 1; + } + return ret; +} +//------------------------------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_when_methods_helper_functions.h b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_when_methods_helper_functions.h new file mode 100644 index 000000000..761da23df --- /dev/null +++ b/ezlopi-core/ezlopi-core-scenes/ezlopi_core_scenes_when_methods_helper_functions.h @@ -0,0 +1,87 @@ +#ifndef _EZLOPI_CORE_SCENES_WHEN_METHODS_HELPER_FUNCTIONS_H_ +#define _EZLOPI_CORE_SCENES_WHEN_METHODS_HELPER_FUNCTIONS_H_ +#include +#include +#include + +typedef enum e_isdate_modes +{ + ISDATE_DAILY_MODE = 0, + ISDATE_WEEKLY_MODE, + ISDATE_MONTHLY_MODE, + ISDATE_WEEKS_MODE, + ISDATE_YEAR_WEEKS_MODE, + ISDATE_UNDEFINED_MODE, +} e_isdate_modes_t; + +typedef enum e_isdate_range_method +{ + ISDATE_RANGE_TIME = 0, + ISDATE_RANGE_DAY, + ISDATE_RANGE_MONTH, + ISDATE_RANGE_YEAR, + ISDATE_RANGE_MAX, +} e_isdate_range_method_t; + +typedef struct s_isdate_method +{ + const char* field_name; + uint8_t(*field_func)(e_isdate_modes_t* mode_type, struct tm* info, l_fields_v2_t* curr_field); +} s_isdate_method_t; + +typedef struct s_issunstate_method +{ + const char* field_name; + uint8_t(*field_func)(l_scenes_list_v2_t* scene_node, l_fields_v2_t* curr_field, struct tm* info, uint8_t curr_sunstate_mode); +} s_issunstate_method_t; + +typedef struct s_isonce_method +{ + const char* field_name; + uint8_t(*field_func)(l_fields_v2_t* curr_field, struct tm* info); +} s_isonce_method_t; + +typedef struct s_isdate_range_method +{ + const char* field_name; + void (*field_func)(l_fields_v2_t* curr_field, struct tm* tmp_tm); +} s_isdate_range_method_t; +//------------------------------- ezlopi_scene_when_is_date ----------------------------------------------- +uint8_t isdate_type_check(e_isdate_modes_t* mode_type, struct tm* info, l_fields_v2_t* curr_field); +uint8_t isdate_tm_check(e_isdate_modes_t* mode_type, struct tm* info, l_fields_v2_t* curr_field); +uint8_t isdate_weekdays_check(e_isdate_modes_t* mode_type, struct tm* info, l_fields_v2_t* curr_field); +uint8_t isdate_mdays_check(e_isdate_modes_t* mode_type, struct tm* info, l_fields_v2_t* curr_field); +uint8_t isdate_year_weeks_check(e_isdate_modes_t* mode_type, struct tm* info, l_fields_v2_t* curr_field); +int isdate_check_flag_result(e_isdate_modes_t mode_type, uint8_t flag_check); + +//------------------------------- ezlopi_scene_when_is_SunState ------------------------------------------- +uint8_t issunstate_check_mdrn(uint8_t sunstate_mode, const char* range_type, struct tm* info, struct tm* defined_moment); +uint8_t issunstate_get_suntime(l_scenes_list_v2_t* scene_node, l_fields_v2_t* curr_field, struct tm* info, uint8_t curr_sunstate_mode); +uint8_t issunstate_get_offs_tmval(l_scenes_list_v2_t* scene_node, l_fields_v2_t* curr_field, struct tm* info, uint8_t curr_sunstate_mode); +uint8_t issunstate_eval_weekdays(l_scenes_list_v2_t* scene_node, l_fields_v2_t* curr_field, struct tm* info, uint8_t curr_sunstate_mode); +uint8_t issunstate_eval_days(l_scenes_list_v2_t* scene_node, l_fields_v2_t* curr_field, struct tm* info, uint8_t curr_sunstate_mode); +uint8_t issunstate_eval_range(l_scenes_list_v2_t* scene_node, l_fields_v2_t* curr_field, struct tm* info, uint8_t curr_sunstate_mode); +int issunstate_check_flag_result(l_scenes_list_v2_t* scene_node, struct tm* info, uint8_t flag_check); + +//------------------------------- ezlopi_scene_when_is_once --------------------------------------------------- +uint8_t isonce_tm_check(l_fields_v2_t* curr_field, struct tm* info); +uint8_t isonce_day_check(l_fields_v2_t* curr_field, struct tm* info); +uint8_t isonce_month_check(l_fields_v2_t* curr_field, struct tm* info); +uint8_t isonce_year_check(l_fields_v2_t* curr_field, struct tm* info); +int isonce_check_flag_result(l_scenes_list_v2_t* scene_node, uint8_t flag_check); + +//------------------------------- ezlopi_scene_when_is_date_range ----------------------------------------- +void isdate_range_get_tm(l_fields_v2_t* curr_field, struct tm* tmp_tm); +void isdate_range_get_startday(l_fields_v2_t* curr_field, struct tm* tmp_tm); +void isdate_range_get_endday(l_fields_v2_t* curr_field, struct tm* tmp_tm); +void isdate_range_get_startmonth(l_fields_v2_t* curr_field, struct tm* tmp_tm); +void isdate_range_get_endmonth(l_fields_v2_t* curr_field, struct tm* tmp_tm); +void isdate_range_get_startyear(l_fields_v2_t* curr_field, struct tm* tmp_tm); +void isdate_range_get_endyear(l_fields_v2_t* curr_field, struct tm* tmp_tm); +uint8_t isdate_range_check_tm(struct tm* start, struct tm* end, struct tm* info); +uint8_t isdate_range_check_day(struct tm* start, struct tm* end, struct tm* info); +uint8_t isdate_range_check_month(struct tm* start, struct tm* end, struct tm* info); +uint8_t isdate_range_check_year(struct tm* start, struct tm* end, struct tm* info); +int isdate_range_check_flag_result(uint8_t flag_check); + +#endif /*_EZLOPI_CORE_SCENES_WHEN_METHODS_HELPER_FUNCTIONS_H_*/ \ No newline at end of file diff --git a/ezlopi-core/ezlopi-core-websocket_client/ezlopi_core_websocket_client.c b/ezlopi-core/ezlopi-core-websocket_client/ezlopi_core_websocket_client.c index 1852b026d..6e0c53132 100644 --- a/ezlopi-core/ezlopi-core-websocket_client/ezlopi_core_websocket_client.c +++ b/ezlopi-core/ezlopi-core-websocket_client/ezlopi_core_websocket_client.c @@ -86,7 +86,7 @@ esp_websocket_client_handle_t ezlopi_websocket_client_init(cJSON* uri, void (*ms esp_websocket_client_config_t websocket_cfg = { .uri = uri->valuestring, .task_stack = 8 * 1024, - .buffer_size = 12 * 1024, + .buffer_size = 8 * 1024, .cert_pem = ca_cert, .client_cert = ssl_shared, .client_key = ssl_priv, @@ -107,7 +107,7 @@ esp_websocket_client_handle_t ezlopi_websocket_client_init(cJSON* uri, void (*ms { free(ca_cert); free(ssl_shared); - free(ssl_shared); + free(ssl_priv); } } else diff --git a/ezlopi-main/Kconfig.projbuild b/ezlopi-main/Kconfig.projbuild index 9e100a9b7..2163be879 100644 --- a/ezlopi-main/Kconfig.projbuild +++ b/ezlopi-main/Kconfig.projbuild @@ -1,5 +1,11 @@ menu "EzloPi User Config" + + config EZPI_DEV_TYPE_TEST + bool "Run device in test mode" + default n + help + Run the device in test mode config EZPI_UTIL_ENABLE_TRACE bool "Enable trace component for logging" diff --git a/ezlopi-main/ezlopi_main.c b/ezlopi-main/ezlopi_main.c index 57d934aad..019b6760f 100644 --- a/ezlopi-main/ezlopi_main.c +++ b/ezlopi-main/ezlopi_main.c @@ -22,6 +22,8 @@ #include "ezlopi_service_ws_server.h" #include "ezlopi_service_broadcast.h" +#include "ezlopi_core_ble_config.h" + #define ENABLE_HEARTBIT_LED 0 static void blinky(void* pv); @@ -85,4 +87,4 @@ static void blinky(void* pv) vTaskDelay(1000 / portTICK_PERIOD_MS); } -} + } diff --git a/ezlopi-sensors-devices/device-0004-digitalIn-generic/device_0004_digitalIn_generic.c b/ezlopi-sensors-devices/device-0004-digitalIn-generic/device_0004_digitalIn_generic.c index a60999a43..29c0c2101 100644 --- a/ezlopi-sensors-devices/device-0004-digitalIn-generic/device_0004_digitalIn_generic.c +++ b/ezlopi-sensors-devices/device-0004-digitalIn-generic/device_0004_digitalIn_generic.c @@ -15,12 +15,12 @@ #include "ezlopi_service_gpioisr.h" #include "device_0004_digitalIn_generic.h" -static int __prepare(void *arg); -static int __init(l_ezlopi_item_t *item); -static void __interrupt_upcall(void *arg); -static int __get_value_cjson(l_ezlopi_item_t *item, void *arg); +static int __prepare(void* arg); +static int __init(l_ezlopi_item_t* item); +static void __interrupt_upcall(void* arg); +static int __get_value_cjson(l_ezlopi_item_t* item, void* arg); -int device_0004_digitalIn_generic(e_ezlopi_actions_t action, l_ezlopi_item_t *item, void *arg, void *user_arg) +int device_0004_digitalIn_generic(e_ezlopi_actions_t action, l_ezlopi_item_t* item, void* arg, void* user_arg) { int ret = 0; @@ -57,7 +57,7 @@ int device_0004_digitalIn_generic(e_ezlopi_actions_t action, l_ezlopi_item_t *it return ret; } -static void __setup_device_cloud_properties(l_ezlopi_device_t *device, cJSON *cjson_device) +static void __setup_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cjson_device) { // char *device_name = NULL; // CJSON_GET_VALUE_STRING(cjson_device, ezlopi_dev_name_str, device_name); @@ -71,7 +71,7 @@ static void __setup_device_cloud_properties(l_ezlopi_device_t *device, cJSON *cj device->cloud_properties.device_type_id = NULL; } -static void __setup_item_properties(l_ezlopi_item_t *item, cJSON *cjson_device) +static void __setup_item_properties(l_ezlopi_item_t* item, cJSON* cjson_device) { int tmp_var = 0; item->cloud_properties.has_getter = true; @@ -91,20 +91,20 @@ static void __setup_item_properties(l_ezlopi_item_t *item, cJSON *cjson_device) item->interface.gpio.gpio_in.interrupt = GPIO_INTR_DISABLE; } -static int __prepare(void *arg) +static int __prepare(void* arg) { int ret = 0; if (arg) { - s_ezlopi_prep_arg_t *prep_arg = (s_ezlopi_prep_arg_t *)arg; - cJSON *cjson_device = prep_arg->cjson_device; + s_ezlopi_prep_arg_t* prep_arg = (s_ezlopi_prep_arg_t*)arg; + cJSON* cjson_device = prep_arg->cjson_device; if (cjson_device) { - l_ezlopi_device_t *device = ezlopi_device_add_device(cjson_device); + l_ezlopi_device_t* device = ezlopi_device_add_device(cjson_device); if (device) { __setup_device_cloud_properties(device, cjson_device); - l_ezlopi_item_t *item = ezlopi_device_add_item_to_device(device, device_0004_digitalIn_generic); + l_ezlopi_item_t* item = ezlopi_device_add_item_to_device(device, device_0004_digitalIn_generic); if (item) { item->cloud_properties.device_id = device->cloud_properties.device_id; @@ -123,7 +123,7 @@ static int __prepare(void *arg) return ret; } -static int __init(l_ezlopi_item_t *item) +static int __init(l_ezlopi_item_t* item) { int ret = 0; if (item) @@ -168,12 +168,12 @@ static int __init(l_ezlopi_item_t *item) return ret; } -static int __get_value_cjson(l_ezlopi_item_t *item, void *arg) +static int __get_value_cjson(l_ezlopi_item_t* item, void* arg) { int ret = 0; if (item && arg) { - cJSON *cjson_propertise = (cJSON *)arg; + cJSON* cjson_propertise = (cJSON*)arg; if (cjson_propertise) { cJSON_AddBoolToObject(cjson_propertise, ezlopi_value_str, item->interface.gpio.gpio_in.value); @@ -185,9 +185,9 @@ static int __get_value_cjson(l_ezlopi_item_t *item, void *arg) return ret; } -static void __interrupt_upcall(void *arg) +static void __interrupt_upcall(void* arg) { - l_ezlopi_item_t *item = (l_ezlopi_item_t *)arg; + l_ezlopi_item_t* item = (l_ezlopi_item_t*)arg; if (item) { item->interface.gpio.gpio_in.value = !item->interface.gpio.gpio_in.value; diff --git a/ezlopi-sensors-devices/device-0009-other-RMT-SK6812/device_0009_other_RMT_SK6812.c b/ezlopi-sensors-devices/device-0009-other-RMT-SK6812/device_0009_other_RMT_SK6812.c index b02dd96f5..2dd86a931 100644 --- a/ezlopi-sensors-devices/device-0009-other-RMT-SK6812/device_0009_other_RMT_SK6812.c +++ b/ezlopi-sensors-devices/device-0009-other-RMT-SK6812/device_0009_other_RMT_SK6812.c @@ -133,8 +133,7 @@ static int __set_cjson_value(l_ezlopi_item_t* item, void* arg) { cJSON* cjson_params = (cJSON*)arg; s_dimmer_args_t* dimmer_args = (s_dimmer_args_t*)item->user_arg; - - if (NULL != dimmer_args) + if ((dimmer_args) && (cjson_params)) { if (ezlopi_item_name_rgbcolor == item->cloud_properties.item_name) { @@ -232,25 +231,26 @@ static int __init(l_ezlopi_item_t* item) ret = -1; free(item->user_arg); // this will free ; memory address linked to all items item->user_arg = NULL; + ezlopi_device_free_device_by_item(item); } } } - else - { - ret = -1; - ezlopi_device_free_device_by_item(item); - } - } - else - { - ret = -1; - ezlopi_device_free_device_by_item(item); + // else + // { + // ret = -1; + // ezlopi_device_free_device_by_item(item); + // } } + // else + // { + // ret = -1; + // ezlopi_device_free_device_by_item(item); + // } } - return ret; } + static void __prepare_device_properties(l_ezlopi_device_t* device, cJSON* cj_device) { // char *device_name = NULL; @@ -270,8 +270,8 @@ static void __prepare_SK6812_RGB_color_item(l_ezlopi_item_t* item, cJSON* cj_dev item->cloud_properties.has_getter = true; item->cloud_properties.has_setter = true; item->cloud_properties.item_id = ezlopi_cloud_generate_item_id(); - item->cloud_properties.item_name = ezlopi_item_name_rgbcolor, - item->cloud_properties.show = true; + item->cloud_properties.item_name = ezlopi_item_name_rgbcolor; + item->cloud_properties.show = true; item->cloud_properties.scale = NULL; item->cloud_properties.value_type = value_type_rgb; item->interface_type = EZLOPI_DEVICE_INTERFACE_PWM; @@ -288,8 +288,8 @@ static void __prepare_SK6812_RGB_dimmer_item(l_ezlopi_item_t* item, cJSON* cj_de item->cloud_properties.has_getter = true; item->cloud_properties.has_setter = true; item->cloud_properties.item_id = ezlopi_cloud_generate_item_id(); - item->cloud_properties.item_name = ezlopi_item_name_dimmer, - item->cloud_properties.show = true; + item->cloud_properties.item_name = ezlopi_item_name_dimmer; + item->cloud_properties.show = true; item->cloud_properties.scale = NULL; item->cloud_properties.value_type = value_type_int; item->interface_type = EZLOPI_DEVICE_INTERFACE_PWM; @@ -357,8 +357,8 @@ static void __prepare_SK6812_LED_onoff_switch_item(l_ezlopi_item_t* item, cJSON* item->cloud_properties.has_getter = true; item->cloud_properties.has_setter = true; item->cloud_properties.item_id = ezlopi_cloud_generate_item_id(); - item->cloud_properties.item_name = ezlopi_item_name_switch, - item->cloud_properties.show = true; + item->cloud_properties.item_name = ezlopi_item_name_switch; + item->cloud_properties.show = true; item->cloud_properties.scale = NULL; item->cloud_properties.value_type = value_type_bool; item->interface_type = EZLOPI_DEVICE_INTERFACE_DIGITAL_OUTPUT; diff --git a/ezlopi-sensors-devices/device-0022-PWM-dimmable-lamp/device_0022_PWM_dimmable_lamp.c b/ezlopi-sensors-devices/device-0022-PWM-dimmable-lamp/device_0022_PWM_dimmable_lamp.c index 5f4e166e1..dea030fa9 100644 --- a/ezlopi-sensors-devices/device-0022-PWM-dimmable-lamp/device_0022_PWM_dimmable_lamp.c +++ b/ezlopi-sensors-devices/device-0022-PWM-dimmable-lamp/device_0022_PWM_dimmable_lamp.c @@ -258,17 +258,17 @@ static int __init(l_ezlopi_item_t* item) } } } - else - { - ret = -1; - ezlopi_device_free_device_by_item(item); - } - } - else - { - ret = -1; - ezlopi_device_free_device_by_item(item); + // else + // { + // ret = -1; + // ezlopi_device_free_device_by_item(item); + // } } + // else + // { + // ret = -1; + // ezlopi_device_free_device_by_item(item); + // } } return ret; } diff --git a/ezlopi-sensors-devices/device-0036-PWM-servo-MG996R/device_0036_PWM_servo_MG996R.c b/ezlopi-sensors-devices/device-0036-PWM-servo-MG996R/device_0036_PWM_servo_MG996R.c index 720d46d32..258e9ffde 100644 --- a/ezlopi-sensors-devices/device-0036-PWM-servo-MG996R/device_0036_PWM_servo_MG996R.c +++ b/ezlopi-sensors-devices/device-0036-PWM-servo-MG996R/device_0036_PWM_servo_MG996R.c @@ -13,15 +13,15 @@ #include "device_0036_PWM_servo_MG996R.h" -static int __prepare(void *arg); -static int __init(l_ezlopi_item_t *item); -static int __get_cjson_value(l_ezlopi_item_t *item, void *arg); -static int __set_cjson_value(l_ezlopi_item_t *item, void *arg); +static int __prepare(void* arg); +static int __init(l_ezlopi_item_t* item); +static int __get_cjson_value(l_ezlopi_item_t* item, void* arg); +static int __set_cjson_value(l_ezlopi_item_t* item, void* arg); -static void __prepare_device_cloud_properties(l_ezlopi_device_t *device, cJSON *cj_device); -static void __prepare_item_cloud_properties(l_ezlopi_item_t *item, cJSON *cj_device); +static void __prepare_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device); +static void __prepare_item_cloud_properties(l_ezlopi_item_t* item, cJSON* cj_device); -int device_0036_PWM_servo_MG996R(e_ezlopi_actions_t action, l_ezlopi_item_t *item, void *arg, void *user_arg) +int device_0036_PWM_servo_MG996R(e_ezlopi_actions_t action, l_ezlopi_item_t* item, void* arg, void* user_arg) { int ret = 0; @@ -54,10 +54,10 @@ int device_0036_PWM_servo_MG996R(e_ezlopi_actions_t action, l_ezlopi_item_t *ite return ret; } -static void __prepare_device_cloud_properties(l_ezlopi_device_t *device, cJSON *cj_device) +static void __prepare_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device) { - char *device_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", device_name); + char* device_name = NULL; + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, device_name); ASSIGN_DEVICE_NAME_V2(device, device_name); device->cloud_properties.device_id = ezlopi_cloud_generate_device_id(); device->cloud_properties.category = category_dimmable_light; @@ -67,7 +67,7 @@ static void __prepare_device_cloud_properties(l_ezlopi_device_t *device, cJSON * device->cloud_properties.device_type_id = NULL; } -static void __prepare_item_cloud_properties(l_ezlopi_item_t *item, cJSON *cj_device) +static void __prepare_item_cloud_properties(l_ezlopi_item_t* item, cJSON* cj_device) { CJSON_GET_VALUE_INT(cj_device, ezlopi_dev_type_str, item->interface_type); item->cloud_properties.item_name = ezlopi_item_name_dimmer; @@ -88,20 +88,20 @@ static void __prepare_item_cloud_properties(l_ezlopi_item_t *item, cJSON *cj_dev #endif } -static int __prepare(void *arg) +static int __prepare(void* arg) { int ret = 0; - s_ezlopi_prep_arg_t *dev_prep_arg = (s_ezlopi_prep_arg_t *)arg; + s_ezlopi_prep_arg_t* dev_prep_arg = (s_ezlopi_prep_arg_t*)arg; if (dev_prep_arg->cjson_device) { - cJSON *cj_device = dev_prep_arg->cjson_device; + cJSON* cj_device = dev_prep_arg->cjson_device; - l_ezlopi_device_t *servo_device = ezlopi_device_add_device(dev_prep_arg->cjson_device); + l_ezlopi_device_t* servo_device = ezlopi_device_add_device(dev_prep_arg->cjson_device); if (servo_device) { __prepare_device_cloud_properties(servo_device, cj_device); - l_ezlopi_item_t *servo_item = ezlopi_device_add_item_to_device(servo_device, device_0036_PWM_servo_MG996R); + l_ezlopi_item_t* servo_item = ezlopi_device_add_item_to_device(servo_device, device_0036_PWM_servo_MG996R); if (servo_item) { __prepare_item_cloud_properties(servo_item, cj_device); @@ -116,7 +116,7 @@ static int __prepare(void *arg) return ret; } -static int __init(l_ezlopi_item_t *item) +static int __init(l_ezlopi_item_t* item) { int ret = 0; if (item) @@ -146,7 +146,7 @@ static int __init(l_ezlopi_item_t *item) return ret; } -static int __set_cjson_value(l_ezlopi_item_t *item, void *arg) +static int __set_cjson_value(l_ezlopi_item_t* item, void* arg) { int ret = 0; if (item && arg) @@ -172,7 +172,7 @@ static int __set_cjson_value(l_ezlopi_item_t *item, void *arg) return ret; } -static int __get_cjson_value(l_ezlopi_item_t *item, void *arg) +static int __get_cjson_value(l_ezlopi_item_t* item, void* arg) { int ret = 0; if (item && arg) @@ -226,13 +226,13 @@ static int __get_cjson_value(l_ezlopi_item_t *item, void *arg) #include "device_0036_PWM_servo_MG996R.h" -static int ezlopi_servo_motor_MG_996R_prepare_and_add(void *args); -static s_ezlopi_device_properties_t *ezlopi_servo_motor_MG_996R_prepare(cJSON *cjson_device); -static int ezlopi_servo_motor_MG_996R_init(s_ezlopi_device_properties_t *properties); -static int ezlopi_servo_motor_MG_996R_get_value_cjson(s_ezlopi_device_properties_t *properties, void *args); -static int ezlopi_servo_motor_MG_996R_set_value(s_ezlopi_device_properties_t *properties, void *arg); +static int ezlopi_servo_motor_MG_996R_prepare_and_add(void* args); +static s_ezlopi_device_properties_t* ezlopi_servo_motor_MG_996R_prepare(cJSON* cjson_device); +static int ezlopi_servo_motor_MG_996R_init(s_ezlopi_device_properties_t* properties); +static int ezlopi_servo_motor_MG_996R_get_value_cjson(s_ezlopi_device_properties_t* properties, void* args); +static int ezlopi_servo_motor_MG_996R_set_value(s_ezlopi_device_properties_t* properties, void* arg); -int ezlopi_servo_motor_MG_996R(e_ezlopi_actions_t action, s_ezlopi_device_properties_t *ezlo_device, void *arg, void *user_arg) +int ezlopi_servo_motor_MG_996R(e_ezlopi_actions_t action, s_ezlopi_device_properties_t* ezlo_device, void* arg, void* user_arg) { int ret = 0; @@ -267,14 +267,14 @@ int ezlopi_servo_motor_MG_996R(e_ezlopi_actions_t action, s_ezlopi_device_proper return ret; } -static int ezlopi_servo_motor_MG_996R_prepare_and_add(void *args) +static int ezlopi_servo_motor_MG_996R_prepare_and_add(void* args) { int ret = 0; - s_ezlopi_prep_arg_t *device_prep_arg = (s_ezlopi_prep_arg_t *)args; + s_ezlopi_prep_arg_t* device_prep_arg = (s_ezlopi_prep_arg_t*)args; if ((NULL != device_prep_arg) && (NULL != device_prep_arg->cjson_device)) { - s_ezlopi_device_properties_t *ezlopi_servo_motor_MG_996R_properties = ezlopi_servo_motor_MG_996R_prepare(device_prep_arg->cjson_device); + s_ezlopi_device_properties_t* ezlopi_servo_motor_MG_996R_properties = ezlopi_servo_motor_MG_996R_prepare(device_prep_arg->cjson_device); if (ezlopi_servo_motor_MG_996R_properties) { if (0 == ezlopi_devices_list_add(device_prep_arg->device, ezlopi_servo_motor_MG_996R_properties, NULL)) @@ -291,9 +291,9 @@ static int ezlopi_servo_motor_MG_996R_prepare_and_add(void *args) return ret; } -static s_ezlopi_device_properties_t *ezlopi_servo_motor_MG_996R_prepare(cJSON *cjson_device) +static s_ezlopi_device_properties_t* ezlopi_servo_motor_MG_996R_prepare(cJSON* cjson_device) { - s_ezlopi_device_properties_t *ezlopi_servo_motor_MG_996R_properties = malloc(sizeof(s_ezlopi_device_properties_t)); + s_ezlopi_device_properties_t* ezlopi_servo_motor_MG_996R_properties = malloc(sizeof(s_ezlopi_device_properties_t)); if (ezlopi_servo_motor_MG_996R_properties) { @@ -336,14 +336,14 @@ static s_ezlopi_device_properties_t *ezlopi_servo_motor_MG_996R_prepare(cJSON *c return ezlopi_servo_motor_MG_996R_properties; } -static int ezlopi_servo_motor_MG_996R_init(s_ezlopi_device_properties_t *properties) +static int ezlopi_servo_motor_MG_996R_init(s_ezlopi_device_properties_t* properties) { int ret = -1; - static s_ezlopi_channel_speed_t *ezlopi_servo_motor_MG_996R_speed = NULL; + static s_ezlopi_channel_speed_t* ezlopi_servo_motor_MG_996R_speed = NULL; if (GPIO_IS_VALID_GPIO(properties->interface.pwm.gpio_num)) { ezlopi_servo_motor_MG_996R_speed = ezlopi_pwm_init(properties->interface.pwm.gpio_num, properties->interface.pwm.pwm_resln, - properties->interface.pwm.freq_hz, properties->interface.pwm.duty_cycle); + properties->interface.pwm.freq_hz, properties->interface.pwm.duty_cycle); properties->interface.pwm.channel = ezlopi_servo_motor_MG_996R_speed->channel; properties->interface.pwm.speed_mode = ezlopi_servo_motor_MG_996R_speed->speed_mode; ret = 0; @@ -351,10 +351,10 @@ static int ezlopi_servo_motor_MG_996R_init(s_ezlopi_device_properties_t *propert return ret; } -static int ezlopi_servo_motor_MG_996R_set_value(s_ezlopi_device_properties_t *properties, void *arg) +static int ezlopi_servo_motor_MG_996R_set_value(s_ezlopi_device_properties_t* properties, void* arg) { int ret = 0; - cJSON *cjson_params = (cJSON *)arg; + cJSON* cjson_params = (cJSON*)arg; if (NULL != cjson_params) { @@ -375,10 +375,10 @@ static int ezlopi_servo_motor_MG_996R_set_value(s_ezlopi_device_properties_t *pr return ret; } -static int ezlopi_servo_motor_MG_996R_get_value_cjson(s_ezlopi_device_properties_t *properties, void *args) +static int ezlopi_servo_motor_MG_996R_get_value_cjson(s_ezlopi_device_properties_t* properties, void* args) { int ret = 0; - cJSON *cjson_propertise = (cJSON *)args; + cJSON* cjson_propertise = (cJSON*)args; if (cjson_propertise) { uint32_t duty = ezlopi_pwm_get_duty(properties->interface.pwm.channel, properties->interface.pwm.speed_mode); diff --git a/ezlopi-sensors-devices/sensor-0005-I2C-MPU6050/sensor_0005_I2C_MPU6050.c b/ezlopi-sensors-devices/sensor-0005-I2C-MPU6050/sensor_0005_I2C_MPU6050.c index 0c2b74606..afd74f048 100644 --- a/ezlopi-sensors-devices/sensor-0005-I2C-MPU6050/sensor_0005_I2C_MPU6050.c +++ b/ezlopi-sensors-devices/sensor-0005-I2C-MPU6050/sensor_0005_I2C_MPU6050.c @@ -14,16 +14,16 @@ #include "sensor_0005_I2C_MPU6050.h" -static int __prepare(void *arg); -static int __init(l_ezlopi_item_t *item); -static int __get_cjson_value(l_ezlopi_item_t *item, void *arg); -static int __notify(l_ezlopi_item_t *item); -static void __prepare_device_cloud_properties(l_ezlopi_device_t *device, cJSON *cj_device); -static void __prepare_item_cloud_properties(l_ezlopi_item_t *item, void *user_data); -static void __prepare_item_interface_properties(l_ezlopi_item_t *item, cJSON *cj_device); -static void __mpu6050_calibration_task(void *params); +static int __prepare(void* arg); +static int __init(l_ezlopi_item_t* item); +static int __get_cjson_value(l_ezlopi_item_t* item, void* arg); +static int __notify(l_ezlopi_item_t* item); +static void __prepare_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device); +static void __prepare_item_cloud_properties(l_ezlopi_item_t* item, void* user_data); +static void __prepare_item_interface_properties(l_ezlopi_item_t* item, cJSON* cj_device); +static void __mpu6050_calibration_task(void* params); //------------------------------------------------------------------------------------------------------------------------------------------------------------ -int sensor_0005_I2C_MPU6050(e_ezlopi_actions_t action, l_ezlopi_item_t *item, void *arg, void *user_arg) +int sensor_0005_I2C_MPU6050(e_ezlopi_actions_t action, l_ezlopi_item_t* item, void* arg, void* user_arg) { int ret = 0; switch (action) @@ -58,10 +58,10 @@ int sensor_0005_I2C_MPU6050(e_ezlopi_actions_t action, l_ezlopi_item_t *item, vo } //------------------------------------------------------------------------------------------------------------------------------------------------------------ -static void __prepare_device_cloud_properties(l_ezlopi_device_t *device, cJSON *cj_device) +static void __prepare_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device) { - char *device_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", device_name); + char* device_name = NULL; + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, device_name); ASSIGN_DEVICE_NAME_V2(device, device_name); device->cloud_properties.device_id = ezlopi_cloud_generate_device_id(); device->cloud_properties.category = category_level_sensor; @@ -70,7 +70,7 @@ static void __prepare_device_cloud_properties(l_ezlopi_device_t *device, cJSON * device->cloud_properties.info = NULL; device->cloud_properties.device_type_id = NULL; } -static void __prepare_item_cloud_properties(l_ezlopi_item_t *item, void *user_data) +static void __prepare_item_cloud_properties(l_ezlopi_item_t* item, void* user_data) { if (item) { @@ -81,7 +81,7 @@ static void __prepare_item_cloud_properties(l_ezlopi_item_t *item, void *user_da item->user_arg = user_data; } } -static void __prepare_item_interface_properties(l_ezlopi_item_t *item, cJSON *cj_device) +static void __prepare_item_interface_properties(l_ezlopi_item_t* item, cJSON* cj_device) { if (item && cj_device) { @@ -106,22 +106,22 @@ static void __prepare_item_interface_properties(l_ezlopi_item_t *item, cJSON *cj } } -static int __prepare(void *arg) +static int __prepare(void* arg) { int ret = 0; - s_ezlopi_prep_arg_t *prep_arg = (s_ezlopi_prep_arg_t *)arg; + s_ezlopi_prep_arg_t* prep_arg = (s_ezlopi_prep_arg_t*)arg; if (prep_arg && prep_arg->cjson_device) { - cJSON *cj_device = prep_arg->cjson_device; - s_mpu6050_data_t *user_data = (s_mpu6050_data_t *)malloc(sizeof(s_mpu6050_data_t)); + cJSON* cj_device = prep_arg->cjson_device; + s_mpu6050_data_t* user_data = (s_mpu6050_data_t*)malloc(sizeof(s_mpu6050_data_t)); if (NULL != user_data) { memset(user_data, 0, sizeof(s_mpu6050_data_t)); - l_ezlopi_device_t *mpu6050_device = ezlopi_device_add_device(cj_device); + l_ezlopi_device_t* mpu6050_device = ezlopi_device_add_device(cj_device); if (mpu6050_device) { __prepare_device_cloud_properties(mpu6050_device, cj_device); - l_ezlopi_item_t *mpu6050_acc_x_item = ezlopi_device_add_item_to_device(mpu6050_device, sensor_0005_I2C_MPU6050); + l_ezlopi_item_t* mpu6050_acc_x_item = ezlopi_device_add_item_to_device(mpu6050_device, sensor_0005_I2C_MPU6050); if (mpu6050_acc_x_item) { __prepare_item_cloud_properties(mpu6050_acc_x_item, user_data); @@ -130,7 +130,7 @@ static int __prepare(void *arg) mpu6050_acc_x_item->cloud_properties.scale = scales_meter_per_square_second; __prepare_item_interface_properties(mpu6050_acc_x_item, cj_device); } - l_ezlopi_item_t *mpu6050_acc_y_item = ezlopi_device_add_item_to_device(mpu6050_device, sensor_0005_I2C_MPU6050); + l_ezlopi_item_t* mpu6050_acc_y_item = ezlopi_device_add_item_to_device(mpu6050_device, sensor_0005_I2C_MPU6050); if (mpu6050_acc_y_item) { __prepare_item_cloud_properties(mpu6050_acc_y_item, user_data); @@ -139,7 +139,7 @@ static int __prepare(void *arg) mpu6050_acc_y_item->cloud_properties.scale = scales_meter_per_square_second; __prepare_item_interface_properties(mpu6050_acc_y_item, cj_device); } - l_ezlopi_item_t *mpu6050_acc_z_item = ezlopi_device_add_item_to_device(mpu6050_device, sensor_0005_I2C_MPU6050); + l_ezlopi_item_t* mpu6050_acc_z_item = ezlopi_device_add_item_to_device(mpu6050_device, sensor_0005_I2C_MPU6050); if (mpu6050_acc_z_item) { __prepare_item_cloud_properties(mpu6050_acc_z_item, user_data); @@ -149,7 +149,7 @@ static int __prepare(void *arg) __prepare_item_interface_properties(mpu6050_acc_z_item, cj_device); } - l_ezlopi_item_t *mpu6050_temp_item = ezlopi_device_add_item_to_device(mpu6050_device, sensor_0005_I2C_MPU6050); + l_ezlopi_item_t* mpu6050_temp_item = ezlopi_device_add_item_to_device(mpu6050_device, sensor_0005_I2C_MPU6050); if (mpu6050_temp_item) { __prepare_item_cloud_properties(mpu6050_temp_item, user_data); @@ -159,7 +159,7 @@ static int __prepare(void *arg) __prepare_item_interface_properties(mpu6050_temp_item, cj_device); } - l_ezlopi_item_t *mpu6050_gyro_x_item = ezlopi_device_add_item_to_device(mpu6050_device, sensor_0005_I2C_MPU6050); + l_ezlopi_item_t* mpu6050_gyro_x_item = ezlopi_device_add_item_to_device(mpu6050_device, sensor_0005_I2C_MPU6050); if (mpu6050_gyro_x_item) { __prepare_item_cloud_properties(mpu6050_gyro_x_item, user_data); @@ -168,7 +168,7 @@ static int __prepare(void *arg) mpu6050_gyro_x_item->cloud_properties.scale = scales_revolutions_per_minute; __prepare_item_interface_properties(mpu6050_gyro_x_item, cj_device); } - l_ezlopi_item_t *mpu6050_gyro_y_item = ezlopi_device_add_item_to_device(mpu6050_device, sensor_0005_I2C_MPU6050); + l_ezlopi_item_t* mpu6050_gyro_y_item = ezlopi_device_add_item_to_device(mpu6050_device, sensor_0005_I2C_MPU6050); if (mpu6050_gyro_y_item) { __prepare_item_cloud_properties(mpu6050_gyro_y_item, user_data); @@ -177,7 +177,7 @@ static int __prepare(void *arg) mpu6050_gyro_y_item->cloud_properties.scale = scales_revolutions_per_minute; __prepare_item_interface_properties(mpu6050_gyro_y_item, cj_device); } - l_ezlopi_item_t *mpu6050_gyro_z_item = ezlopi_device_add_item_to_device(mpu6050_device, sensor_0005_I2C_MPU6050); + l_ezlopi_item_t* mpu6050_gyro_z_item = ezlopi_device_add_item_to_device(mpu6050_device, sensor_0005_I2C_MPU6050); if (mpu6050_gyro_z_item) { __prepare_item_cloud_properties(mpu6050_gyro_z_item, user_data); @@ -205,7 +205,7 @@ static int __prepare(void *arg) return ret; } -static int __init(l_ezlopi_item_t *item) +static int __init(l_ezlopi_item_t* item) { int ret = 0; if (item) @@ -240,7 +240,7 @@ static int __init(l_ezlopi_item_t *item) return ret; } -static int __get_cjson_value(l_ezlopi_item_t *item, void *arg) +static int __get_cjson_value(l_ezlopi_item_t* item, void* arg) { int ret = 0; if (item && arg) @@ -335,7 +335,7 @@ static int __get_cjson_value(l_ezlopi_item_t *item, void *arg) return ret; } -static int __notify(l_ezlopi_item_t *item) +static int __notify(l_ezlopi_item_t* item) { static float __prev[7]; int ret = 0; @@ -417,10 +417,10 @@ static int __notify(l_ezlopi_item_t *item) return ret; } -static void __mpu6050_calibration_task(void *params) // calibrate task +static void __mpu6050_calibration_task(void* params) // calibrate task { vTaskDelay(4000 / portTICK_PERIOD_MS); - l_ezlopi_item_t *item = (l_ezlopi_item_t *)params; + l_ezlopi_item_t* item = (l_ezlopi_item_t*)params; if (item) { s_mpu6050_data_t *user_data = (s_mpu6050_data_t *)item->user_arg; diff --git a/ezlopi-sensors-devices/sensor-0006-I2C-ADXL345/sensor_0006_I2C_ADXL345.c b/ezlopi-sensors-devices/sensor-0006-I2C-ADXL345/sensor_0006_I2C_ADXL345.c index 5ea709e43..6e710f572 100644 --- a/ezlopi-sensors-devices/sensor-0006-I2C-ADXL345/sensor_0006_I2C_ADXL345.c +++ b/ezlopi-sensors-devices/sensor-0006-I2C-ADXL345/sensor_0006_I2C_ADXL345.c @@ -59,7 +59,7 @@ int sensor_0006_I2C_ADXL345(e_ezlopi_actions_t action, l_ezlopi_item_t* item, vo static void __prepare_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device) { char* device_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", device_name); + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, device_name); ASSIGN_DEVICE_NAME_V2(device, device_name); device->cloud_properties.device_id = ezlopi_cloud_generate_device_id(); device->cloud_properties.category = category_level_sensor; @@ -166,7 +166,7 @@ static int __init(l_ezlopi_item_t* item) int ret = 0; if (item) { - s_adxl345_data_t *user_data = (s_adxl345_data_t *)item->user_arg; + s_adxl345_data_t* user_data = (s_adxl345_data_t*)item->user_arg; if (user_data) { if (item->interface.i2c_master.enable) @@ -201,18 +201,18 @@ static int __get_cjson_value(l_ezlopi_item_t* item, void* arg) int ret = 0; if (item && arg) { - cJSON *cj_result = (cJSON *)arg; + cJSON* cj_result = (cJSON*)arg; if (cj_result) { float acceleration_value = 0; - s_adxl345_data_t *user_data = (s_adxl345_data_t *)item->user_arg; + s_adxl345_data_t* user_data = (s_adxl345_data_t*)item->user_arg; if (user_data) { if (ezlopi_item_name_acceleration_x_axis == item->cloud_properties.item_name) { acceleration_value = (user_data->acc_x * ADXL345_CONVERTER_FACTOR_MG_TO_G * ADXL345_STANDARD_G_TO_ACCEL_CONVERSION_VALUE); cJSON_AddNumberToObject(cj_result, ezlopi_value_str, acceleration_value); - char *valueFormatted = ezlopi_valueformatter_float(acceleration_value); + char* valueFormatted = ezlopi_valueformatter_float(acceleration_value); if (valueFormatted) { cJSON_AddStringToObject(cj_result, ezlopi_valueFormatted_str, valueFormatted); @@ -223,7 +223,7 @@ static int __get_cjson_value(l_ezlopi_item_t* item, void* arg) { acceleration_value = (user_data->acc_y * ADXL345_CONVERTER_FACTOR_MG_TO_G * ADXL345_STANDARD_G_TO_ACCEL_CONVERSION_VALUE); cJSON_AddNumberToObject(cj_result, ezlopi_value_str, acceleration_value); - char *valueFormatted = ezlopi_valueformatter_float(acceleration_value); + char* valueFormatted = ezlopi_valueformatter_float(acceleration_value); if (valueFormatted) { cJSON_AddStringToObject(cj_result, ezlopi_valueFormatted_str, valueFormatted); @@ -234,7 +234,7 @@ static int __get_cjson_value(l_ezlopi_item_t* item, void* arg) { acceleration_value = (user_data->acc_z * ADXL345_CONVERTER_FACTOR_MG_TO_G * ADXL345_STANDARD_G_TO_ACCEL_CONVERSION_VALUE); cJSON_AddNumberToObject(cj_result, ezlopi_value_str, acceleration_value); - char *valueFormatted = ezlopi_valueformatter_float(acceleration_value); + char* valueFormatted = ezlopi_valueformatter_float(acceleration_value); if (valueFormatted) { cJSON_AddStringToObject(cj_result, ezlopi_valueFormatted_str, valueFormatted); @@ -254,7 +254,7 @@ static int __notify(l_ezlopi_item_t* item) static float __prev[3] = { 0 }; if (item) { - s_adxl345_data_t *user_data = (s_adxl345_data_t *)item->user_arg; + s_adxl345_data_t* user_data = (s_adxl345_data_t*)item->user_arg; if (user_data) { if (ezlopi_item_name_acceleration_x_axis == item->cloud_properties.item_name) diff --git a/ezlopi-sensors-devices/sensor-0010-I2C-BME680/sensor_0010_I2C_BME680.c b/ezlopi-sensors-devices/sensor-0010-I2C-BME680/sensor_0010_I2C_BME680.c index 5c1ca0571..c98644868 100644 --- a/ezlopi-sensors-devices/sensor-0010-I2C-BME680/sensor_0010_I2C_BME680.c +++ b/ezlopi-sensors-devices/sensor-0010-I2C-BME680/sensor_0010_I2C_BME680.c @@ -59,7 +59,7 @@ int sensor_0010_I2C_BME680(e_ezlopi_actions_t action, l_ezlopi_item_t* item, voi static void __prepare_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device) { char* device_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", device_name); + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, device_name); ASSIGN_DEVICE_NAME_V2(device, device_name); device->cloud_properties.device_id = ezlopi_cloud_generate_device_id(); diff --git a/ezlopi-sensors-devices/sensor-0015-oneWire-DHT11/sensor_0015_oneWire_DHT11.c b/ezlopi-sensors-devices/sensor-0015-oneWire-DHT11/sensor_0015_oneWire_DHT11.c index 111d1cc7b..8df56ac30 100644 --- a/ezlopi-sensors-devices/sensor-0015-oneWire-DHT11/sensor_0015_oneWire_DHT11.c +++ b/ezlopi-sensors-devices/sensor-0015-oneWire-DHT11/sensor_0015_oneWire_DHT11.c @@ -128,7 +128,7 @@ static int __dht11_setup_device_cloud_properties_temperature(l_ezlopi_device_t* if (device && cj_device) { char* device_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", device_name); + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, device_name); ASSIGN_DEVICE_NAME_V2(device, device_name); device->cloud_properties.device_id = ezlopi_cloud_generate_device_id(); @@ -147,7 +147,7 @@ static int __dht11_setup_device_cloud_properties_humidity(l_ezlopi_device_t* dev if (device && cj_device) { char* device_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", device_name); + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, device_name); ASSIGN_DEVICE_NAME_V2(device, device_name); device->cloud_properties.device_id = ezlopi_cloud_generate_device_id(); @@ -258,7 +258,7 @@ static int __0015_get_value(l_ezlopi_item_t* item, void* args) } cJSON_AddStringToObject(cj_properties, ezlopi_scale_str, item->cloud_properties.scale); } - if (ezlopi_item_name_humidity == item->cloud_properties.item_name) + else if (ezlopi_item_name_humidity == item->cloud_properties.item_name) { cJSON_AddNumberToObject(cj_properties, ezlopi_value_str, dht11_data->humidity); char* valueFormatted = ezlopi_valueformatter_float(dht11_data->humidity); diff --git a/ezlopi-sensors-devices/sensor-0016-oneWire-DHT22/sensor_0016_oneWire_DHT22.c b/ezlopi-sensors-devices/sensor-0016-oneWire-DHT22/sensor_0016_oneWire_DHT22.c index 6f8bd34b7..a10205ac5 100644 --- a/ezlopi-sensors-devices/sensor-0016-oneWire-DHT22/sensor_0016_oneWire_DHT22.c +++ b/ezlopi-sensors-devices/sensor-0016-oneWire-DHT22/sensor_0016_oneWire_DHT22.c @@ -309,7 +309,7 @@ static int dht22_sensor_setup_item_properties_humidity(l_ezlopi_item_t* item, cJ CJSON_GET_VALUE_INT(cj_device, ezlopi_dev_type_str, item->interface_type); item->interface.onewire_master.enable = true; - CJSON_GET_VALUE_INT(cj_device, ezlopi_dev_name_str, item->interface.onewire_master.onewire_pin); + CJSON_GET_VALUE_INT(cj_device, ezlopi_gpio_str, item->interface.onewire_master.onewire_pin); } return ret; diff --git a/ezlopi-sensors-devices/sensor-0017-ADC-potentiometer/sensor_0017_ADC_potentiometer.c b/ezlopi-sensors-devices/sensor-0017-ADC-potentiometer/sensor_0017_ADC_potentiometer.c index 66e7f1013..e6c500b60 100644 --- a/ezlopi-sensors-devices/sensor-0017-ADC-potentiometer/sensor_0017_ADC_potentiometer.c +++ b/ezlopi-sensors-devices/sensor-0017-ADC-potentiometer/sensor_0017_ADC_potentiometer.c @@ -18,12 +18,12 @@ typedef struct s_potentiometer float pot_val; } s_potentiometer_t; -static int __0017_prepare(void *arg); -static int __0017_init(l_ezlopi_item_t *item); -static int __0017_get_cjson_value(l_ezlopi_item_t *item, void *arg); -static int __0017_notify(l_ezlopi_item_t *item); +static int __0017_prepare(void* arg); +static int __0017_init(l_ezlopi_item_t* item); +static int __0017_get_cjson_value(l_ezlopi_item_t* item, void* arg); +static int __0017_notify(l_ezlopi_item_t* item); //-------------------------------------------------------------------------------------------------------- -int sensor_0017_ADC_potentiometer(e_ezlopi_actions_t action, l_ezlopi_item_t *item, void *arg, void *user_arg) +int sensor_0017_ADC_potentiometer(e_ezlopi_actions_t action, l_ezlopi_item_t* item, void* arg, void* user_arg) { int ret = 0; switch (action) @@ -57,10 +57,10 @@ int sensor_0017_ADC_potentiometer(e_ezlopi_actions_t action, l_ezlopi_item_t *it return ret; } //------------------------------------------------------------------------------------------------------------------------- -static void __prepare_device_cloud_properties(l_ezlopi_device_t *device, cJSON *cj_device) +static void __prepare_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device) { - char *dev_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", dev_name); + char* dev_name = NULL; + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, dev_name); ASSIGN_DEVICE_NAME_V2(device, dev_name); device->cloud_properties.device_id = ezlopi_cloud_generate_device_id(); device->cloud_properties.category = category_level_sensor; @@ -69,7 +69,7 @@ static void __prepare_device_cloud_properties(l_ezlopi_device_t *device, cJSON * device->cloud_properties.info = NULL; device->cloud_properties.device_type = dev_type_sensor; } -static void __prepare_item_cloud_properties(l_ezlopi_item_t *item, cJSON *cj_device, void *user_data) +static void __prepare_item_cloud_properties(l_ezlopi_item_t* item, cJSON* cj_device, void* user_data) { item->cloud_properties.item_id = ezlopi_cloud_generate_item_id(); item->cloud_properties.has_getter = true; @@ -81,26 +81,26 @@ static void __prepare_item_cloud_properties(l_ezlopi_item_t *item, cJSON *cj_dev item->user_arg = user_data; item->interface_type = EZLOPI_DEVICE_INTERFACE_MAX; // other - CJSON_GET_VALUE_INT(cj_device, "gpio", item->interface.adc.gpio_num); + CJSON_GET_VALUE_INT(cj_device, ezlopi_gpio_str, item->interface.adc.gpio_num); item->interface.adc.resln_bit = 3; } //------------------------------------------------------------------------------------------------------------------------- -static int __0017_prepare(void *arg) +static int __0017_prepare(void* arg) { int ret = 0; - s_ezlopi_prep_arg_t *device_prep_arg = (s_ezlopi_prep_arg_t *)arg; + s_ezlopi_prep_arg_t* device_prep_arg = (s_ezlopi_prep_arg_t*)arg; if (device_prep_arg && (NULL != device_prep_arg->cjson_device)) { - cJSON *cj_device = device_prep_arg->cjson_device; - s_potentiometer_t *user_data = (s_potentiometer_t *)malloc(sizeof(s_potentiometer_t)); + cJSON* cj_device = device_prep_arg->cjson_device; + s_potentiometer_t* user_data = (s_potentiometer_t*)malloc(sizeof(s_potentiometer_t)); if (NULL != user_data) { memset(user_data, 0, sizeof(s_potentiometer_t)); - l_ezlopi_device_t *potentiometer_device = ezlopi_device_add_device(cj_device); + l_ezlopi_device_t* potentiometer_device = ezlopi_device_add_device(cj_device); if (potentiometer_device) { __prepare_device_cloud_properties(potentiometer_device, cj_device); - l_ezlopi_item_t *potentiometer_item = ezlopi_device_add_item_to_device(potentiometer_device, sensor_0017_ADC_potentiometer); + l_ezlopi_item_t* potentiometer_item = ezlopi_device_add_item_to_device(potentiometer_device, sensor_0017_ADC_potentiometer); if (potentiometer_item) { __prepare_item_cloud_properties(potentiometer_item, cj_device, user_data); @@ -123,7 +123,7 @@ static int __0017_prepare(void *arg) return ret; } -static int __0017_init(l_ezlopi_item_t *item) +static int __0017_init(l_ezlopi_item_t* item) { int ret = 0; if (item) @@ -162,12 +162,12 @@ static int __0017_init(l_ezlopi_item_t *item) return ret; } -static int __0017_get_cjson_value(l_ezlopi_item_t *item, void *arg) +static int __0017_get_cjson_value(l_ezlopi_item_t* item, void* arg) { int ret = 0; if (item && arg) { - cJSON *cj_result = (cJSON *)arg; + cJSON* cj_result = (cJSON*)arg; if (cj_result) { s_potentiometer_t *user_data = (s_potentiometer_t *)item->user_arg; @@ -187,7 +187,7 @@ static int __0017_get_cjson_value(l_ezlopi_item_t *item, void *arg) return ret; } -static int __0017_notify(l_ezlopi_item_t *item) +static int __0017_notify(l_ezlopi_item_t* item) { int ret = 0; if (item) diff --git a/ezlopi-sensors-devices/sensor-0018-other-internal-hall-effect/sensor_0018_other_internal_hall_effect.c b/ezlopi-sensors-devices/sensor-0018-other-internal-hall-effect/sensor_0018_other_internal_hall_effect.c index 879d06edd..357266ecc 100644 --- a/ezlopi-sensors-devices/sensor-0018-other-internal-hall-effect/sensor_0018_other_internal_hall_effect.c +++ b/ezlopi-sensors-devices/sensor-0018-other-internal-hall-effect/sensor_0018_other_internal_hall_effect.c @@ -84,8 +84,8 @@ int sensor_0018_other_internal_hall_effect(e_ezlopi_actions_t action, l_ezlopi_i static void __setup_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device) { char* device_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", device_name) - ASSIGN_DEVICE_NAME_V2(device, device_name); + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, device_name); + ASSIGN_DEVICE_NAME_V2(device, device_name); device->cloud_properties.device_id = ezlopi_cloud_generate_device_id(); device->cloud_properties.category = category_security_sensor; device->cloud_properties.subcategory = subcategory_door; diff --git a/ezlopi-sensors-devices/sensor-0020-other-2axis-joystick/sensor_0020_other_2axis_joystick.c b/ezlopi-sensors-devices/sensor-0020-other-2axis-joystick/sensor_0020_other_2axis_joystick.c index dbde77c85..507553ae8 100644 --- a/ezlopi-sensors-devices/sensor-0020-other-2axis-joystick/sensor_0020_other_2axis_joystick.c +++ b/ezlopi-sensors-devices/sensor-0020-other-2axis-joystick/sensor_0020_other_2axis_joystick.c @@ -72,7 +72,7 @@ int sensor_0020_other_2axis_joystick(e_ezlopi_actions_t action, l_ezlopi_item_t* static void __setup_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device) { char* device_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", device_name); + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, device_name); ASSIGN_DEVICE_NAME_V2(device, device_name); device->cloud_properties.device_id = ezlopi_cloud_generate_device_id(); diff --git a/ezlopi-sensors-devices/sensor-0026-ADC-LDR/sensor_0026_ADC_LDR.c b/ezlopi-sensors-devices/sensor-0026-ADC-LDR/sensor_0026_ADC_LDR.c index 9aec1b284..ae7e77553 100644 --- a/ezlopi-sensors-devices/sensor-0026-ADC-LDR/sensor_0026_ADC_LDR.c +++ b/ezlopi-sensors-devices/sensor-0026-ADC-LDR/sensor_0026_ADC_LDR.c @@ -13,22 +13,22 @@ #include "sensor_0026_ADC_LDR.h" -const char *light_alarm_states[] = - { - "no_light", - "light_detected", - "unknown", +const char* light_alarm_states[] = +{ + "no_light", + "light_detected", + "unknown", }; -static int __prepare(void *arg); -static int __init(l_ezlopi_item_t *item); -static int __notify(l_ezlopi_item_t *item); -static int __get_value_cjson(l_ezlopi_item_t *item, void *arg); -static void __setup_device_cloud_params(l_ezlopi_device_t *device, cJSON *cj_device); -static void __setup_item_cloud_properties(l_ezlopi_item_t *item, cJSON *cj_device); -static int _get_item_list(l_ezlopi_item_t *item, void *arg); +static int __prepare(void* arg); +static int __init(l_ezlopi_item_t* item); +static int __notify(l_ezlopi_item_t* item); +static int __get_value_cjson(l_ezlopi_item_t* item, void* arg); +static void __setup_device_cloud_params(l_ezlopi_device_t* device, cJSON* cj_device); +static void __setup_item_cloud_properties(l_ezlopi_item_t* item, cJSON* cj_device); +static int _get_item_list(l_ezlopi_item_t* item, void* arg); -int sensor_0026_ADC_LDR(e_ezlopi_actions_t action, l_ezlopi_item_t *item, void *arg, void *user_arg) +int sensor_0026_ADC_LDR(e_ezlopi_actions_t action, l_ezlopi_item_t* item, void* arg, void* user_arg) { int ret = 0; @@ -68,10 +68,10 @@ int sensor_0026_ADC_LDR(e_ezlopi_actions_t action, l_ezlopi_item_t *item, void * return ret; } -static void __setup_device_cloud_params(l_ezlopi_device_t *device, cJSON *cj_device) +static void __setup_device_cloud_params(l_ezlopi_device_t* device, cJSON* cj_device) { - char *device_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", device_name); + char* device_name = NULL; + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, device_name); ASSIGN_DEVICE_NAME_V2(device, device_name); device->cloud_properties.category = category_light_sensor; @@ -82,7 +82,7 @@ static void __setup_device_cloud_params(l_ezlopi_device_t *device, cJSON *cj_dev device->cloud_properties.device_id = ezlopi_cloud_generate_device_id(); } -static void __setup_item_cloud_properties(l_ezlopi_item_t *item, cJSON *cj_device) +static void __setup_item_cloud_properties(l_ezlopi_item_t* item, cJSON* cj_device) { if (item) { @@ -96,24 +96,24 @@ static void __setup_item_cloud_properties(l_ezlopi_item_t *item, cJSON *cj_devic item->interface_type = EZLOPI_DEVICE_INTERFACE_ANALOG_INPUT; item->interface.adc.resln_bit = 3; - CJSON_GET_VALUE_INT(cj_device, "gpio", item->interface.adc.gpio_num); + CJSON_GET_VALUE_INT(cj_device, ezlopi_gpio_str, item->interface.adc.gpio_num); } } -static int __prepare(void *arg) +static int __prepare(void* arg) { int ret = 0; - s_ezlopi_prep_arg_t *prep_arg = (s_ezlopi_prep_arg_t *)arg; + s_ezlopi_prep_arg_t* prep_arg = (s_ezlopi_prep_arg_t*)arg; if (prep_arg && prep_arg->cjson_device) { - cJSON *cj_device = prep_arg->cjson_device; + cJSON* cj_device = prep_arg->cjson_device; if (cj_device) { - l_ezlopi_device_t *device = ezlopi_device_add_device(cj_device); + l_ezlopi_device_t* device = ezlopi_device_add_device(cj_device); if (device) { __setup_device_cloud_params(device, cj_device); - l_ezlopi_item_t *item = ezlopi_device_add_item_to_device(device, sensor_0026_ADC_LDR); + l_ezlopi_item_t* item = ezlopi_device_add_item_to_device(device, sensor_0026_ADC_LDR); if (item) { __setup_item_cloud_properties(item, cj_device); @@ -130,7 +130,7 @@ static int __prepare(void *arg) return ret; } -static int __init(l_ezlopi_item_t *item) +static int __init(l_ezlopi_item_t* item) { int ret = 0; if (item) @@ -141,6 +141,11 @@ static int __init(l_ezlopi_item_t *item) { ret = 1; } + // else + // { + // ret = -1; + // ezlopi_device_free_device_by_item(item); + // } } // else // { @@ -151,18 +156,18 @@ static int __init(l_ezlopi_item_t *item) return ret; } -static int _get_item_list(l_ezlopi_item_t *item, void *arg) +static int _get_item_list(l_ezlopi_item_t* item, void* arg) { int ret = 0; - cJSON *cj_result = (cJSON *)arg; + cJSON* cj_result = (cJSON*)arg; if (cj_result && item) { - cJSON *json_array_enum = cJSON_CreateArray(); + cJSON* json_array_enum = cJSON_CreateArray(); if (NULL != json_array_enum) { for (uint8_t i = 0; i < LIGHT_ALARM_MAX; i++) { - cJSON *json_value = cJSON_CreateString(light_alarm_states[i]); + cJSON* json_value = cJSON_CreateString(light_alarm_states[i]); if (NULL != json_value) { cJSON_AddItemToArray(json_array_enum, json_value); @@ -170,36 +175,36 @@ static int _get_item_list(l_ezlopi_item_t *item, void *arg) } cJSON_AddItemToObject(cj_result, ezlopi_enum_str, json_array_enum); } - cJSON_AddStringToObject(cj_result, ezlopi_value_str, ((char *)item->user_arg) ? item->user_arg : "no_light"); - cJSON_AddStringToObject(cj_result, ezlopi_valueFormatted_str, ((char *)item->user_arg) ? item->user_arg : "no_light"); + cJSON_AddStringToObject(cj_result, ezlopi_value_str, ((char*)item->user_arg) ? item->user_arg : "no_light"); + cJSON_AddStringToObject(cj_result, ezlopi_valueFormatted_str, ((char*)item->user_arg) ? item->user_arg : "no_light"); ret = 1; } return ret; } -static int __get_value_cjson(l_ezlopi_item_t *item, void *arg) +static int __get_value_cjson(l_ezlopi_item_t* item, void* arg) { int ret = 0; - cJSON *cj_result = (cJSON *)arg; + cJSON* cj_result = (cJSON*)arg; if (cj_result && item) { - cJSON_AddStringToObject(cj_result, ezlopi_value_str, ((char *)item->user_arg) ? item->user_arg : "no_light"); - cJSON_AddStringToObject(cj_result, ezlopi_valueFormatted_str, ((char *)item->user_arg) ? item->user_arg : "no_light"); + cJSON_AddStringToObject(cj_result, ezlopi_value_str, ((char*)item->user_arg) ? item->user_arg : "no_light"); + cJSON_AddStringToObject(cj_result, ezlopi_valueFormatted_str, ((char*)item->user_arg) ? item->user_arg : "no_light"); ret = 1; } return ret; } -static int __notify(l_ezlopi_item_t *item) +static int __notify(l_ezlopi_item_t* item) { int ret = 0; if (item) { - s_ezlopi_analog_data_t ezlopi_analog_data = {.value = 0, .voltage = 0}; + s_ezlopi_analog_data_t ezlopi_analog_data = { .value = 0, .voltage = 0 }; ezlopi_adc_get_adc_data(item->interface.adc.gpio_num, &ezlopi_analog_data); TRACE_I("Value is: %d, voltage is: %d", ezlopi_analog_data.value, ezlopi_analog_data.voltage); - char *curr_ldr_state = NULL; + char* curr_ldr_state = NULL; if (((float)(4096 - ezlopi_analog_data.value) / 4096.0f) > 0.5f) // pot_val : [100% - 30%] { curr_ldr_state = "no_light"; // no light @@ -208,9 +213,9 @@ static int __notify(l_ezlopi_item_t *item) { curr_ldr_state = "light_detected"; // light detected } - if (curr_ldr_state != (char *)item->user_arg) + if (curr_ldr_state != (char*)item->user_arg) { - item->user_arg = (void *)curr_ldr_state; + item->user_arg = (void*)curr_ldr_state; ezlopi_device_value_updated_from_device_v3(item); } } diff --git a/ezlopi-sensors-devices/sensor-0027-ADC-waterLeak/sensor_0027_ADC_waterLeak.c b/ezlopi-sensors-devices/sensor-0027-ADC-waterLeak/sensor_0027_ADC_waterLeak.c index 9a1e7bca0..a0a1bc886 100644 --- a/ezlopi-sensors-devices/sensor-0027-ADC-waterLeak/sensor_0027_ADC_waterLeak.c +++ b/ezlopi-sensors-devices/sensor-0027-ADC-waterLeak/sensor_0027_ADC_waterLeak.c @@ -217,6 +217,11 @@ static int __init(l_ezlopi_item_t *item) { ret = 1; } + // else + // { + // ret = -1; + // ezlopi_device_free_device_by_item(item); + // } } // else // { diff --git a/ezlopi-sensors-devices/sensor-0028-other-GY61/sensor_0028_other_GY61.c b/ezlopi-sensors-devices/sensor-0028-other-GY61/sensor_0028_other_GY61.c index 7da09807c..39c419208 100644 --- a/ezlopi-sensors-devices/sensor-0028-other-GY61/sensor_0028_other_GY61.c +++ b/ezlopi-sensors-devices/sensor-0028-other-GY61/sensor_0028_other_GY61.c @@ -73,7 +73,7 @@ int sensor_0028_other_GY61(e_ezlopi_actions_t action, l_ezlopi_item_t* item, voi static void __prepare_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device) { char* dev_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", dev_name); + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, dev_name); ASSIGN_DEVICE_NAME_V2(device, dev_name); device->cloud_properties.device_id = ezlopi_cloud_generate_device_id(); device->cloud_properties.category = category_level_sensor; @@ -225,7 +225,7 @@ static int __0028_get_cjson_value(l_ezlopi_item_t* item, void* arg) s_gy61_data_t* user_data = ((s_gy61_data_t*)item->user_arg); if (ezlopi_item_name_acceleration_x_axis == item->cloud_properties.item_name) { - cJSON_AddNumberToObject(cj_result, "value", (user_data->x_data)); + cJSON_AddNumberToObject(cj_result, ezlopi_value_str, (user_data->x_data)); // TRACE_I("x-axis-G : %.2f", user_data->x_data); char *valueFormatted = ezlopi_valueformatter_float(user_data->x_data); if (valueFormatted) @@ -236,7 +236,7 @@ static int __0028_get_cjson_value(l_ezlopi_item_t* item, void* arg) } if (ezlopi_item_name_acceleration_y_axis == item->cloud_properties.item_name) { - cJSON_AddNumberToObject(cj_result, "value", (user_data->y_data)); + cJSON_AddNumberToObject(cj_result, ezlopi_value_str, (user_data->y_data)); // TRACE_I("y-axis-G : %.2f", user_data->y_data); char *valueFormatted = ezlopi_valueformatter_float(user_data->y_data); if (valueFormatted) @@ -247,7 +247,7 @@ static int __0028_get_cjson_value(l_ezlopi_item_t* item, void* arg) } if (ezlopi_item_name_acceleration_z_axis == item->cloud_properties.item_name) { - cJSON_AddNumberToObject(cj_result, "value", (user_data->z_data)); + cJSON_AddNumberToObject(cj_result, ezlopi_value_str, (user_data->z_data)); // TRACE_I("z-axis-G : %.2f", user_data->z_data); char *valueFormatted = ezlopi_valueformatter_float(user_data->z_data); if (valueFormatted) diff --git a/ezlopi-sensors-devices/sensor-0029-I2C-GXHTC3/sensor_0029_I2C_GXHTC3.c b/ezlopi-sensors-devices/sensor-0029-I2C-GXHTC3/sensor_0029_I2C_GXHTC3.c index 632ebc142..87c96a34e 100644 --- a/ezlopi-sensors-devices/sensor-0029-I2C-GXHTC3/sensor_0029_I2C_GXHTC3.c +++ b/ezlopi-sensors-devices/sensor-0029-I2C-GXHTC3/sensor_0029_I2C_GXHTC3.c @@ -205,7 +205,7 @@ static int __get_cjson_update_value(l_ezlopi_item_t* item) static void __prepare_device_cloud_properties_temp(l_ezlopi_device_t* device, cJSON* cj_device) { char* device_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", device_name); + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, device_name); ASSIGN_DEVICE_NAME_V2(device, device_name); device->cloud_properties.category = category_temperature; @@ -219,7 +219,7 @@ static void __prepare_device_cloud_properties_temp(l_ezlopi_device_t* device, cJ static void __prepare_device_cloud_properties_hum(l_ezlopi_device_t* device, cJSON* cj_device) { char* device_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", device_name); + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, device_name); ASSIGN_DEVICE_NAME_V2(device, device_name); device->cloud_properties.category = category_humidity; diff --git a/ezlopi-sensors-devices/sensor-0032-ADC-soilMoisture/sensor_0032_ADC_soilMoisture.c b/ezlopi-sensors-devices/sensor-0032-ADC-soilMoisture/sensor_0032_ADC_soilMoisture.c index e5147d546..29f1dfee7 100644 --- a/ezlopi-sensors-devices/sensor-0032-ADC-soilMoisture/sensor_0032_ADC_soilMoisture.c +++ b/ezlopi-sensors-devices/sensor-0032-ADC-soilMoisture/sensor_0032_ADC_soilMoisture.c @@ -15,12 +15,12 @@ #include "sensor_0032_ADC_soilMoisture.h" -static int __prepare(void *arg); -static int __init(l_ezlopi_item_t *item); -static int __notify(l_ezlopi_item_t *item); -static int __get_cjson_value(l_ezlopi_item_t *item, void *arg); +static int __prepare(void* arg); +static int __init(l_ezlopi_item_t* item); +static int __notify(l_ezlopi_item_t* item); +static int __get_cjson_value(l_ezlopi_item_t* item, void* arg); -int sensor_0032_ADC_soilMoisture(e_ezlopi_actions_t action, l_ezlopi_item_t *item, void *arg, void *user_arg) +int sensor_0032_ADC_soilMoisture(e_ezlopi_actions_t action, l_ezlopi_item_t* item, void* arg, void* user_arg) { int ret = 0; switch (action) @@ -54,37 +54,37 @@ int sensor_0032_ADC_soilMoisture(e_ezlopi_actions_t action, l_ezlopi_item_t *ite return ret; } -static int __notify(l_ezlopi_item_t *item) +static int __notify(l_ezlopi_item_t* item) { int ret = 0; - s_ezlopi_analog_data_t *soil_moisture_data = (s_ezlopi_analog_data_t *)item->user_arg; + double* soil_moisture_data = (double*)item->user_arg; if (soil_moisture_data) { - s_ezlopi_analog_data_t tmp_data = {.value = 0, .voltage = 0}; + s_ezlopi_analog_data_t tmp_data = { .value = 0, .voltage = 0 }; ezlopi_adc_get_adc_data(item->interface.adc.gpio_num, &tmp_data); - if (fabs(tmp_data.voltage - soil_moisture_data->voltage) > 100) + double percentage = ((4095 - tmp_data.value) / 4096.0) * 100; + if (fabs(percentage - *soil_moisture_data) > 1.0) { - soil_moisture_data->value = tmp_data.value; - soil_moisture_data->voltage = tmp_data.voltage; + *soil_moisture_data = percentage; ezlopi_device_value_updated_from_device_v3(item); } } return ret; } -static int __get_cjson_value(l_ezlopi_item_t *item, void *arg) +static int __get_cjson_value(l_ezlopi_item_t* item, void* arg) { int ret = 0; if (item && arg) { - cJSON *cj_result = (cJSON *)arg; - s_ezlopi_analog_data_t *soil_moisture_data = (s_ezlopi_analog_data_t *)item->user_arg; + cJSON* cj_result = (cJSON*)arg; + // s_ezlopi_analog_data_t* soil_moisture_data = (s_ezlopi_analog_data_t*)item->user_arg; + double* soil_moisture_data = (double*)item->user_arg; if (soil_moisture_data) { - double percent_data = ((4095 - soil_moisture_data->value) / 4095.0) * 100; - cJSON_AddNumberToObject(cj_result, ezlopi_value_str, percent_data); - char *valueFormatted = ezlopi_valueformatter_double(percent_data); + cJSON_AddNumberToObject(cj_result, ezlopi_value_str, *soil_moisture_data); + char* valueFormatted = ezlopi_valueformatter_double(*soil_moisture_data); if (valueFormatted) { cJSON_AddStringToObject(cj_result, ezlopi_valueFormatted_str, valueFormatted); @@ -96,7 +96,7 @@ static int __get_cjson_value(l_ezlopi_item_t *item, void *arg) return ret; } -static int __init(l_ezlopi_item_t *item) +static int __init(l_ezlopi_item_t* item) { int ret = 0; if (item) @@ -107,6 +107,11 @@ static int __init(l_ezlopi_item_t *item) { ret = 1; } + // else + // { + // ret = -1; + // ezlopi_device_free_device_by_item(item); + // } } // else // { @@ -117,7 +122,7 @@ static int __init(l_ezlopi_item_t *item) return ret; } -static void __prepare_device_cloud_properties(l_ezlopi_device_t *device, cJSON *cj_device) +static void __prepare_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device) { // char *device_name = NULL; // CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, device_name); @@ -137,7 +142,7 @@ static void __prepare_device_cloud_properties(l_ezlopi_device_t *device, cJSON * device->cloud_properties.device_type_id = NULL; } -static void __prepare_item_properties(l_ezlopi_item_t *item, cJSON *cj_device, void *user_arg) +static void __prepare_item_properties(l_ezlopi_item_t* item, cJSON* cj_device, void* user_arg) { CJSON_GET_VALUE_INT(cj_device, ezlopi_dev_type_str, item->interface_type); item->cloud_properties.has_getter = true; @@ -154,26 +159,27 @@ static void __prepare_item_properties(l_ezlopi_item_t *item, cJSON *cj_device, v item->user_arg = user_arg; } -static int __prepare(void *arg) +static int __prepare(void* arg) { int ret = 0; - s_ezlopi_prep_arg_t *prep_arg = (s_ezlopi_prep_arg_t *)arg; + s_ezlopi_prep_arg_t* prep_arg = (s_ezlopi_prep_arg_t*)arg; if (prep_arg && prep_arg->cjson_device) { - l_ezlopi_device_t *device = ezlopi_device_add_device(prep_arg->cjson_device); + l_ezlopi_device_t* device = ezlopi_device_add_device(prep_arg->cjson_device); if (device) { __prepare_device_cloud_properties(device, prep_arg->cjson_device); - l_ezlopi_item_t *item_temperature = ezlopi_device_add_item_to_device(device, sensor_0032_ADC_soilMoisture); + l_ezlopi_item_t* item_temperature = ezlopi_device_add_item_to_device(device, sensor_0032_ADC_soilMoisture); if (item_temperature) { item_temperature->cloud_properties.device_id = device->cloud_properties.device_id; - s_ezlopi_analog_data_t *soil_moisture_data = (s_ezlopi_analog_data_t *)malloc(sizeof(s_ezlopi_analog_data_t)); + // s_ezlopi_analog_data_t* soil_moisture_data = (s_ezlopi_analog_data_t*)malloc(sizeof(s_ezlopi_analog_data_t)); + double* soil_moisture_data = (double*)malloc(sizeof(double)); if (soil_moisture_data) { - memset(soil_moisture_data, 0, sizeof(s_ezlopi_analog_data_t)); - __prepare_item_properties(item_temperature, prep_arg->cjson_device, (void *)soil_moisture_data); + memset(soil_moisture_data, 0, sizeof(double)); + __prepare_item_properties(item_temperature, prep_arg->cjson_device, (void*)soil_moisture_data); } ret = 1; } diff --git a/ezlopi-sensors-devices/sensor-0033-ADC-turbidity/sensor_0033_ADC_turbidity.c b/ezlopi-sensors-devices/sensor-0033-ADC-turbidity/sensor_0033_ADC_turbidity.c index 1371cd2b9..11a4b247f 100644 --- a/ezlopi-sensors-devices/sensor-0033-ADC-turbidity/sensor_0033_ADC_turbidity.c +++ b/ezlopi-sensors-devices/sensor-0033-ADC-turbidity/sensor_0033_ADC_turbidity.c @@ -13,19 +13,19 @@ #include "sensor_0033_ADC_turbidity.h" -static int __prepare(void *arg); -static int __init(l_ezlopi_item_t *item); -static int __notify(l_ezlopi_item_t *item); -static int __get_cjson_value(l_ezlopi_item_t *item, void *arg); -static int __get_item_list(l_ezlopi_item_t *item, void *arg); +static int __prepare(void* arg); +static int __init(l_ezlopi_item_t* item); +static int __notify(l_ezlopi_item_t* item); +static int __get_cjson_value(l_ezlopi_item_t* item, void* arg); +static int __get_item_list(l_ezlopi_item_t* item, void* arg); -static const char *water_filter_replacement_alarm_states[] = { +static const char* water_filter_replacement_alarm_states[] = { "water_filter_ok", "replace_water_filter", "unknown", }; -int sensor_0033_ADC_turbidity(e_ezlopi_actions_t action, l_ezlopi_item_t *item, void *arg, void *user_arg) +int sensor_0033_ADC_turbidity(e_ezlopi_actions_t action, l_ezlopi_item_t* item, void* arg, void* user_arg) { int ret = 0; switch (action) @@ -63,18 +63,18 @@ int sensor_0033_ADC_turbidity(e_ezlopi_actions_t action, l_ezlopi_item_t *item, return ret; } -static int __get_item_list(l_ezlopi_item_t *item, void *arg) +static int __get_item_list(l_ezlopi_item_t* item, void* arg) { int ret = 0; - cJSON *cjson_propertise = (cJSON *)arg; + cJSON* cjson_propertise = (cJSON*)arg; if (cjson_propertise) { - cJSON *json_array_enum = cJSON_CreateArray(); + cJSON* json_array_enum = cJSON_CreateArray(); if (NULL != json_array_enum) { for (uint8_t i = 0; i < TURBIDITY__MAX; i++) { - cJSON *json_value = cJSON_CreateString(water_filter_replacement_alarm_states[i]); + cJSON* json_value = cJSON_CreateString(water_filter_replacement_alarm_states[i]); if (NULL != json_value) { cJSON_AddItemToArray(json_array_enum, json_value); @@ -83,11 +83,11 @@ static int __get_item_list(l_ezlopi_item_t *item, void *arg) cJSON_AddItemToObject(cjson_propertise, ezlopi_enum_str, json_array_enum); } - s_ezlopi_analog_data_t ezlopi_analog_data = {.value = 0, .voltage = 0}; + s_ezlopi_analog_data_t ezlopi_analog_data = { .value = 0, .voltage = 0 }; ezlopi_adc_get_adc_data(item->interface.adc.gpio_num, &ezlopi_analog_data); TRACE_I("Value is: %d, voltage is: %d", ezlopi_analog_data.value, ezlopi_analog_data.voltage); - const char *ezlopi_water_present_turbidity_state = NULL; + const char* ezlopi_water_present_turbidity_state = NULL; if (1000 > ezlopi_analog_data.voltage) { ezlopi_water_present_turbidity_state = "replace_water_filter"; @@ -112,15 +112,15 @@ static int __get_item_list(l_ezlopi_item_t *item, void *arg) return ret; } -static int __notify(l_ezlopi_item_t *item) +static int __notify(l_ezlopi_item_t* item) { int ret = 0; - const char *tmp_sensor_state = NULL; - char *turbidity_sensor_state = (char *)item->user_arg; + const char* tmp_sensor_state = NULL; + char* turbidity_sensor_state = (char*)item->user_arg; if (turbidity_sensor_state) { - s_ezlopi_analog_data_t tmp_analog_data = {.value = 0, .voltage = 0}; + s_ezlopi_analog_data_t tmp_analog_data = { .value = 0, .voltage = 0 }; ezlopi_adc_get_adc_data(item->interface.adc.gpio_num, &tmp_analog_data); if (1000 > tmp_analog_data.voltage) { @@ -140,13 +140,13 @@ static int __notify(l_ezlopi_item_t *item) return ret; } -static int __get_cjson_value(l_ezlopi_item_t *item, void *arg) +static int __get_cjson_value(l_ezlopi_item_t* item, void* arg) { int ret = 0; if (item && arg) { - cJSON *cj_result = (cJSON *)arg; - char *turbidity_sensor_state = (char *)item->user_arg; + cJSON* cj_result = (cJSON*)arg; + char* turbidity_sensor_state = (char*)item->user_arg; if (turbidity_sensor_state) { cJSON_AddStringToObject(cj_result, ezlopi_value_str, turbidity_sensor_state); @@ -157,7 +157,7 @@ static int __get_cjson_value(l_ezlopi_item_t *item, void *arg) return ret; } -static int __init(l_ezlopi_item_t *item) +static int __init(l_ezlopi_item_t* item) { int ret = 0; if (item) @@ -168,6 +168,11 @@ static int __init(l_ezlopi_item_t *item) { ret = 1; } + // else + // { + // ret = -1; + // ezlopi_device_free_device_by_item(item); + // } } // else // { @@ -178,7 +183,7 @@ static int __init(l_ezlopi_item_t *item) return ret; } -static void __prepare_device_cloud_properties(l_ezlopi_device_t *device, cJSON *cj_device) +static void __prepare_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device) { // char *device_name = NULL; // CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, device_name); @@ -192,7 +197,7 @@ static void __prepare_device_cloud_properties(l_ezlopi_device_t *device, cJSON * device->cloud_properties.device_type_id = NULL; } -static void __prepare_item_properties(l_ezlopi_item_t *item, cJSON *cj_device, void *user_arg) +static void __prepare_item_properties(l_ezlopi_item_t* item, cJSON* cj_device, void* user_arg) { item->cloud_properties.has_getter = true; item->cloud_properties.has_setter = false; @@ -208,27 +213,27 @@ static void __prepare_item_properties(l_ezlopi_item_t *item, cJSON *cj_device, v item->user_arg = user_arg; } -static int __prepare(void *arg) +static int __prepare(void* arg) { int ret = 0; - s_ezlopi_prep_arg_t *prep_arg = (s_ezlopi_prep_arg_t *)arg; + s_ezlopi_prep_arg_t* prep_arg = (s_ezlopi_prep_arg_t*)arg; if (prep_arg && prep_arg->cjson_device) { - l_ezlopi_device_t *device = ezlopi_device_add_device(prep_arg->cjson_device); + l_ezlopi_device_t* device = ezlopi_device_add_device(prep_arg->cjson_device); if (device) { __prepare_device_cloud_properties(device, prep_arg->cjson_device); - l_ezlopi_item_t *item_turbidity = ezlopi_device_add_item_to_device(device, sensor_0033_ADC_turbidity); + l_ezlopi_item_t* item_turbidity = ezlopi_device_add_item_to_device(device, sensor_0033_ADC_turbidity); if (item_turbidity) { item_turbidity->cloud_properties.device_id = device->cloud_properties.device_id; - char *turbidity_sensor_states = (char *)malloc(40 * sizeof(char)); + char* turbidity_sensor_states = (char*)malloc(40 * sizeof(char)); if (turbidity_sensor_states) { memset(turbidity_sensor_states, 0, sizeof(s_ezlopi_analog_data_t)); - __prepare_item_properties(item_turbidity, prep_arg->cjson_device, (void *)turbidity_sensor_states); + __prepare_item_properties(item_turbidity, prep_arg->cjson_device, (void*)turbidity_sensor_states); ret = 1; } } diff --git a/ezlopi-sensors-devices/sensor-0035-digitalIn-touch-sensor-TPP223B/sensor_0035_digitalIn_touch_sensor_TPP223B.c b/ezlopi-sensors-devices/sensor-0035-digitalIn-touch-sensor-TPP223B/sensor_0035_digitalIn_touch_sensor_TPP223B.c index 2532a2a52..493a5a9fd 100644 --- a/ezlopi-sensors-devices/sensor-0035-digitalIn-touch-sensor-TPP223B/sensor_0035_digitalIn_touch_sensor_TPP223B.c +++ b/ezlopi-sensors-devices/sensor-0035-digitalIn-touch-sensor-TPP223B/sensor_0035_digitalIn_touch_sensor_TPP223B.c @@ -16,14 +16,14 @@ #include "sensor_0035_digitalIn_touch_sensor_TPP223B.h" -static int __prepare(void *arg); -static void __prepare_touch_sensor_device_cloud_properties(l_ezlopi_device_t *device, cJSON *cj_device); -static void __prepare_touch_sensor_properties(l_ezlopi_item_t *item, cJSON *cj_device); -static int __init(l_ezlopi_item_t *item); -static void __touch_switch_callback(void *arg); -static int __get_cjson_value(l_ezlopi_item_t *item, void *arg); - -int sensor_0035_digitalIn_touch_sensor_TPP223B(e_ezlopi_actions_t action, l_ezlopi_item_t *item, void *arg, void *user_arg) +static int __prepare(void* arg); +static void __prepare_touch_sensor_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device); +static void __prepare_touch_sensor_properties(l_ezlopi_item_t* item, cJSON* cj_device); +static int __init(l_ezlopi_item_t* item); +static void __touch_switch_callback(void* arg); +static int __get_cjson_value(l_ezlopi_item_t* item, void* arg); + +int sensor_0035_digitalIn_touch_sensor_TPP223B(e_ezlopi_actions_t action, l_ezlopi_item_t* item, void* arg, void* user_arg) { switch (action) { @@ -51,22 +51,22 @@ int sensor_0035_digitalIn_touch_sensor_TPP223B(e_ezlopi_actions_t action, l_ezlo return 0; } -static int __get_cjson_value(l_ezlopi_item_t *item, void *arg) +static int __get_cjson_value(l_ezlopi_item_t* item, void* arg) { int ret = 0; - cJSON *param = (cJSON *)arg; + cJSON* param = (cJSON*)arg; if (param) { cJSON_AddBoolToObject(param, ezlopi_value_str, item->interface.gpio.gpio_in.value); - const char *valueFormatted = ezlopi_valueformatter_bool(item->interface.gpio.gpio_in.value ? true : false); + const char* valueFormatted = ezlopi_valueformatter_bool(item->interface.gpio.gpio_in.value ? true : false); cJSON_AddStringToObject(param, ezlopi_valueFormatted_str, valueFormatted); } return ret; } -static int __init(l_ezlopi_item_t *item) +static int __init(l_ezlopi_item_t* item) { int ret = 0; if (item) @@ -104,26 +104,26 @@ static int __init(l_ezlopi_item_t *item) return ret; } -static void __touch_switch_callback(void *arg) +static void __touch_switch_callback(void* arg) { - l_ezlopi_item_t *item = (l_ezlopi_item_t *)arg; + l_ezlopi_item_t* item = (l_ezlopi_item_t*)arg; int gpio_level = gpio_get_level(item->interface.gpio.gpio_in.gpio_num); item->interface.gpio.gpio_in.value = (false == item->interface.gpio.gpio_in.invert) ? gpio_level : !gpio_level; ezlopi_device_value_updated_from_device_v3(item); } -static int __prepare(void *arg) +static int __prepare(void* arg) { int ret = 0; - s_ezlopi_prep_arg_t *prep_arg = (s_ezlopi_prep_arg_t *)arg; + s_ezlopi_prep_arg_t* prep_arg = (s_ezlopi_prep_arg_t*)arg; if (prep_arg && prep_arg->cjson_device) { - l_ezlopi_device_t *touch_device = ezlopi_device_add_device(prep_arg->cjson_device); + l_ezlopi_device_t* touch_device = ezlopi_device_add_device(prep_arg->cjson_device); if (touch_device) { __prepare_touch_sensor_device_cloud_properties(touch_device, prep_arg->cjson_device); - l_ezlopi_item_t *touch_switch_item = ezlopi_device_add_item_to_device(touch_device, sensor_0035_digitalIn_touch_sensor_TPP223B); + l_ezlopi_item_t* touch_switch_item = ezlopi_device_add_item_to_device(touch_device, sensor_0035_digitalIn_touch_sensor_TPP223B); if (touch_switch_item) { touch_switch_item->cloud_properties.device_id = touch_device->cloud_properties.device_id; @@ -141,7 +141,7 @@ static int __prepare(void *arg) return ret; } -static void __prepare_touch_sensor_device_cloud_properties(l_ezlopi_device_t *device, cJSON *cj_device) +static void __prepare_touch_sensor_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device) { // char *device_name = NULL; // CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, device_name); @@ -155,7 +155,7 @@ static void __prepare_touch_sensor_device_cloud_properties(l_ezlopi_device_t *de device->cloud_properties.device_type_id = NULL; } -static void __prepare_touch_sensor_properties(l_ezlopi_item_t *item, cJSON *cj_device) +static void __prepare_touch_sensor_properties(l_ezlopi_item_t* item, cJSON* cj_device) { CJSON_GET_VALUE_INT(cj_device, ezlopi_dev_type_str, item->interface_type); item->cloud_properties.has_getter = true; diff --git a/ezlopi-sensors-devices/sensor-0037-pms5003-sensor/sensor_0037_pms5003_sensor.c b/ezlopi-sensors-devices/sensor-0037-pms5003-sensor/sensor_0037_pms5003_sensor.c index fc48d2d24..96a446b8d 100644 --- a/ezlopi-sensors-devices/sensor-0037-pms5003-sensor/sensor_0037_pms5003_sensor.c +++ b/ezlopi-sensors-devices/sensor-0037-pms5003-sensor/sensor_0037_pms5003_sensor.c @@ -15,12 +15,12 @@ #include "pms5003.h" #include "sensor_0037_pms5003_sensor.h" -static int __prepare(void *arg, void *user_arg); -static int __init(l_ezlopi_item_t *item); -static int __cjson_get_value(l_ezlopi_item_t *item, void *arg); -static int __notify(l_ezlopi_item_t *item); +static int __prepare(void* arg, void* user_arg); +static int __init(l_ezlopi_item_t* item); +static int __cjson_get_value(l_ezlopi_item_t* item, void* arg); +static int __notify(l_ezlopi_item_t* item); -int sensor_pms5003_v3(e_ezlopi_actions_t action, l_ezlopi_item_t *item, void *arg, void *user_arg) +int sensor_pms5003_v3(e_ezlopi_actions_t action, l_ezlopi_item_t* item, void* arg, void* user_arg) { int ret = 0; @@ -56,11 +56,11 @@ int sensor_pms5003_v3(e_ezlopi_actions_t action, l_ezlopi_item_t *item, void *ar return ret; } -static int __notify(l_ezlopi_item_t *item) +static int __notify(l_ezlopi_item_t* item) { int ret = 0; - s_pms5003_sensor_object *pms_object = (s_pms5003_sensor_object *)item->user_arg; + s_pms5003_sensor_object* pms_object = (s_pms5003_sensor_object*)item->user_arg; if (pms_object) { @@ -71,7 +71,7 @@ static int __notify(l_ezlopi_item_t *item) } if ((pms_object->counter != 0) && (pms_object->counter <= 9)) { - s_pms5003_sensor_object *pms_object = (s_pms5003_sensor_object *)item->user_arg; + s_pms5003_sensor_object* pms_object = (s_pms5003_sensor_object*)item->user_arg; pms_print_data(&pms_object->pms_data); ezlopi_device_value_updated_from_device_v3(item); pms_object->counter++; @@ -85,7 +85,7 @@ static int __notify(l_ezlopi_item_t *item) return ret; } -static int __cjson_get_value(l_ezlopi_item_t *item, void *arg) +static int __cjson_get_value(l_ezlopi_item_t* item, void* arg) { int ret = 0; @@ -189,7 +189,7 @@ static int __cjson_get_value(l_ezlopi_item_t *item, void *arg) return ret; } -static int __init(l_ezlopi_item_t *item) +static int __init(l_ezlopi_item_t* item) { int ret = 0; if (item) @@ -212,11 +212,11 @@ static int __init(l_ezlopi_item_t *item) return ret; } -static int __prepare(void *arg, void *user_arg) +static int __prepare(void* arg, void* user_arg) { int ret = 0; - s_ezlopi_prep_arg_t *prep_arg = (s_ezlopi_prep_arg_t *)arg; + s_ezlopi_prep_arg_t* prep_arg = (s_ezlopi_prep_arg_t*)arg; if (prep_arg) { uint32_t parent_id = 0; diff --git a/ezlopi-sensors-devices/sensor-0040-other-TCS230/sensor_0040_other_TCS230.c b/ezlopi-sensors-devices/sensor-0040-other-TCS230/sensor_0040_other_TCS230.c index ef7750b9f..cd14d6306 100644 --- a/ezlopi-sensors-devices/sensor-0040-other-TCS230/sensor_0040_other_TCS230.c +++ b/ezlopi-sensors-devices/sensor-0040-other-TCS230/sensor_0040_other_TCS230.c @@ -91,7 +91,7 @@ static void __tcs230_setup_gpio(gpio_num_t s0_pin, static void __prepare_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device) { char* device_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", device_name); + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, device_name); ASSIGN_DEVICE_NAME_V2(device, device_name); device->cloud_properties.device_id = ezlopi_cloud_generate_device_id(); device->cloud_properties.category = category_generic_sensor; diff --git a/ezlopi-sensors-devices/sensor-0041-ADC-FC28-soilMoisture/sensor_0041_ADC_FC28_soilMoisture.c b/ezlopi-sensors-devices/sensor-0041-ADC-FC28-soilMoisture/sensor_0041_ADC_FC28_soilMoisture.c index f2f76f0a0..3bd766e1c 100644 --- a/ezlopi-sensors-devices/sensor-0041-ADC-FC28-soilMoisture/sensor_0041_ADC_FC28_soilMoisture.c +++ b/ezlopi-sensors-devices/sensor-0041-ADC-FC28-soilMoisture/sensor_0041_ADC_FC28_soilMoisture.c @@ -63,7 +63,7 @@ int sensor_0041_ADC_FC28_soilMoisture(e_ezlopi_actions_t action, l_ezlopi_item_t static void __prepare_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device) { char* dev_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", dev_name); + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, dev_name); ASSIGN_DEVICE_NAME_V2(device, dev_name); device->cloud_properties.device_id = ezlopi_cloud_generate_device_id(); device->cloud_properties.category = category_humidity; @@ -89,7 +89,7 @@ static void __prepare_item_interface_properties(l_ezlopi_item_t* item, cJSON* cj if (item && cj_device) { item->interface_type = EZLOPI_DEVICE_INTERFACE_MAX; // other - CJSON_GET_VALUE_INT(cj_device, "gpio", item->interface.adc.gpio_num); + CJSON_GET_VALUE_INT(cj_device, ezlopi_gpio_str, item->interface.adc.gpio_num); item->interface.adc.resln_bit = 3; } } diff --git a/ezlopi-sensors-devices/sensor-0042-ADC-shunt-voltmeter/sensor_0042_ADC_shunt_voltmeter.c b/ezlopi-sensors-devices/sensor-0042-ADC-shunt-voltmeter/sensor_0042_ADC_shunt_voltmeter.c index 6eb43e9d2..f70032acf 100644 --- a/ezlopi-sensors-devices/sensor-0042-ADC-shunt-voltmeter/sensor_0042_ADC_shunt_voltmeter.c +++ b/ezlopi-sensors-devices/sensor-0042-ADC-shunt-voltmeter/sensor_0042_ADC_shunt_voltmeter.c @@ -63,7 +63,7 @@ int sensor_0042_ADC_shunt_voltmeter(e_ezlopi_actions_t action, l_ezlopi_item_t* static void __prepare_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device) { char* device_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", device_name); + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, device_name); ASSIGN_DEVICE_NAME_V2(device, device_name); device->cloud_properties.device_id = ezlopi_cloud_generate_device_id(); device->cloud_properties.category = category_level_sensor; diff --git a/ezlopi-sensors-devices/sensor-0043-ADC-GYML8511-UV-intensity/sensor_0043_ADC_GYML8511_UV_intensity.c b/ezlopi-sensors-devices/sensor-0043-ADC-GYML8511-UV-intensity/sensor_0043_ADC_GYML8511_UV_intensity.c index 4a6953b49..374638cf5 100644 --- a/ezlopi-sensors-devices/sensor-0043-ADC-GYML8511-UV-intensity/sensor_0043_ADC_GYML8511_UV_intensity.c +++ b/ezlopi-sensors-devices/sensor-0043-ADC-GYML8511-UV-intensity/sensor_0043_ADC_GYML8511_UV_intensity.c @@ -64,7 +64,7 @@ int sensor_0043_ADC_GYML8511_UV_intensity(e_ezlopi_actions_t action, l_ezlopi_it static void __prepare_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device) { char* dev_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", dev_name); + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, dev_name); ASSIGN_DEVICE_NAME_V2(device, dev_name); device->cloud_properties.device_id = ezlopi_cloud_generate_device_id(); device->cloud_properties.category = category_level_sensor; @@ -90,7 +90,7 @@ static void __prepare_item_interface_properties(l_ezlopi_item_t* item, cJSON* cj if (item && cj_device) { item->interface_type = EZLOPI_DEVICE_INTERFACE_MAX; // other - CJSON_GET_VALUE_INT(cj_device, "gpio", item->interface.adc.gpio_num); + CJSON_GET_VALUE_INT(cj_device, ezlopi_gpio_str, item->interface.adc.gpio_num); item->interface.adc.resln_bit = 3; } } diff --git a/ezlopi-sensors-devices/sensor-0046-ADC-ACS712-05B-currentmeter/sensor_0046_ADC_ACS712_05B_currentmeter.c b/ezlopi-sensors-devices/sensor-0046-ADC-ACS712-05B-currentmeter/sensor_0046_ADC_ACS712_05B_currentmeter.c index 4082b46e7..65ef8126f 100644 --- a/ezlopi-sensors-devices/sensor-0046-ADC-ACS712-05B-currentmeter/sensor_0046_ADC_ACS712_05B_currentmeter.c +++ b/ezlopi-sensors-devices/sensor-0046-ADC-ACS712-05B-currentmeter/sensor_0046_ADC_ACS712_05B_currentmeter.c @@ -65,7 +65,7 @@ int sensor_0046_ADC_ACS712_05B_currentmeter(e_ezlopi_actions_t action, l_ezlopi_ static void __prepare_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device) { char* device_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", device_name); + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, device_name); ASSIGN_DEVICE_NAME_V2(device, device_name); device->cloud_properties.device_id = ezlopi_cloud_generate_device_id(); device->cloud_properties.category = category_level_sensor; @@ -172,10 +172,10 @@ static int __0046_init(l_ezlopi_item_t* item) static int __0046_get_cjson_value(l_ezlopi_item_t* item, void* arg) { int ret = 0; - if (item) + if (item && arg) { - cJSON* cjson_properties = (cJSON*)arg; - if (cjson_properties && item) + cJSON *cjson_properties = (cJSON *)arg; + if (cjson_properties) { s_currentmeter_t* user_data = (s_currentmeter_t*)item->user_arg; if (user_data) diff --git a/ezlopi-sensors-devices/sensor-0047-other-HX711-loadcell/sensor_0047_other_HX711_loadcell.c b/ezlopi-sensors-devices/sensor-0047-other-HX711-loadcell/sensor_0047_other_HX711_loadcell.c index b1e134577..bd4b4dea6 100644 --- a/ezlopi-sensors-devices/sensor-0047-other-HX711-loadcell/sensor_0047_other_HX711_loadcell.c +++ b/ezlopi-sensors-devices/sensor-0047-other-HX711-loadcell/sensor_0047_other_HX711_loadcell.c @@ -34,18 +34,18 @@ typedef struct s_hx711_data float weight; } s_hx711_data_t; -static int __0047_prepare(void *arg); -static int __0047_init(l_ezlopi_item_t *item); -static int __0047_get_cjson_value(l_ezlopi_item_t *item, void *arg); -static int __0047_notify(l_ezlopi_item_t *item); +static int __0047_prepare(void* arg); +static int __0047_init(l_ezlopi_item_t* item); +static int __0047_get_cjson_value(l_ezlopi_item_t* item, void* arg); +static int __0047_notify(l_ezlopi_item_t* item); -static void __hx711_power_reset(l_ezlopi_item_t *item); -static float __hx711_rawdata(l_ezlopi_item_t *item, hx711_gain_t _gain); -static float __hx711_avg_reading(l_ezlopi_item_t *item, uint8_t sample_iteration); +static void __hx711_power_reset(l_ezlopi_item_t* item); +static float __hx711_rawdata(l_ezlopi_item_t* item, hx711_gain_t _gain); +static float __hx711_avg_reading(l_ezlopi_item_t* item, uint8_t sample_iteration); -static void __Calculate_hx711_tare_wt(void *params); +static void __Calculate_hx711_tare_wt(void* params); //------------------------------------------------------------------------------------------------------------------- -int sensor_0047_other_HX711_loadcell(e_ezlopi_actions_t action, l_ezlopi_item_t *item, void *arg, void *user_arg) +int sensor_0047_other_HX711_loadcell(e_ezlopi_actions_t action, l_ezlopi_item_t* item, void* arg, void* user_arg) { int ret = 0; @@ -82,10 +82,10 @@ int sensor_0047_other_HX711_loadcell(e_ezlopi_actions_t action, l_ezlopi_item_t return ret; } //------------------------------------------------------------------------------------------------------ -static void __prepare_device_cloud_properties(l_ezlopi_device_t *device, cJSON *cj_device) +static void __prepare_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device) { - char *device_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", device_name); + char* device_name = NULL; + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, device_name); ASSIGN_DEVICE_NAME_V2(device, device_name); device->cloud_properties.device_id = ezlopi_cloud_generate_device_id(); device->cloud_properties.category = category_level_sensor; @@ -94,7 +94,7 @@ static void __prepare_device_cloud_properties(l_ezlopi_device_t *device, cJSON * device->cloud_properties.info = NULL; device->cloud_properties.device_type = dev_type_sensor; } -static void __prepare_item_cloud_properties(l_ezlopi_item_t *item, cJSON *cj_device, s_hx711_data_t *user_data) +static void __prepare_item_cloud_properties(l_ezlopi_item_t* item, cJSON* cj_device, s_hx711_data_t* user_data) { item->cloud_properties.item_id = ezlopi_cloud_generate_item_id(); item->cloud_properties.has_getter = true; @@ -105,29 +105,29 @@ static void __prepare_item_cloud_properties(l_ezlopi_item_t *item, cJSON *cj_dev item->cloud_properties.scale = scales_kilo_gram; item->user_arg = user_data; - CJSON_GET_VALUE_INT(cj_device, "dev_type", item->interface_type); // _max = 10 - CJSON_GET_VALUE_INT(cj_device, "gpio1", user_data->HX711_SCK_pin); - TRACE_I("hx711_SCL_PIN: %d ", user_data->HX711_SCK_pin); - CJSON_GET_VALUE_INT(cj_device, "gpio2", user_data->HX711_DT_pin); - TRACE_I("hx711_DT_PIN: %d ", user_data->HX711_DT_pin); + CJSON_GET_VALUE_INT(cj_device, ezlopi_dev_type_str, item->interface_type); // _max = 10 + CJSON_GET_VALUE_INT(cj_device, ezlopi_gpio1_str, user_data->HX711_SCK_pin); + TRACE_S("hx711_SCL_PIN: %d ", user_data->HX711_SCK_pin); + CJSON_GET_VALUE_INT(cj_device, ezlopi_gpio2_str, user_data->HX711_DT_pin); + TRACE_S("hx711_DT_PIN: %d ", user_data->HX711_DT_pin); } -static int __0047_prepare(void *arg) +static int __0047_prepare(void* arg) { int ret = 0; - s_ezlopi_prep_arg_t *device_prep_arg = (s_ezlopi_prep_arg_t *)arg; + s_ezlopi_prep_arg_t* device_prep_arg = (s_ezlopi_prep_arg_t*)arg; if (device_prep_arg && (NULL != device_prep_arg->cjson_device)) { - s_hx711_data_t *hx711_data = (s_hx711_data_t *)malloc(sizeof(s_hx711_data_t)); + s_hx711_data_t* hx711_data = (s_hx711_data_t*)malloc(sizeof(s_hx711_data_t)); if (hx711_data) { memset(hx711_data, 0, sizeof(s_hx711_data_t)); //--------------------------- DIGI - DEVICE 1 -------------------------------------------- - l_ezlopi_device_t *hx711_device = ezlopi_device_add_device(device_prep_arg->cjson_device); + l_ezlopi_device_t* hx711_device = ezlopi_device_add_device(device_prep_arg->cjson_device); if (hx711_device) { __prepare_device_cloud_properties(hx711_device, device_prep_arg->cjson_device); - l_ezlopi_item_t *hx711_item = ezlopi_device_add_item_to_device(hx711_device, sensor_0047_other_HX711_loadcell); + l_ezlopi_item_t* hx711_item = ezlopi_device_add_item_to_device(hx711_device, sensor_0047_other_HX711_loadcell); if (hx711_item) { ret = 1; @@ -150,7 +150,7 @@ static int __0047_prepare(void *arg) return ret; } -static int __0047_init(l_ezlopi_item_t *item) +static int __0047_init(l_ezlopi_item_t* item) { int ret = 0; if (item) @@ -211,13 +211,13 @@ static int __0047_init(l_ezlopi_item_t *item) return ret; } -static int __0047_get_cjson_value(l_ezlopi_item_t *item, void *arg) +static int __0047_get_cjson_value(l_ezlopi_item_t* item, void* arg) { int ret = 0; if (item && arg) { - cJSON *cj_result = (cJSON *)arg; + cJSON* cj_result = (cJSON*)arg; if (cj_result) { s_hx711_data_t *user_data = (s_hx711_data_t *)item->user_arg; @@ -234,7 +234,7 @@ static int __0047_get_cjson_value(l_ezlopi_item_t *item, void *arg) return ret; } -static int __0047_notify(l_ezlopi_item_t *item) +static int __0047_notify(l_ezlopi_item_t* item) { int ret = 0; if (item) @@ -261,10 +261,10 @@ static int __0047_notify(l_ezlopi_item_t *item) return ret; } -static void __Calculate_hx711_tare_wt(void *params) +static void __Calculate_hx711_tare_wt(void* params) { float RAW_tare = 0; - l_ezlopi_item_t *item = (l_ezlopi_item_t *)params; + l_ezlopi_item_t* item = (l_ezlopi_item_t*)params; if (item) { s_hx711_data_t *user_data = (s_hx711_data_t *)item->user_arg; @@ -297,7 +297,7 @@ static void __Calculate_hx711_tare_wt(void *params) vTaskDelete(NULL); } -static float __hx711_rawdata(l_ezlopi_item_t *item, hx711_gain_t _gain) +static float __hx711_rawdata(l_ezlopi_item_t* item, hx711_gain_t _gain) { float raw_data = 0; unsigned long data = 0; @@ -364,7 +364,7 @@ static float __hx711_rawdata(l_ezlopi_item_t *item, hx711_gain_t _gain) return raw_data; } -static float __hx711_avg_reading(l_ezlopi_item_t *item, uint8_t sample_iteration) +static float __hx711_avg_reading(l_ezlopi_item_t* item, uint8_t sample_iteration) { float sum = 0; if (sample_iteration < 1) @@ -384,7 +384,7 @@ static float __hx711_avg_reading(l_ezlopi_item_t *item, uint8_t sample_iteration return sum; } -static void __hx711_power_reset(l_ezlopi_item_t *item) +static void __hx711_power_reset(l_ezlopi_item_t* item) { if (item) { diff --git a/ezlopi-sensors-devices/sensor-0057-other-KY026-FlameDetector/sensor_0057_other_KY026_FlameDetector.c b/ezlopi-sensors-devices/sensor-0057-other-KY026-FlameDetector/sensor_0057_other_KY026_FlameDetector.c index 093a4936d..7fd1dc38f 100644 --- a/ezlopi-sensors-devices/sensor-0057-other-KY026-FlameDetector/sensor_0057_other_KY026_FlameDetector.c +++ b/ezlopi-sensors-devices/sensor-0057-other-KY026-FlameDetector/sensor_0057_other_KY026_FlameDetector.c @@ -243,7 +243,7 @@ static void __prepare_item_adc_cloud_properties(l_ezlopi_item_t* item, cJSON* cj CJSON_GET_VALUE_INT(cj_device, ezlopi_dev_type_str, item->interface_type); // _max = 10 CJSON_GET_VALUE_INT(cj_device, ezlopi_gpio2_str, item->interface.adc.gpio_num); - TRACE_S("flame_> ADC_PIN: %d ", item->interface.adc.gpio_num); + TRACE_S("flame-> ADC_PIN: %d ", item->interface.adc.gpio_num); item->interface.adc.resln_bit = 3; // ADC 12_bit // passing the custom data_structure diff --git a/ezlopi-sensors-devices/sensor-0066-other-R307-FingerPrint/sensor_0066_other_R307_FingerPrint.c b/ezlopi-sensors-devices/sensor-0066-other-R307-FingerPrint/sensor_0066_other_R307_FingerPrint.c index 32ac21656..2921abfa4 100644 --- a/ezlopi-sensors-devices/sensor-0066-other-R307-FingerPrint/sensor_0066_other_R307_FingerPrint.c +++ b/ezlopi-sensors-devices/sensor-0066-other-R307-FingerPrint/sensor_0066_other_R307_FingerPrint.c @@ -139,7 +139,7 @@ int sensor_0066_other_R307_FingerPrint(e_ezlopi_actions_t action, l_ezlopi_item_ static void __prepare_device_cloud_properties(l_ezlopi_device_t* device, cJSON* cj_device) { char* dev_name = NULL; - CJSON_GET_VALUE_STRING(cj_device, "dev_name", dev_name); + CJSON_GET_VALUE_STRING(cj_device, ezlopi_dev_name_str, dev_name); ASSIGN_DEVICE_NAME_V2(device, dev_name); device->cloud_properties.device_id = ezlopi_cloud_generate_device_id(); device->cloud_properties.category = category_generic_sensor; diff --git a/ezlopi-sensors-devices/sensor-0067-UART-hilink-presence-sensor/hilink_presence_sensor_setting.c b/ezlopi-sensors-devices/sensor-0067-UART-hilink-presence-sensor/hilink_presence_sensor_setting.c index 13557f15e..6923c3dc1 100644 --- a/ezlopi-sensors-devices/sensor-0067-UART-hilink-presence-sensor/hilink_presence_sensor_setting.c +++ b/ezlopi-sensors-devices/sensor-0067-UART-hilink-presence-sensor/hilink_presence_sensor_setting.c @@ -14,16 +14,16 @@ #include "hilink_presence_sensor_setting.h" #include "sensor_0067_hilink_presence_sensor.h" -static const char *nvs_key_hilink_presence_sensor_predefined_setting = "predef"; -static const char *nvs_key_hilink_presence_sensor_userdefined_setting = "userdef"; -static const char *nvs_key_hilink_presence_sensor_radar_distance_sensitivity = "rdrsens"; -static uint32_t hilink_presence_sensor_setting_ids[3] = {0, 0, 0}; +static const char* nvs_key_hilink_presence_sensor_predefined_setting = "predef"; +static const char* nvs_key_hilink_presence_sensor_userdefined_setting = "userdef"; +static const char* nvs_key_hilink_presence_sensor_radar_distance_sensitivity = "rdrsens"; +static uint32_t hilink_presence_sensor_setting_ids[3] = { 0, 0, 0 }; -static l_ezlopi_device_settings_v3_t *hilink_presence_sensor_radar_distance_sensitivity_setting; -static l_ezlopi_device_settings_v3_t *hilink_presence_sensor_user_defined_setting; -static l_ezlopi_device_settings_v3_t *hilink_presence_sensor_predefined_setting; +static l_ezlopi_device_settings_v3_t* hilink_presence_sensor_radar_distance_sensitivity_setting; +static l_ezlopi_device_settings_v3_t* hilink_presence_sensor_user_defined_setting; +static l_ezlopi_device_settings_v3_t* hilink_presence_sensor_predefined_setting; -static const char *hilink_presence_sensor_setting_enum[] = { +static const char* hilink_presence_sensor_setting_enum[] = { "sleep_mode_close", "sleep_mode_mid", "sleep_mode_long", @@ -45,37 +45,37 @@ static const s_hilink_userdefined_setting_value_t hilink_user_defined_setting_de .is_active = false, }; -static int __settings_callback(e_ezlopi_settings_action_t action, struct l_ezlopi_device_settings_v3 *setting, void *arg, void *user_arg); -static int __settings_get(void *arg, l_ezlopi_device_settings_v3_t *setting); -static int __settings_set(void *arg, l_ezlopi_device_settings_v3_t *setting); -static int __settings_reset(void *arg, l_ezlopi_device_settings_v3_t *setting); -static int __settings_update(void *arg, l_ezlopi_device_settings_v3_t *setting); +static int __settings_callback(e_ezlopi_settings_action_t action, struct l_ezlopi_device_settings_v3* setting, void* arg, void* user_arg); +static int __settings_get(void* arg, l_ezlopi_device_settings_v3_t* setting); +static int __settings_set(void* arg, l_ezlopi_device_settings_v3_t* setting); +static int __settings_reset(void* arg, l_ezlopi_device_settings_v3_t* setting); +static int __settings_update(void* arg, l_ezlopi_device_settings_v3_t* setting); // Setting initialization declarations -static int __setting_initialize_hilink_presence_sensor_predefined_settings(l_ezlopi_device_t *device); -static int __setting_initialize_hilink_presence_sensor_userdefined_settings(l_ezlopi_device_t *device); -static int __setting_initialize_hilink_presence_sensor_radar_distance_sensitivity(l_ezlopi_device_t *device); +static int __setting_initialize_hilink_presence_sensor_predefined_settings(l_ezlopi_device_t* device); +static int __setting_initialize_hilink_presence_sensor_userdefined_settings(l_ezlopi_device_t* device); +static int __setting_initialize_hilink_presence_sensor_radar_distance_sensitivity(l_ezlopi_device_t* device); // Setting getters declarations -static int __setting_get_sensor_enum(cJSON *cj_enum); -static int __setting_get_pre_defined_setting(void *arg, l_ezlopi_device_settings_v3_t *setting); -static int __setting_get_user_defined_setting(void *arg, l_ezlopi_device_settings_v3_t *setting); -static int __setting_get_radar_distance_sensitivity_setting(void *arg, l_ezlopi_device_settings_v3_t *setting); +static int __setting_get_sensor_enum(cJSON* cj_enum); +static int __setting_get_pre_defined_setting(void* arg, l_ezlopi_device_settings_v3_t* setting); +static int __setting_get_user_defined_setting(void* arg, l_ezlopi_device_settings_v3_t* setting); +static int __setting_get_radar_distance_sensitivity_setting(void* arg, l_ezlopi_device_settings_v3_t* setting); // Setting setter declearations static int __setting_set_change_user_defined_template(bool set_active); static int __setting_set_change_setting_template(ld2410_template_t template, uint32_t setting_id); -static int __setting_set_find_predefined_setting_template(s_hilink_predefined_setting_value_t *setting_value, ld2410_template_t *template); -static int __setting_set_pre_defined_setting(void *arg, l_ezlopi_device_settings_v3_t *setting); -static int __setting_set_user_defined_setting(void *arg, l_ezlopi_device_settings_v3_t *setting); +static int __setting_set_find_predefined_setting_template(s_hilink_predefined_setting_value_t* setting_value, ld2410_template_t* template); +static int __setting_set_pre_defined_setting(void* arg, l_ezlopi_device_settings_v3_t* setting); +static int __setting_set_user_defined_setting(void* arg, l_ezlopi_device_settings_v3_t* setting); // Setting reset declarations -static int __setting_reset_pre_defined_setting(void *arg, l_ezlopi_device_settings_v3_t *setting); -static int __setting_reset_user_defined_setting(void *arg, l_ezlopi_device_settings_v3_t *setting); -static int __setting_reset_radar_distance_sensitivity_setting(void *arg, l_ezlopi_device_settings_v3_t *setting); +static int __setting_reset_pre_defined_setting(void* arg, l_ezlopi_device_settings_v3_t* setting); +static int __setting_reset_user_defined_setting(void* arg, l_ezlopi_device_settings_v3_t* setting); +static int __setting_reset_radar_distance_sensitivity_setting(void* arg, l_ezlopi_device_settings_v3_t* setting); // Setting update declarations -static int __setting_update_pre_defined_setting(void *arg, l_ezlopi_device_settings_v3_t *setting); -static int __setting_update_user_defined_setting(void *arg, l_ezlopi_device_settings_v3_t *setting); -static int __setting_update_radar_distance_sensitivity_setting(void *arg, l_ezlopi_device_settings_v3_t *setting); +static int __setting_update_pre_defined_setting(void* arg, l_ezlopi_device_settings_v3_t* setting); +static int __setting_update_user_defined_setting(void* arg, l_ezlopi_device_settings_v3_t* setting); +static int __setting_update_radar_distance_sensitivity_setting(void* arg, l_ezlopi_device_settings_v3_t* setting); // ********************************************* Setting initialization related start ********************************************* // -static int __setting_initialize_hilink_presence_sensor_predefined_settings(l_ezlopi_device_t *device) +static int __setting_initialize_hilink_presence_sensor_predefined_settings(l_ezlopi_device_t* device) { int ret = 0; @@ -84,11 +84,11 @@ static int __setting_initialize_hilink_presence_sensor_predefined_settings(l_ezl if (hilink_presence_sensor_predefined_setting) { hilink_presence_sensor_predefined_setting->cloud_properties.setting_id = hilink_presence_sensor_setting_ids[0]; - s_hilink_predefined_setting_value_t *hilink_presence_sensor_setting_value = (s_hilink_predefined_setting_value_t *)malloc(sizeof(s_hilink_predefined_setting_value_t)); + s_hilink_predefined_setting_value_t* hilink_presence_sensor_setting_value = (s_hilink_predefined_setting_value_t*)malloc(sizeof(s_hilink_predefined_setting_value_t)); if (hilink_presence_sensor_setting_value) { memset(hilink_presence_sensor_setting_value, 0, sizeof(s_hilink_predefined_setting_value_t)); - char *read_value = ezlopi_nvs_read_str(nvs_key_hilink_presence_sensor_predefined_setting); + char* read_value = ezlopi_nvs_read_str(nvs_key_hilink_presence_sensor_predefined_setting); if (NULL != read_value) { TRACE_I("Setting already exist"); @@ -104,7 +104,7 @@ static int __setting_initialize_hilink_presence_sensor_predefined_settings(l_ezl ret = 1; } } - hilink_presence_sensor_predefined_setting->user_arg = (void *)hilink_presence_sensor_setting_value; + hilink_presence_sensor_predefined_setting->user_arg = (void*)hilink_presence_sensor_setting_value; } else { @@ -116,7 +116,7 @@ static int __setting_initialize_hilink_presence_sensor_predefined_settings(l_ezl return ret; } -static int __setting_initialize_hilink_presence_sensor_userdefined_settings(l_ezlopi_device_t *device) +static int __setting_initialize_hilink_presence_sensor_userdefined_settings(l_ezlopi_device_t* device) { int ret = 0; @@ -125,11 +125,11 @@ static int __setting_initialize_hilink_presence_sensor_userdefined_settings(l_ez if (hilink_presence_sensor_user_defined_setting) { hilink_presence_sensor_user_defined_setting->cloud_properties.setting_id = hilink_presence_sensor_setting_ids[1]; - s_hilink_userdefined_setting_value_t *hilink_presence_sensor_user_defined_setting_val = (s_hilink_userdefined_setting_value_t *)malloc(sizeof(s_hilink_userdefined_setting_value_t)); + s_hilink_userdefined_setting_value_t* hilink_presence_sensor_user_defined_setting_val = (s_hilink_userdefined_setting_value_t*)malloc(sizeof(s_hilink_userdefined_setting_value_t)); if (hilink_presence_sensor_user_defined_setting_val) { memset(hilink_presence_sensor_user_defined_setting_val, 0, sizeof(s_hilink_userdefined_setting_value_t)); - char *read_value = ezlopi_nvs_read_str(nvs_key_hilink_presence_sensor_userdefined_setting); + char* read_value = ezlopi_nvs_read_str(nvs_key_hilink_presence_sensor_userdefined_setting); if (NULL != read_value) { TRACE_I("Setting already exist."); @@ -139,7 +139,7 @@ static int __setting_initialize_hilink_presence_sensor_userdefined_settings(l_ez { TRACE_W("Not found saved setting for predefined setting value!"); memcpy(hilink_presence_sensor_user_defined_setting_val, &hilink_user_defined_setting_default_value, sizeof(s_hilink_userdefined_setting_value_t)); - char *user_defined_value = __prepare_user_defined_setting_str(hilink_presence_sensor_user_defined_setting_val); + char* user_defined_value = __prepare_user_defined_setting_str(hilink_presence_sensor_user_defined_setting_val); if (user_defined_value) { if (ezlopi_nvs_write_str(user_defined_value, strlen(user_defined_value), nvs_key_hilink_presence_sensor_userdefined_setting)) @@ -153,7 +153,7 @@ static int __setting_initialize_hilink_presence_sensor_userdefined_settings(l_ez ret = 1; } } - hilink_presence_sensor_user_defined_setting->user_arg = (void *)hilink_presence_sensor_user_defined_setting_val; + hilink_presence_sensor_user_defined_setting->user_arg = (void*)hilink_presence_sensor_user_defined_setting_val; } else { @@ -170,7 +170,7 @@ static int __setting_initialize_hilink_presence_sensor_userdefined_settings(l_ez return ret; } -static int __setting_initialize_hilink_presence_sensor_radar_distance_sensitivity(l_ezlopi_device_t *device) +static int __setting_initialize_hilink_presence_sensor_radar_distance_sensitivity(l_ezlopi_device_t* device) { int ret = 0; if (device) @@ -180,7 +180,7 @@ static int __setting_initialize_hilink_presence_sensor_radar_distance_sensitivit if (hilink_presence_sensor_radar_distance_sensitivity_setting) { hilink_presence_sensor_radar_distance_sensitivity_setting->cloud_properties.setting_id = hilink_presence_sensor_setting_ids[2]; - s_hilink_radar_distance_sensitivity_value_t *distance_sensitivity_value = (s_hilink_radar_distance_sensitivity_value_t *)malloc(sizeof(s_hilink_radar_distance_sensitivity_value_t)); + s_hilink_radar_distance_sensitivity_value_t* distance_sensitivity_value = (s_hilink_radar_distance_sensitivity_value_t*)malloc(sizeof(s_hilink_radar_distance_sensitivity_value_t)); if (distance_sensitivity_value) { memset(distance_sensitivity_value, 0, sizeof(s_hilink_radar_distance_sensitivity_value_t)); @@ -228,7 +228,7 @@ int hilink_presence_sensor_apply_settings() if (hilink_presence_sensor_predefined_setting && hilink_presence_sensor_user_defined_setting) { // Only the predefined setting mode is required to be accessed, if it is set to user_defined_mode, the settings are changed according to the user defined setting automatically. - s_hilink_predefined_setting_value_t *predef_setting_value = (s_hilink_predefined_setting_value_t *)hilink_presence_sensor_predefined_setting->user_arg; + s_hilink_predefined_setting_value_t* predef_setting_value = (s_hilink_predefined_setting_value_t*)hilink_presence_sensor_predefined_setting->user_arg; if (predef_setting_value) { ld2410_template_t template; @@ -249,7 +249,7 @@ int hilink_presence_sensor_apply_settings() return ret; } -int hilink_presence_sensor_initialize_settings(l_ezlopi_device_t *device) +int hilink_presence_sensor_initialize_settings(l_ezlopi_device_t* device) { int ret = 0; @@ -263,7 +263,7 @@ int hilink_presence_sensor_initialize_settings(l_ezlopi_device_t *device) bool hilink_presence_sensor_target_in_detectable_range(const uint16_t moving_target_distance) { bool in_range = false; - s_hilink_radar_distance_sensitivity_value_t *setting_val = (s_hilink_radar_distance_sensitivity_value_t *)hilink_presence_sensor_radar_distance_sensitivity_setting->user_arg; + s_hilink_radar_distance_sensitivity_value_t* setting_val = (s_hilink_radar_distance_sensitivity_value_t*)hilink_presence_sensor_radar_distance_sensitivity_setting->user_arg; if (setting_val) { if (setting_val->distance_sensitivity_value <= moving_target_distance) @@ -284,7 +284,7 @@ bool hilink_presence_sensor_target_in_detectable_range(const uint16_t moving_tar // ********************************************* Setting initialization related end ********************************************* // -static int __settings_callback(e_ezlopi_settings_action_t action, struct l_ezlopi_device_settings_v3 *setting, void *arg, void *user_arg) +static int __settings_callback(e_ezlopi_settings_action_t action, struct l_ezlopi_device_settings_v3* setting, void* arg, void* user_arg) { int ret = 0; switch (action) @@ -298,7 +298,7 @@ static int __settings_callback(e_ezlopi_settings_action_t action, struct l_ezlop case EZLOPI_SETTINGS_ACTION_SET_SETTING: { TRACE_I("%s", stringify(EZLOPI_SETTINGS_ACTION_SET_SETTING)) - __settings_set(arg, setting); + __settings_set(arg, setting); break; } case EZLOPI_SETTINGS_ACTION_RESET_SETTING: @@ -324,7 +324,7 @@ static int __settings_callback(e_ezlopi_settings_action_t action, struct l_ezlop } // ********************************************* hub.device.settings.list related start ********************************************* // -static int __setting_get_sensor_enum(cJSON *cj_enum) +static int __setting_get_sensor_enum(cJSON* cj_enum) { int ret = 0; @@ -348,12 +348,12 @@ static int __setting_get_sensor_enum(cJSON *cj_enum) return ret; } -static int __setting_get_pre_defined_setting(void *arg, l_ezlopi_device_settings_v3_t *setting) +static int __setting_get_pre_defined_setting(void* arg, l_ezlopi_device_settings_v3_t* setting) { int ret = 0; - cJSON *cj_properties = (cJSON *)arg; - s_hilink_predefined_setting_value_t *setting_value = (s_hilink_predefined_setting_value_t *)setting->user_arg; + cJSON* cj_properties = (cJSON*)arg; + s_hilink_predefined_setting_value_t* setting_value = (s_hilink_predefined_setting_value_t*)setting->user_arg; if (cj_properties && setting_value) { cJSON_AddItemToObject(cj_properties, "label", __setting_add_text_and_lang_tag(HILINK_PRESENCE_SENSOR_SETTING_PREDEFINED_LABEL_TEXT, HILINK_PRESENCE_SENSOR_SETTING_PREDEFINED_LABEL_LANG_TAG)); @@ -362,7 +362,7 @@ static int __setting_get_pre_defined_setting(void *arg, l_ezlopi_device_settings cJSON_AddStringToObject(cj_properties, "status", "synced"); cJSON_AddStringToObject(cj_properties, "valueType", value_type_token); - cJSON *enum_object = cJSON_AddObjectToObject(cj_properties, "enum"); + cJSON* enum_object = cJSON_AddObjectToObject(cj_properties, "enum"); if (enum_object) { @@ -379,7 +379,7 @@ static int __setting_get_pre_defined_setting(void *arg, l_ezlopi_device_settings { ret = 1; } - cJSON_AddStringToObject(cj_properties, "value", setting_value->setting_value); + cJSON_AddStringToObject(cj_properties, ezlopi_value_str, setting_value->setting_value); cJSON_AddStringToObject(cj_properties, "valueDefault", hilink_presence_sensor_setting_enum[7]); } else @@ -389,12 +389,12 @@ static int __setting_get_pre_defined_setting(void *arg, l_ezlopi_device_settings return ret; } -static int __setting_get_user_defined_setting(void *arg, l_ezlopi_device_settings_v3_t *setting) +static int __setting_get_user_defined_setting(void* arg, l_ezlopi_device_settings_v3_t* setting) { int ret = 0; - cJSON *cj_properties = (cJSON *)arg; - s_hilink_userdefined_setting_value_t *setting_value = (s_hilink_userdefined_setting_value_t *)setting->user_arg; + cJSON* cj_properties = (cJSON*)arg; + s_hilink_userdefined_setting_value_t* setting_value = (s_hilink_userdefined_setting_value_t*)setting->user_arg; if (cj_properties && setting_value) { cJSON_AddItemToObject(cj_properties, "label", __setting_add_text_and_lang_tag(HILINK_PRESENCE_SENSOR_SETTING_USER_DEFINED_LABEL_TEXT, HILINK_PRESENCE_SENSOR_SETTING_USER_DEFINED_LABEL_LANG_TAG)); @@ -403,15 +403,15 @@ static int __setting_get_user_defined_setting(void *arg, l_ezlopi_device_setting cJSON_AddStringToObject(cj_properties, "status", "synced"); cJSON_AddStringToObject(cj_properties, "valueType", value_type_presence_operation_mode); - cJSON *cj_value = cJSON_AddObjectToObject(cj_properties, "value"); + cJSON* cj_value = cJSON_AddObjectToObject(cj_properties, ezlopi_value_str); if (cj_value) { ESP_ERROR_CHECK(__prepare_user_defined_setting_cjson(cj_value, setting_value)); } - cJSON *cj_value_default = cJSON_AddObjectToObject(cj_properties, "valueDefault"); + cJSON* cj_value_default = cJSON_AddObjectToObject(cj_properties, "valueDefault"); if (cj_value_default) { - ESP_ERROR_CHECK(__prepare_user_defined_setting_cjson(cj_value_default, (s_hilink_userdefined_setting_value_t *)&hilink_user_defined_setting_default_value)); + ESP_ERROR_CHECK(__prepare_user_defined_setting_cjson(cj_value_default, (s_hilink_userdefined_setting_value_t*)&hilink_user_defined_setting_default_value)); } } else @@ -422,12 +422,12 @@ static int __setting_get_user_defined_setting(void *arg, l_ezlopi_device_setting return ret; } -static int __setting_get_radar_distance_sensitivity_setting(void *arg, l_ezlopi_device_settings_v3_t *setting) +static int __setting_get_radar_distance_sensitivity_setting(void* arg, l_ezlopi_device_settings_v3_t* setting) { int ret = 0; - cJSON *cj_properties = (cJSON *)arg; - s_hilink_radar_distance_sensitivity_value_t *setting_value = (s_hilink_radar_distance_sensitivity_value_t *)setting->user_arg; + cJSON* cj_properties = (cJSON*)arg; + s_hilink_radar_distance_sensitivity_value_t* setting_value = (s_hilink_radar_distance_sensitivity_value_t*)setting->user_arg; if (cj_properties && setting_value) { cJSON_AddItemToObject(cj_properties, "label", __setting_add_text_and_lang_tag(HILINK_PRESENCE_SENSOR_SETTING_RADAR_DISTANCE_SENSITIVITY_LABEL_TEXT, HILINK_PRESENCE_SENSOR_SETTING_RADAR_DISTANCE_SENSITIVITY_LABEL_LANG_TAG)); @@ -435,7 +435,7 @@ static int __setting_get_radar_distance_sensitivity_setting(void *arg, l_ezlopi_ cJSON_AddStringToObject(cj_properties, "status", "synced"); cJSON_AddStringToObject(cj_properties, "valueType", value_type_int); - cJSON_AddNumberToObject(cj_properties, "value", setting_value->distance_sensitivity_value); + cJSON_AddNumberToObject(cj_properties, ezlopi_value_str, setting_value->distance_sensitivity_value); cJSON_AddNumberToObject(cj_properties, "valueMin", 5); cJSON_AddNumberToObject(cj_properties, "valueMax", 30); cJSON_AddNumberToObject(cj_properties, "valueDefault", 10); @@ -448,7 +448,7 @@ static int __setting_get_radar_distance_sensitivity_setting(void *arg, l_ezlopi_ return ret; } -static int __settings_get(void *arg, l_ezlopi_device_settings_v3_t *setting) +static int __settings_get(void* arg, l_ezlopi_device_settings_v3_t* setting) { int ret = 0; @@ -476,7 +476,7 @@ static int __setting_set_change_user_defined_template(bool set_active) { int ret = 0; - s_hilink_userdefined_setting_value_t *setting_val = (s_hilink_userdefined_setting_value_t *)hilink_presence_sensor_user_defined_setting->user_arg; + s_hilink_userdefined_setting_value_t* setting_val = (s_hilink_userdefined_setting_value_t*)hilink_presence_sensor_user_defined_setting->user_arg; if (setting_val) { if (set_active) @@ -490,7 +490,7 @@ static int __setting_set_change_user_defined_template(bool set_active) }; ld2410_set_template(CUSTOM_TEMPLATE, &ld2410_setting); setting_val->is_active = true; - char *value_str = __prepare_user_defined_setting_str(setting_val); + char* value_str = __prepare_user_defined_setting_str(setting_val); if (value_str) { if (ezlopi_nvs_write_str(value_str, strlen(value_str), nvs_key_hilink_presence_sensor_userdefined_setting)) @@ -528,7 +528,7 @@ static int __setting_set_change_setting_template(ld2410_template_t template, uin } else { - s_hilink_predefined_setting_value_t *predef_value = (s_hilink_predefined_setting_value_t *)hilink_presence_sensor_predefined_setting->user_arg; + s_hilink_predefined_setting_value_t* predef_value = (s_hilink_predefined_setting_value_t*)hilink_presence_sensor_predefined_setting->user_arg; // If setting change request comes from user defined setting, check if predefined setting mode is set to user defined mode; in this case 9th index in enum str array. if (predef_value && (0 == strcmp(predef_value->setting_value, hilink_presence_sensor_setting_enum[9]))) { @@ -545,7 +545,7 @@ static int __setting_set_change_setting_template(ld2410_template_t template, uin return ret; } -static int __setting_set_find_predefined_setting_template(s_hilink_predefined_setting_value_t *setting_value, ld2410_template_t *template) +static int __setting_set_find_predefined_setting_template(s_hilink_predefined_setting_value_t* setting_value, ld2410_template_t* template) { int ret = 0; if (0 == strcmp(setting_value->setting_value, hilink_presence_sensor_setting_enum[0])) // sleep_mode_close @@ -597,19 +597,19 @@ static int __setting_set_find_predefined_setting_template(s_hilink_predefined_se return ret; } -static int __setting_set_pre_defined_setting(void *arg, l_ezlopi_device_settings_v3_t *setting) +static int __setting_set_pre_defined_setting(void* arg, l_ezlopi_device_settings_v3_t* setting) { int ret = 0; - cJSON *cj_properties = (cJSON *)arg; + cJSON* cj_properties = (cJSON*)arg; ld2410_template_t template; if (cj_properties && setting) { - s_hilink_predefined_setting_value_t *setting_value = (s_hilink_predefined_setting_value_t *)setting->user_arg; + s_hilink_predefined_setting_value_t* setting_value = (s_hilink_predefined_setting_value_t*)setting->user_arg; if (setting_value) { - char *pre_defined_setting_value = NULL; - CJSON_GET_VALUE_STRING(cj_properties, "value", pre_defined_setting_value); + char* pre_defined_setting_value = NULL; + CJSON_GET_VALUE_STRING(cj_properties, ezlopi_value_str, pre_defined_setting_value); if (pre_defined_setting_value) { snprintf(setting_value->setting_value, 50, "%s", pre_defined_setting_value); @@ -645,19 +645,19 @@ static int __setting_set_pre_defined_setting(void *arg, l_ezlopi_device_settings return ret; } -static int __setting_set_user_defined_setting(void *arg, l_ezlopi_device_settings_v3_t *setting) +static int __setting_set_user_defined_setting(void* arg, l_ezlopi_device_settings_v3_t* setting) { int ret = 0; - cJSON *cj_properties = (cJSON *)arg; - s_hilink_userdefined_setting_value_t *setting_val = (s_hilink_userdefined_setting_value_t *)setting->user_arg; + cJSON* cj_properties = (cJSON*)arg; + s_hilink_userdefined_setting_value_t* setting_val = (s_hilink_userdefined_setting_value_t*)setting->user_arg; if (cj_properties && setting && setting_val) { - cJSON *cj_value = cJSON_GetObjectItem(cj_properties, "value"); + cJSON* cj_value = cJSON_GetObjectItem(cj_properties, ezlopi_value_str); if (cj_value) { ESP_ERROR_CHECK(__setting_extract_user_defined_setting(cJSON_Print(cj_value), setting_val)); - char *value_str = __prepare_user_defined_setting_str(setting_val); + char* value_str = __prepare_user_defined_setting_str(setting_val); if (value_str) { if (ezlopi_nvs_write_str(value_str, strlen(value_str), nvs_key_hilink_presence_sensor_userdefined_setting)) @@ -687,15 +687,15 @@ static int __setting_set_user_defined_setting(void *arg, l_ezlopi_device_setting return ret; } -static int __setting_set_radar_distance_sensitivity_setting(void *arg, l_ezlopi_device_settings_v3_t *setting) +static int __setting_set_radar_distance_sensitivity_setting(void* arg, l_ezlopi_device_settings_v3_t* setting) { int ret = 0; - cJSON *cj_properties = (cJSON *)arg; - s_hilink_radar_distance_sensitivity_value_t *setting_val = (s_hilink_radar_distance_sensitivity_value_t *)setting->user_arg; + cJSON* cj_properties = (cJSON*)arg; + s_hilink_radar_distance_sensitivity_value_t* setting_val = (s_hilink_radar_distance_sensitivity_value_t*)setting->user_arg; if (cj_properties && setting && setting_val) { - CJSON_GET_VALUE_INT(cj_properties, "value", setting_val->distance_sensitivity_value); + CJSON_GET_VALUE_INT(cj_properties, ezlopi_value_str, setting_val->distance_sensitivity_value); if (!ezlopi_nvs_write_int32(setting_val->distance_sensitivity_value, nvs_key_hilink_presence_sensor_radar_distance_sensitivity)) { TRACE_E("Failed to write to NVS"); @@ -710,7 +710,7 @@ static int __setting_set_radar_distance_sensitivity_setting(void *arg, l_ezlopi_ return ret; } -static int __settings_set(void *arg, l_ezlopi_device_settings_v3_t *setting) +static int __settings_set(void* arg, l_ezlopi_device_settings_v3_t* setting) { int ret = 0; @@ -734,14 +734,14 @@ static int __settings_set(void *arg, l_ezlopi_device_settings_v3_t *setting) // ********************************************* hub.device.setting.value.set related end ********************************************* // // ********************************************* hub.device.setting.reset related start ********************************************* // -static int __setting_reset_pre_defined_setting(void *arg, l_ezlopi_device_settings_v3_t *setting) +static int __setting_reset_pre_defined_setting(void* arg, l_ezlopi_device_settings_v3_t* setting) { int ret = 0; - cJSON *cj_params = (cJSON *)arg; + cJSON* cj_params = (cJSON*)arg; if (cj_params && setting) { - s_hilink_predefined_setting_value_t *setting_val = (s_hilink_predefined_setting_value_t *)setting->user_arg; + s_hilink_predefined_setting_value_t* setting_val = (s_hilink_predefined_setting_value_t*)setting->user_arg; if (setting_val) { snprintf(setting_val->setting_value, 50, "%s", hilink_presence_sensor_setting_enum[7]); @@ -768,19 +768,19 @@ static int __setting_reset_pre_defined_setting(void *arg, l_ezlopi_device_settin return ret; } -static int __setting_reset_user_defined_setting(void *arg, l_ezlopi_device_settings_v3_t *setting) +static int __setting_reset_user_defined_setting(void* arg, l_ezlopi_device_settings_v3_t* setting) { int ret = 0; - cJSON *cj_params = (cJSON *)arg; + cJSON* cj_params = (cJSON*)arg; if (cj_params && setting) { - s_hilink_userdefined_setting_value_t *setting_val = (s_hilink_userdefined_setting_value_t *)setting->user_arg; + s_hilink_userdefined_setting_value_t* setting_val = (s_hilink_userdefined_setting_value_t*)setting->user_arg; if (setting) { memset(setting_val, 0, sizeof(s_hilink_userdefined_setting_value_t)); memcpy(setting_val, &hilink_user_defined_setting_default_value, sizeof(s_hilink_userdefined_setting_value_t)); - char *setting_val_str = __prepare_user_defined_setting_str(setting_val); + char* setting_val_str = __prepare_user_defined_setting_str(setting_val); if (setting_val_str) { if (ezlopi_nvs_write_str(setting_val_str, strlen(setting_val_str), nvs_key_hilink_presence_sensor_userdefined_setting)) @@ -811,14 +811,14 @@ static int __setting_reset_user_defined_setting(void *arg, l_ezlopi_device_setti return ret; } -static int __setting_reset_radar_distance_sensitivity_setting(void *arg, l_ezlopi_device_settings_v3_t *setting) +static int __setting_reset_radar_distance_sensitivity_setting(void* arg, l_ezlopi_device_settings_v3_t* setting) { int ret = 0; - cJSON *cj_params = (cJSON *)arg; + cJSON* cj_params = (cJSON*)arg; if (cj_params && setting) { - s_hilink_radar_distance_sensitivity_value_t *setting_val = (s_hilink_radar_distance_sensitivity_value_t *)setting->user_arg; + s_hilink_radar_distance_sensitivity_value_t* setting_val = (s_hilink_radar_distance_sensitivity_value_t*)setting->user_arg; if (setting_val) { setting_val->distance_sensitivity_value = 10; @@ -845,7 +845,7 @@ static int __setting_reset_radar_distance_sensitivity_setting(void *arg, l_ezlop return ret; } -static int __settings_reset(void *arg, l_ezlopi_device_settings_v3_t *setting) +static int __settings_reset(void* arg, l_ezlopi_device_settings_v3_t* setting) { int ret = 0; @@ -869,17 +869,17 @@ static int __settings_reset(void *arg, l_ezlopi_device_settings_v3_t *setting) // ********************************************* hub.device.setting.reset related end ********************************************* // // ********************************************* hub.device.setting.updated related start ********************************************* // -static int __setting_update_pre_defined_setting(void *arg, l_ezlopi_device_settings_v3_t *setting) +static int __setting_update_pre_defined_setting(void* arg, l_ezlopi_device_settings_v3_t* setting) { int ret = 0; if (setting) { - cJSON *cj_params = (cJSON *)arg; - s_hilink_predefined_setting_value_t *setting_value = (s_hilink_predefined_setting_value_t *)setting->user_arg; + cJSON* cj_params = (cJSON*)arg; + s_hilink_predefined_setting_value_t* setting_value = (s_hilink_predefined_setting_value_t*)setting->user_arg; if (cj_params && setting_value) { - cJSON_AddStringToObject(cj_params, "value", setting_value->setting_value); + cJSON_AddStringToObject(cj_params, ezlopi_value_str, setting_value->setting_value); } else { @@ -894,15 +894,15 @@ static int __setting_update_pre_defined_setting(void *arg, l_ezlopi_device_setti return ret; } -static int __setting_update_user_defined_setting(void *arg, l_ezlopi_device_settings_v3_t *setting) +static int __setting_update_user_defined_setting(void* arg, l_ezlopi_device_settings_v3_t* setting) { int ret = 0; - cJSON *cj_params = (cJSON *)arg; - s_hilink_userdefined_setting_value_t *setting_value = (s_hilink_userdefined_setting_value_t *)hilink_presence_sensor_user_defined_setting->user_arg; + cJSON* cj_params = (cJSON*)arg; + s_hilink_userdefined_setting_value_t* setting_value = (s_hilink_userdefined_setting_value_t*)hilink_presence_sensor_user_defined_setting->user_arg; if (cj_params && setting && setting_value) { - cJSON *cj_value = cJSON_AddObjectToObject(cj_params, "value"); + cJSON* cj_value = cJSON_AddObjectToObject(cj_params, ezlopi_value_str); if (cj_value) { if (setting_value->is_active) @@ -927,15 +927,15 @@ static int __setting_update_user_defined_setting(void *arg, l_ezlopi_device_sett return ret; } -static int __setting_update_radar_distance_sensitivity_setting(void *arg, l_ezlopi_device_settings_v3_t *setting) +static int __setting_update_radar_distance_sensitivity_setting(void* arg, l_ezlopi_device_settings_v3_t* setting) { int ret = 0; - cJSON *cj_params = (cJSON *)arg; - s_hilink_radar_distance_sensitivity_value_t *setting_value = (s_hilink_radar_distance_sensitivity_value_t *)setting->user_arg; + cJSON* cj_params = (cJSON*)arg; + s_hilink_radar_distance_sensitivity_value_t* setting_value = (s_hilink_radar_distance_sensitivity_value_t*)setting->user_arg; if (cj_params && setting && setting_value) { - cJSON_AddNumberToObject(cj_params, "value", setting_value->distance_sensitivity_value); + cJSON_AddNumberToObject(cj_params, ezlopi_value_str, setting_value->distance_sensitivity_value); } else { @@ -945,7 +945,7 @@ static int __setting_update_radar_distance_sensitivity_setting(void *arg, l_ezlo return ret; } -static int __settings_update(void *arg, l_ezlopi_device_settings_v3_t *setting) +static int __settings_update(void* arg, l_ezlopi_device_settings_v3_t* setting) { int ret = 0; diff --git a/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/sensor_0068_ENS160_gas_sensor.c b/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/sensor_0068_ENS160_gas_sensor.c index 4b1bff128..96819567d 100644 --- a/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/sensor_0068_ENS160_gas_sensor.c +++ b/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/sensor_0068_ENS160_gas_sensor.c @@ -90,22 +90,22 @@ static int __get_cjson_value(l_ezlopi_item_t* item, void* arg) if (item->cloud_properties.item_id == aqi_item_id) { valueFormatted = ezlopi_valueformatter_uint32(ens160_sensor->data.aqi); - cJSON_AddStringToObject(cj_params, "valueFormatted", valueFormatted); - cJSON_AddNumberToObject(cj_params, "value", ens160_sensor->data.aqi); + cJSON_AddStringToObject(cj_params, ezlopi_valueFormatted_str, valueFormatted); + cJSON_AddNumberToObject(cj_params, ezlopi_value_str, ens160_sensor->data.aqi); free(valueFormatted); } if (item->cloud_properties.item_id == voc_item_id) { valueFormatted = ezlopi_valueformatter_uint32(ens160_sensor->data.tvoc); - cJSON_AddStringToObject(cj_params, "valueFormatted", valueFormatted); - cJSON_AddNumberToObject(cj_params, "value", ens160_sensor->data.tvoc); + cJSON_AddStringToObject(cj_params, ezlopi_valueFormatted_str, valueFormatted); + cJSON_AddNumberToObject(cj_params, ezlopi_value_str, ens160_sensor->data.tvoc); free(valueFormatted); } if (item->cloud_properties.item_id == co2_item_id) { valueFormatted = ezlopi_valueformatter_uint32(ens160_sensor->data.eco2); - cJSON_AddStringToObject(cj_params, "valueFormatted", valueFormatted); - cJSON_AddNumberToObject(cj_params, "value", ens160_sensor->data.eco2); + cJSON_AddStringToObject(cj_params, ezlopi_valueFormatted_str, valueFormatted); + cJSON_AddNumberToObject(cj_params, ezlopi_value_str, ens160_sensor->data.eco2); free(valueFormatted); } } diff --git a/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/sensor_0068_ENS160_gas_sensor_settings.c b/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/sensor_0068_ENS160_gas_sensor_settings.c index 57fdef2ce..e4d95e22f 100644 --- a/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/sensor_0068_ENS160_gas_sensor_settings.c +++ b/ezlopi-sensors-devices/sensor-0068-I2C-ENS160-gas-sensor/sensor_0068_ENS160_gas_sensor_settings.c @@ -208,14 +208,14 @@ static int __settings_get_ens160_gas_sensor_ambient_temperature_get(void* arg, l cJSON_AddStringToObject(cj_properties, "status", "synced"); cJSON_AddStringToObject(cj_properties, "valueType", value_type_temperature); - cJSON* value = cJSON_AddObjectToObject(cj_properties, "value"); + cJSON* value = cJSON_AddObjectToObject(cj_properties, ezlopi_value_str); cJSON* valueDefault = cJSON_AddObjectToObject(cj_properties, "valueDefault"); if (value && valueDefault) { - cJSON_AddNumberToObject(value, "value", ambient_temperature->ambient_temperature); + cJSON_AddNumberToObject(value, ezlopi_value_str, ambient_temperature->ambient_temperature); cJSON_AddStringToObject(value, "scale", scales_celsius); - cJSON_AddNumberToObject(valueDefault, "value", 25); + cJSON_AddNumberToObject(valueDefault, ezlopi_value_str, 25); cJSON_AddStringToObject(valueDefault, "scale", scales_celsius); } } @@ -240,14 +240,14 @@ static int __settings_get_ens160_gas_sensor_relative_humidity_get(void* arg, l_e cJSON_AddStringToObject(cj_properties, "status", "synced"); cJSON_AddStringToObject(cj_properties, "valueType", value_type_humidity); - cJSON* value = cJSON_AddObjectToObject(cj_properties, "value"); + cJSON* value = cJSON_AddObjectToObject(cj_properties, ezlopi_value_str); cJSON* valueDefault = cJSON_AddObjectToObject(cj_properties, "valueDefault"); if (value && valueDefault) { - cJSON_AddNumberToObject(value, "value", relative_humidity->relative_humidity); + cJSON_AddNumberToObject(value, ezlopi_value_str, relative_humidity->relative_humidity); cJSON_AddStringToObject(value, "scale", scales_percent); - cJSON_AddNumberToObject(valueDefault, "value", 50); + cJSON_AddNumberToObject(valueDefault, ezlopi_value_str, 50); cJSON_AddStringToObject(valueDefault, "scale", scales_percent); } } @@ -284,7 +284,7 @@ static int __settings_set_ens160_gas_sensor_ambient_temperature_get(void* arg, l s_sensor_ens160_gas_sensor_setting_ambient_temperature_t* ambient_temperature = (s_sensor_ens160_gas_sensor_setting_ambient_temperature_t*)setting->user_arg; if (cj_properties && ambient_temperature) { - CJSON_GET_VALUE_DOUBLE(cj_properties, "value", ambient_temperature->ambient_temperature); + CJSON_GET_VALUE_DOUBLE(cj_properties, ezlopi_value_str, ambient_temperature->ambient_temperature); if (!ezlopi_nvs_write_float32(ambient_temperature->ambient_temperature, nvs_key_ens160_gas_sensor_ambient_temperature_setting)) { TRACE_E("Failed to write to NVS"); @@ -306,7 +306,7 @@ static int __settings_set_ens160_gas_sensor_relative_humidity_get(void* arg, l_e s_sensor_ens160_gas_sensor_setting_relative_humidity_t* relative_humidity = (s_sensor_ens160_gas_sensor_setting_relative_humidity_t*)setting->user_arg; if (cj_properties && relative_humidity) { - CJSON_GET_VALUE_DOUBLE(cj_properties, "value", relative_humidity->relative_humidity); + CJSON_GET_VALUE_DOUBLE(cj_properties, ezlopi_value_str, relative_humidity->relative_humidity); if (!ezlopi_nvs_write_float32(relative_humidity->relative_humidity, nvs_key_ens160_gas_sensor_relative_humidity_setting)) { TRACE_E("Failed to write to NVS"); @@ -354,7 +354,7 @@ static int __settings_update_ens160_gas_sensor_ambient_temperature_get(void* arg s_sensor_ens160_gas_sensor_setting_ambient_temperature_t* ambient_temperature = (s_sensor_ens160_gas_sensor_setting_ambient_temperature_t*)setting->user_arg; if (cj_properties && ambient_temperature) { - cJSON_AddNumberToObject(cj_properties, "value", ambient_temperature->ambient_temperature); + cJSON_AddNumberToObject(cj_properties, ezlopi_value_str, ambient_temperature->ambient_temperature); cJSON_AddStringToObject(cj_properties, "scale", scales_celsius); } else @@ -372,7 +372,7 @@ static int __settings_update_ens160_gas_sensor_relative_humidity_get(void* arg, s_sensor_ens160_gas_sensor_setting_relative_humidity_t* relative_humidity = (s_sensor_ens160_gas_sensor_setting_relative_humidity_t*)setting->user_arg; if (cj_properties && relative_humidity) { - cJSON_AddNumberToObject(cj_properties, "value", relative_humidity->relative_humidity); + cJSON_AddNumberToObject(cj_properties, ezlopi_value_str, relative_humidity->relative_humidity); cJSON_AddStringToObject(cj_properties, "scale", scales_percent); } else diff --git a/ezlopi-sensors-devices/sensor-0069-UART-ze08-ch02-gas-sensor/CMakeLists.txt b/ezlopi-sensors-devices/sensor-0069-UART-ze08-ch02-gas-sensor/CMakeLists.txt index 8b5697e6a..4d01f4e49 100644 --- a/ezlopi-sensors-devices/sensor-0069-UART-ze08-ch02-gas-sensor/CMakeLists.txt +++ b/ezlopi-sensors-devices/sensor-0069-UART-ze08-ch02-gas-sensor/CMakeLists.txt @@ -1,6 +1,6 @@ file(GLOB_RECURSE config_src "*.c") -idf_component_register(SRCS "${config_src}" "ze08_ch2o.c" +idf_component_register(SRCS "sensor_0069_ze08_ch02_gas_sensor.c" "${config_src}" "ze08_ch2o.c" INCLUDE_DIRS "." REQUIRES ezlopi-util-trace ezlopi-core-devices diff --git a/ezlopi-sensors-devices/sensor-0069-UART-ze08-ch02-gas-sensor/sensor_0069_ze08_ch02_gas_sensor.c b/ezlopi-sensors-devices/sensor-0069-UART-ze08-ch02-gas-sensor/sensor_0069_ze08_ch02_gas_sensor.c index 3a6dc31a4..6e4acbe17 100644 --- a/ezlopi-sensors-devices/sensor-0069-UART-ze08-ch02-gas-sensor/sensor_0069_ze08_ch02_gas_sensor.c +++ b/ezlopi-sensors-devices/sensor-0069-UART-ze08-ch02-gas-sensor/sensor_0069_ze08_ch02_gas_sensor.c @@ -78,8 +78,8 @@ static int __get_cjson_value(l_ezlopi_item_t* item, void* arg) if (ze08_ch2o_sensor && cj_params) { char* valueFormatted = ezlopi_valueformatter_float(ze08_ch2o_sensor->ppm); - cJSON_AddStringToObject(cj_params, "valueFormatted", valueFormatted); - cJSON_AddNumberToObject(cj_params, "value", ze08_ch2o_sensor->ppm); + cJSON_AddStringToObject(cj_params, ezlopi_valueFormatted_str, valueFormatted); + cJSON_AddNumberToObject(cj_params, ezlopi_value_str, ze08_ch2o_sensor->ppm); free(valueFormatted); } else diff --git a/ezlopi-services/ezlopi-service-meshbot/ezlopi_service_meshbot.c b/ezlopi-services/ezlopi-service-meshbot/ezlopi_service_meshbot.c index 3539f191c..fe0e5d170 100644 --- a/ezlopi-services/ezlopi-service-meshbot/ezlopi_service_meshbot.c +++ b/ezlopi-services/ezlopi-service-meshbot/ezlopi_service_meshbot.c @@ -139,7 +139,7 @@ void ezlopi_scenes_meshbot_init(void) { if (scene_node->enabled && scene_node->when_block && (scene_node->else_block || scene_node->then_block)) { - xTaskCreate(__scenes_process, scene_node->name, 2 * 2048, scene_node, 2, NULL); + xTaskCreate(__scenes_process, scene_node->name, 3 * 2048, scene_node, 2, NULL); } else { @@ -253,7 +253,7 @@ static void __scenes_process(void* arg) } else { - TRACE_D("Meshobot '%s' is Idle.", scene_node->name); + TRACE_D("Meshobot '%s' is Idle.", scene_node->name); } } diff --git a/ezlopi-services/ezlopi-service-ota/ezlopi_service_ota.c b/ezlopi-services/ezlopi-service-ota/ezlopi_service_ota.c index 01df87676..590155719 100644 --- a/ezlopi-services/ezlopi-service-ota/ezlopi_service_ota.c +++ b/ezlopi-services/ezlopi-service-ota/ezlopi_service_ota.c @@ -16,6 +16,11 @@ #include "ezlopi_core_ezlopi_broadcast.h" static void ota_service_process(void* pv); +static volatile bool __ota_busy = false; +bool __get_ota_service_busy_state(void) +{ + return __ota_busy; +} void ota_service_init(void) { @@ -28,7 +33,7 @@ static void ota_service_process(void* pv) vTaskDelay(5000 / portTICK_RATE_MS); while (1) { - + __ota_busy = true; int ret_nma_reg = ezlopi_event_group_wait_for_event(EZLOPI_EVENT_NMA_REG, 60000, false); int ret_ota = ezlopi_event_group_wait_for_event(EZLOPI_EVENT_OTA, 86400 * 1000, 1); // 86400 seconds in a day (24 hrs) TRACE_D("Configuration Selection NMA Reg: %d", ret_nma_reg); @@ -54,9 +59,11 @@ static void ota_service_process(void* pv) } } } + __ota_busy = false; // must clear immediately ; if OTA-event is serviced } else { + __ota_busy = false; // must clear before the delay vTaskDelay(1000 / portTICK_RATE_MS); } } diff --git a/ezlopi-services/ezlopi-service-ota/ezlopi_service_ota.h b/ezlopi-services/ezlopi-service-ota/ezlopi_service_ota.h index 9a96900c2..b0ba52a57 100644 --- a/ezlopi-services/ezlopi-service-ota/ezlopi_service_ota.h +++ b/ezlopi-services/ezlopi-service-ota/ezlopi_service_ota.h @@ -2,5 +2,6 @@ #define _EZLOPI_SERVICE_OTA_H_ void ota_service_init(void); +bool __get_ota_service_busy_state(void); #endif // _EZLOPI_SERVICE_OTA_H_ diff --git a/ezlopi-services/ezlopi-service-uart/ezlopi_service_uart.c b/ezlopi-services/ezlopi-service-uart/ezlopi_service_uart.c index c44e08a52..b25abe946 100644 --- a/ezlopi-services/ezlopi-service-uart/ezlopi_service_uart.c +++ b/ezlopi-services/ezlopi-service-uart/ezlopi_service_uart.c @@ -548,5 +548,5 @@ static void ezlopi_service_uart_read_config(void) void EZPI_SERVICE_uart_init(void) { serial_init(); - xTaskCreate(ezlopi_service_uart_rx_task, "ezlopi_service_uart_rx_task", 1024 * 10, NULL, configMAX_PRIORITIES, NULL); + xTaskCreate(ezlopi_service_uart_rx_task, "ezlopi_service_uart_rx_task", 1024 * 2, NULL, configMAX_PRIORITIES, NULL); } diff --git a/ezlopi-services/ezlopi-service-webprov/ezlopi_service_webprov.c b/ezlopi-services/ezlopi-service-webprov/ezlopi_service_webprov.c index 6b8c0f991..3a569e211 100644 --- a/ezlopi-services/ezlopi-service-webprov/ezlopi_service_webprov.c +++ b/ezlopi-services/ezlopi-service-webprov/ezlopi_service_webprov.c @@ -387,7 +387,6 @@ static void __config_check(void* pv) vTaskDelay(50000 / portTICK_RATE_MS); } - free(ca_certificate); free(provision_token); free(provisioning_server); diff --git a/sdkconfig b/sdkconfig index c2dbbb17d..724e8cba5 100644 --- a/sdkconfig +++ b/sdkconfig @@ -4,9 +4,9 @@ # CONFIG_IDF_CMAKE=y CONFIG_IDF_TARGET_ARCH_XTENSA=y -CONFIG_IDF_TARGET="esp32s3" -CONFIG_IDF_TARGET_ESP32S3=y -CONFIG_IDF_FIRMWARE_CHIP_ID=0x0009 +CONFIG_IDF_TARGET="esp32" +CONFIG_IDF_TARGET_ESP32=y +CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000 # # SDK tool configuration @@ -38,7 +38,7 @@ CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 # # Bootloader config # -CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x0 +CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x1000 CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y # CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set # CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set @@ -70,48 +70,36 @@ CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT=y # # Security features # -CONFIG_SECURE_BOOT_SUPPORTS_RSA=y -CONFIG_SECURE_TARGET_HAS_SECURE_ROM_DL_MODE=y # CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set # CONFIG_SECURE_BOOT is not set # CONFIG_SECURE_FLASH_ENC_ENABLED is not set # end of Security features -# -# Boot ROM Behavior -# -CONFIG_BOOT_ROM_LOG_ALWAYS_ON=y -# CONFIG_BOOT_ROM_LOG_ALWAYS_OFF is not set -# CONFIG_BOOT_ROM_LOG_ON_GPIO_HIGH is not set -# CONFIG_BOOT_ROM_LOG_ON_GPIO_LOW is not set -# end of Boot ROM Behavior - # # Serial flasher config # CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 # CONFIG_ESPTOOLPY_NO_STUB is not set -# CONFIG_ESPTOOLPY_OCT_FLASH is not set # CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set # CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set CONFIG_ESPTOOLPY_FLASHMODE_DIO=y # CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y CONFIG_ESPTOOLPY_FLASHMODE="dio" -# CONFIG_ESPTOOLPY_FLASHFREQ_120M is not set # CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set CONFIG_ESPTOOLPY_FLASHFREQ_40M=y +# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set # CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set CONFIG_ESPTOOLPY_FLASHFREQ="40m" # CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set -# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set -CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_32MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_64MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_128MB is not set -CONFIG_ESPTOOLPY_FLASHSIZE="8MB" +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y CONFIG_ESPTOOLPY_BEFORE_RESET=y # CONFIG_ESPTOOLPY_BEFORE_NORESET is not set @@ -147,7 +135,8 @@ CONFIG_PARTITION_TABLE_MD5=y # # EzloPi User Config # -# CONFIG_EZPI_UTIL_ENABLE_TRACE is not set +CONFIG_EZPI_DEV_TYPE_TEST=y +CONFIG_EZPI_UTIL_ENABLE_TRACE=y # CONFIG_EZPI_CORE_ENABLE_ETH is not set CONFIG_EZPI_SERV_ENABLE_MESHBOTS=y # CONFIG_EZLOPI_BLE_ENALBE_PASSKEY is not set @@ -158,11 +147,7 @@ CONFIG_EZLOPI_BLE_ENALBE_PAIRING=y # CONFIG_EZPI_MDNS_HOSTNAME="ezlopi_device" CONFIG_EZPI_MDNS_INSTANCE_NAME="ezlopi_serial" -CONFIG_EZPI_MDNS_ENABLE_EXTRA_SERVICES=y -CONFIG_EZPI_MDNS_ENABLE_MANUFACTURER_SERVICE=y -CONFIG_EZPI_MDNS_ENABLE_BRAND_SERVICE=y -CONFIG_EZPI_MDNS_ENABLE_MODEL_SERVICE=y -CONFIG_EZPI_MDNS_ENABLE_NAME_SERVICE=y +# CONFIG_EZPI_MDNS_ENABLE_EXTRA_SERVICES is not set # end of EzloPi mDNS config # end of EzloPi User Config @@ -212,81 +197,51 @@ CONFIG_APPTRACE_LOCK_ENABLE=y # Bluetooth # CONFIG_BT_ENABLED=y -CONFIG_BT_SOC_SUPPORT_5_0=y # # Bluetooth controller # -CONFIG_BT_CTRL_MODE_EFF=1 -CONFIG_BT_CTRL_BLE_MAX_ACT=10 -CONFIG_BT_CTRL_BLE_MAX_ACT_EFF=10 -CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB=0 -CONFIG_BT_CTRL_PINNED_TO_CORE_0=y -# CONFIG_BT_CTRL_PINNED_TO_CORE_1 is not set -CONFIG_BT_CTRL_PINNED_TO_CORE=0 -CONFIG_BT_CTRL_HCI_MODE_VHCI=y -# CONFIG_BT_CTRL_HCI_MODE_UART_H4 is not set -CONFIG_BT_CTRL_HCI_TL=1 -CONFIG_BT_CTRL_ADV_DUP_FILT_MAX=30 -CONFIG_BT_BLE_CCA_MODE_NONE=y -# CONFIG_BT_BLE_CCA_MODE_HW is not set -# CONFIG_BT_BLE_CCA_MODE_SW is not set -CONFIG_BT_BLE_CCA_MODE=0 -CONFIG_BT_CTRL_HW_CCA_VAL=20 -CONFIG_BT_CTRL_HW_CCA_EFF=0 -CONFIG_BT_CTRL_CE_LENGTH_TYPE_ORIG=y -# CONFIG_BT_CTRL_CE_LENGTH_TYPE_CE is not set -# CONFIG_BT_CTRL_CE_LENGTH_TYPE_SD is not set -CONFIG_BT_CTRL_CE_LENGTH_TYPE_EFF=0 -CONFIG_BT_CTRL_TX_ANTENNA_INDEX_0=y -# CONFIG_BT_CTRL_TX_ANTENNA_INDEX_1 is not set -CONFIG_BT_CTRL_TX_ANTENNA_INDEX_EFF=0 -CONFIG_BT_CTRL_RX_ANTENNA_INDEX_0=y -# CONFIG_BT_CTRL_RX_ANTENNA_INDEX_1 is not set -CONFIG_BT_CTRL_RX_ANTENNA_INDEX_EFF=0 -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N24 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N21 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N18 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N15 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N12 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N9 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N6 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N3 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N0 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P3 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P6 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P9 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P12 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P15 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P18 is not set -CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P21=y -CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_EFF=15 -CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP=y -CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM=100 -CONFIG_BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD=20 -CONFIG_BT_CTRL_BLE_SCAN_DUPL=y -CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DEVICE=y -# CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DATA is not set -# CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DATA_DEVICE is not set -CONFIG_BT_CTRL_SCAN_DUPL_TYPE=0 -CONFIG_BT_CTRL_SCAN_DUPL_CACHE_SIZE=100 -CONFIG_BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD=0 -# CONFIG_BT_CTRL_BLE_MESH_SCAN_DUPL_EN is not set -# CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EN is not set -CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_DIS=y -CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EFF=0 +CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y +# CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY is not set +# CONFIG_BTDM_CTRL_MODE_BTDM is not set +CONFIG_BTDM_CTRL_BLE_MAX_CONN=3 +CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF=0 +CONFIG_BTDM_CTRL_PCM_ROLE_EFF=0 +CONFIG_BTDM_CTRL_PCM_POLAR_EFF=0 +CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF=3 +CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF=0 +CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF=0 +CONFIG_BTDM_CTRL_PINNED_TO_CORE_0=y +# CONFIG_BTDM_CTRL_PINNED_TO_CORE_1 is not set +CONFIG_BTDM_CTRL_PINNED_TO_CORE=0 +CONFIG_BTDM_CTRL_HCI_MODE_VHCI=y +# CONFIG_BTDM_CTRL_HCI_MODE_UART_H4 is not set # # MODEM SLEEP Options # -# CONFIG_BT_CTRL_MODEM_SLEEP is not set +CONFIG_BTDM_CTRL_MODEM_SLEEP=y +CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG=y +# CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_EVED is not set +CONFIG_BTDM_CTRL_LPCLK_SEL_MAIN_XTAL=y # end of MODEM SLEEP Options -CONFIG_BT_CTRL_SLEEP_MODE_EFF=0 -CONFIG_BT_CTRL_SLEEP_CLOCK_EFF=0 -CONFIG_BT_CTRL_HCI_TL_EFF=1 -# CONFIG_BT_CTRL_AGC_RECORRECT_EN is not set -# CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX is not set +CONFIG_BTDM_BLE_DEFAULT_SCA_250PPM=y +CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF=1 +CONFIG_BTDM_BLE_SCAN_DUPL=y +CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE=y +# CONFIG_BTDM_SCAN_DUPL_TYPE_DATA is not set +# CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE is not set +CONFIG_BTDM_SCAN_DUPL_TYPE=0 +CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE=100 +CONFIG_BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD=0 +# CONFIG_BTDM_BLE_MESH_SCAN_DUPL_EN is not set +CONFIG_BTDM_CTRL_FULL_SCAN_SUPPORTED=y +CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP=y +CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM=100 +CONFIG_BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD=20 +CONFIG_BTDM_RESERVE_DRAM=0xdb5c +CONFIG_BTDM_CTRL_HLI=y # end of Bluetooth controller CONFIG_BT_BLUEDROID_ENABLED=y @@ -302,6 +257,7 @@ CONFIG_BT_BLUEDROID_PINNED_TO_CORE_0=y CONFIG_BT_BLUEDROID_PINNED_TO_CORE=0 CONFIG_BT_BTU_TASK_STACK_SIZE=4096 # CONFIG_BT_BLUEDROID_MEM_DEBUG is not set +# CONFIG_BT_CLASSIC_ENABLED is not set CONFIG_BT_BLE_ENABLED=y CONFIG_BT_GATTS_ENABLE=y # CONFIG_BT_GATTS_PPCP_CHAR_GAP is not set @@ -316,6 +272,7 @@ CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MODE=0 # CONFIG_BT_GATTS_APPEARANCE_WRITABLE is not set CONFIG_BT_GATTC_ENABLE=y CONFIG_BT_GATTC_MAX_CACHE_CHAR=40 +CONFIG_BT_GATTC_NOTIF_REG_MAX=5 # CONFIG_BT_GATTC_CACHE_NVS_FLASH is not set CONFIG_BT_GATTC_CONNECT_RETRY_COUNT=3 CONFIG_BT_BLE_SMP_ENABLE=y @@ -504,9 +461,8 @@ CONFIG_BT_SMP_ENABLE=y # CONFIG_BT_BLE_ACT_SCAN_REP_ADV_SCAN is not set CONFIG_BT_BLE_ESTAB_LINK_CONN_TOUT=30 CONFIG_BT_MAX_DEVICE_NAME_LEN=32 +# CONFIG_BT_BLE_RPA_SUPPORTED is not set CONFIG_BT_BLE_RPA_TIMEOUT=900 -# CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set -CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y # CONFIG_BT_BLE_HIGH_DUTY_ADV_INTERVAL is not set # end of Bluedroid Options # end of Bluetooth @@ -531,7 +487,6 @@ CONFIG_COAP_LOG_DEFAULT_LEVEL=0 # # CONFIG_ADC_FORCE_XPD_FSM is not set CONFIG_ADC_DISABLE_DAC=y -# CONFIG_ADC_CONTINUOUS_FORCE_USE_ADC2_ON_C3_S3 is not set # end of ADC configuration # @@ -553,6 +508,10 @@ CONFIG_SPI_SLAVE_ISR_IN_IRAM=y # TWAI configuration # # CONFIG_TWAI_ISR_IN_IRAM is not set +# CONFIG_TWAI_ERRATA_FIX_BUS_OFF_REC is not set +# CONFIG_TWAI_ERRATA_FIX_TX_INTR_LOST is not set +# CONFIG_TWAI_ERRATA_FIX_RX_FRAME_INVALID is not set +# CONFIG_TWAI_ERRATA_FIX_RX_FIFO_CORRUPT is not set # CONFIG_TWAI_ERRATA_FIX_LISTEN_ONLY_DOM is not set # end of TWAI configuration @@ -562,6 +521,18 @@ CONFIG_SPI_SLAVE_ISR_IN_IRAM=y CONFIG_UART_ISR_IN_IRAM=y # end of UART configuration +# +# RTCIO configuration +# +# CONFIG_RTCIO_SUPPORT_RTC_GPIO_DESC is not set +# end of RTCIO configuration + +# +# GPIO Configuration +# +# CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL is not set +# end of GPIO Configuration + # # GDMA Configuration # @@ -575,95 +546,87 @@ CONFIG_UART_ISR_IN_IRAM=y # # CONFIG_EFUSE_CUSTOM_TABLE is not set # CONFIG_EFUSE_VIRTUAL is not set -CONFIG_EFUSE_MAX_BLK_LEN=256 +# CONFIG_EFUSE_CODE_SCHEME_COMPAT_NONE is not set +CONFIG_EFUSE_CODE_SCHEME_COMPAT_3_4=y +# CONFIG_EFUSE_CODE_SCHEME_COMPAT_REPEAT is not set +CONFIG_EFUSE_MAX_BLK_LEN=192 # end of eFuse Bit Manager # # ESP-TLS # CONFIG_ESP_TLS_USING_MBEDTLS=y -CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y +# CONFIG_ESP_TLS_USE_SECURE_ELEMENT is not set # CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set # CONFIG_ESP_TLS_SERVER is not set # CONFIG_ESP_TLS_PSK_VERIFICATION is not set -# CONFIG_ESP_TLS_INSECURE is not set +CONFIG_ESP_TLS_INSECURE=y +# CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY is not set # end of ESP-TLS # -# ESP32S3-Specific +# ESP32-specific # -CONFIG_ESP32S3_REV_MIN_0=y -# CONFIG_ESP32S3_REV_MIN_1 is not set -# CONFIG_ESP32S3_REV_MIN_2 is not set -CONFIG_ESP32S3_REV_MIN_FULL=0 +CONFIG_ESP32_REV_MIN_0=y +# CONFIG_ESP32_REV_MIN_1 is not set +# CONFIG_ESP32_REV_MIN_1_1 is not set +# CONFIG_ESP32_REV_MIN_2 is not set +# CONFIG_ESP32_REV_MIN_3 is not set +# CONFIG_ESP32_REV_MIN_3_1 is not set +CONFIG_ESP32_REV_MIN=0 +CONFIG_ESP32_REV_MIN_FULL=0 CONFIG_ESP_REV_MIN_FULL=0 -CONFIG_ESP32S3_REV_MAX_FULL_STR_OPT=y -CONFIG_ESP32S3_REV_MAX_FULL=99 -CONFIG_ESP_REV_MAX_FULL=99 -# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_80 is not set -# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_160 is not set -CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y -CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ=240 - -# -# Cache config -# -CONFIG_ESP32S3_INSTRUCTION_CACHE_16KB=y -# CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB is not set -CONFIG_ESP32S3_INSTRUCTION_CACHE_SIZE=0x4000 -# CONFIG_ESP32S3_INSTRUCTION_CACHE_4WAYS is not set -CONFIG_ESP32S3_INSTRUCTION_CACHE_8WAYS=y -CONFIG_ESP32S3_ICACHE_ASSOCIATED_WAYS=8 -# CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_16B is not set -CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_32B=y -CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_SIZE=32 -# CONFIG_ESP32S3_INSTRUCTION_CACHE_WRAP is not set -# CONFIG_ESP32S3_DATA_CACHE_16KB is not set -CONFIG_ESP32S3_DATA_CACHE_32KB=y -# CONFIG_ESP32S3_DATA_CACHE_64KB is not set -CONFIG_ESP32S3_DATA_CACHE_SIZE=0x8000 -# CONFIG_ESP32S3_DATA_CACHE_4WAYS is not set -CONFIG_ESP32S3_DATA_CACHE_8WAYS=y -CONFIG_ESP32S3_DCACHE_ASSOCIATED_WAYS=8 -# CONFIG_ESP32S3_DATA_CACHE_LINE_16B is not set -CONFIG_ESP32S3_DATA_CACHE_LINE_32B=y -# CONFIG_ESP32S3_DATA_CACHE_LINE_64B is not set -CONFIG_ESP32S3_DATA_CACHE_LINE_SIZE=32 -# CONFIG_ESP32S3_DATA_CACHE_WRAP is not set -# end of Cache config - -# CONFIG_ESP32S3_SPIRAM_SUPPORT is not set -# CONFIG_ESP32S3_TRAX is not set -CONFIG_ESP32S3_TRACEMEM_RESERVE_DRAM=0x0 -# CONFIG_ESP32S3_ULP_COPROC_ENABLED is not set -CONFIG_ESP32S3_ULP_COPROC_RESERVE_MEM=0 -CONFIG_ESP32S3_DEBUG_OCDAWARE=y -CONFIG_ESP32S3_BROWNOUT_DET=y -CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_7=y -# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_6 is not set -# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_5 is not set -# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_4 is not set -# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_3 is not set -# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_2 is not set -# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_1 is not set -CONFIG_ESP32S3_BROWNOUT_DET_LVL=7 -CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC_FRC1=y -# CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC is not set -# CONFIG_ESP32S3_TIME_SYSCALL_USE_FRC1 is not set -# CONFIG_ESP32S3_TIME_SYSCALL_USE_NONE is not set -CONFIG_ESP32S3_RTC_CLK_SRC_INT_RC=y -# CONFIG_ESP32S3_RTC_CLK_SRC_EXT_CRYS is not set -# CONFIG_ESP32S3_RTC_CLK_SRC_EXT_OSC is not set -# CONFIG_ESP32S3_RTC_CLK_SRC_INT_8MD256 is not set -CONFIG_ESP32S3_RTC_CLK_CAL_CYCLES=1024 -CONFIG_ESP32S3_DEEP_SLEEP_WAKEUP_DELAY=2000 -# CONFIG_ESP32S3_RTCDATA_IN_FAST_MEM is not set -# CONFIG_ESP32S3_USE_FIXED_STATIC_RAM_SIZE is not set -# end of ESP32S3-Specific +CONFIG_ESP32_REV_MAX_FULL_STR_OPT=y +CONFIG_ESP32_REV_MAX_FULL=399 +CONFIG_ESP_REV_MAX_FULL=399 +CONFIG_ESP32_DPORT_WORKAROUND=y +# CONFIG_ESP32_DEFAULT_CPU_FREQ_80 is not set +CONFIG_ESP32_DEFAULT_CPU_FREQ_160=y +# CONFIG_ESP32_DEFAULT_CPU_FREQ_240 is not set +CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=160 +# CONFIG_ESP32_SPIRAM_SUPPORT is not set +# CONFIG_ESP32_TRAX is not set +CONFIG_ESP32_TRACEMEM_RESERVE_DRAM=0x0 +# CONFIG_ESP32_ULP_COPROC_ENABLED is not set +CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=0 +CONFIG_ESP32_DEBUG_OCDAWARE=y +CONFIG_ESP32_BROWNOUT_DET=y +CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_0=y +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_1 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_7 is not set +CONFIG_ESP32_BROWNOUT_DET_LVL=0 +CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y +# CONFIG_ESP32_TIME_SYSCALL_USE_RTC is not set +# CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 is not set +# CONFIG_ESP32_TIME_SYSCALL_USE_NONE is not set +CONFIG_ESP32_RTC_CLK_SRC_INT_RC=y +# CONFIG_ESP32_RTC_CLK_SRC_EXT_CRYS is not set +# CONFIG_ESP32_RTC_CLK_SRC_EXT_OSC is not set +# CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256 is not set +CONFIG_ESP32_RTC_CLK_CAL_CYCLES=1024 +CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=2000 +CONFIG_ESP32_XTAL_FREQ_40=y +# CONFIG_ESP32_XTAL_FREQ_26 is not set +# CONFIG_ESP32_XTAL_FREQ_AUTO is not set +CONFIG_ESP32_XTAL_FREQ=40 +# CONFIG_ESP32_DISABLE_BASIC_ROM_CONSOLE is not set +# CONFIG_ESP32_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set +# CONFIG_ESP32_COMPATIBLE_PRE_V3_1_BOOTLOADERS is not set +# CONFIG_ESP32_USE_FIXED_STATIC_RAM_SIZE is not set +CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL=5 +# end of ESP32-specific # # ADC-Calibration # +CONFIG_ADC_CAL_EFUSE_TP_ENABLE=y +CONFIG_ADC_CAL_EFUSE_VREF_ENABLE=y +CONFIG_ADC_CAL_LUT_ENABLE=y # end of ADC-Calibration # @@ -676,6 +639,14 @@ CONFIG_ESP_ERR_TO_NAME_LOOKUP=y # Ethernet # CONFIG_ETH_ENABLED=y +CONFIG_ETH_USE_ESP32_EMAC=y +CONFIG_ETH_PHY_INTERFACE_RMII=y +CONFIG_ETH_RMII_CLK_INPUT=y +# CONFIG_ETH_RMII_CLK_OUTPUT is not set +CONFIG_ETH_RMII_CLK_IN_GPIO=0 +CONFIG_ETH_DMA_BUFFER_SIZE=512 +CONFIG_ETH_DMA_RX_BUFFER_NUM=10 +CONFIG_ETH_DMA_TX_BUFFER_NUM=10 CONFIG_ETH_USE_SPI_ETHERNET=y # CONFIG_ETH_SPI_ETHERNET_DM9051 is not set CONFIG_ETH_SPI_ETHERNET_W5500=y @@ -738,9 +709,10 @@ CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y -# CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES_TWO is not set -CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES_FOUR=y -CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES=4 +# CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_TWO is not set +CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR=y +CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4 +# CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR is not set # end of MAC Config # @@ -750,12 +722,12 @@ CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND=y # CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND is not set +CONFIG_ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS=y # end of Sleep Config # # RTC Clock Config # -CONFIG_RTC_CLOCK_BBPLL_POWER_ON_WITH_USB=y # end of RTC Clock Config # end of Hardware Settings @@ -775,7 +747,6 @@ CONFIG_ESP_IPC_ISR_ENABLE=y # LCD Peripheral Configuration # CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE=32 -# CONFIG_LCD_RGB_ISR_IRAM_SAFE is not set # end of LCD Peripheral Configuration # end of LCD and Touch Panel @@ -796,7 +767,6 @@ CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20 CONFIG_ESP_PHY_MAX_TX_POWER=20 # CONFIG_ESP_PHY_REDUCE_TX_POWER is not set -CONFIG_ESP_PHY_ENABLE_USB=y CONFIG_ESP_PHY_RF_CAL_PARTIAL=y # CONFIG_ESP_PHY_RF_CAL_NONE is not set # CONFIG_ESP_PHY_RF_CAL_FULL is not set @@ -807,8 +777,6 @@ CONFIG_ESP_PHY_CALIBRATION_MODE=0 # Power Management # # CONFIG_PM_ENABLE is not set -CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y -CONFIG_PM_POWER_DOWN_TAGMEM_IN_LIGHT_SLEEP=y # end of Power Management # @@ -826,8 +794,6 @@ CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set -CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK=y -CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y # # Memory protection @@ -843,12 +809,8 @@ CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y CONFIG_ESP_MAIN_TASK_AFFINITY=0x0 CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048 CONFIG_ESP_CONSOLE_UART_DEFAULT=y -# CONFIG_ESP_CONSOLE_USB_CDC is not set -# CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG is not set # CONFIG_ESP_CONSOLE_UART_CUSTOM is not set # CONFIG_ESP_CONSOLE_NONE is not set -# CONFIG_ESP_CONSOLE_SECONDARY_NONE is not set -CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG=y CONFIG_ESP_CONSOLE_UART=y CONFIG_ESP_CONSOLE_MULTIPLE_UART=y CONFIG_ESP_CONSOLE_UART_NUM=0 @@ -863,7 +825,7 @@ CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y # CONFIG_ESP_PANIC_HANDLER_IRAM is not set # CONFIG_ESP_DEBUG_STUBS_ENABLE is not set -CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4=y +CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_5=y # end of ESP System Settings # @@ -875,7 +837,8 @@ CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER=y CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584 CONFIG_ESP_TIMER_INTERRUPT_LEVEL=1 # CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is not set -CONFIG_ESP_TIMER_IMPL_SYSTIMER=y +# CONFIG_ESP_TIMER_IMPL_FRC2 is not set +CONFIG_ESP_TIMER_IMPL_TG0_LAC=y # end of High resolution timer (esp_timer) # @@ -899,13 +862,11 @@ CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y # CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 -CONFIG_ESP32_WIFI_IRAM_OPT=y -CONFIG_ESP32_WIFI_RX_IRAM_OPT=y +# CONFIG_ESP32_WIFI_IRAM_OPT is not set +# CONFIG_ESP32_WIFI_RX_IRAM_OPT is not set CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y # CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set -# CONFIG_ESP_WIFI_FTM_ENABLE is not set # CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is not set -# CONFIG_ESP_WIFI_GCMP_SUPPORT is not set # CONFIG_ESP_WIFI_GMAC_SUPPORT is not set CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y # CONFIG_ESP_WIFI_SLP_BEACON_LOST_OPT is not set @@ -991,10 +952,10 @@ CONFIG_FMB_EVENT_QUEUE_TIMEOUT=20 # # CONFIG_FREERTOS_UNICORE is not set CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF -CONFIG_FREERTOS_TICK_SUPPORT_SYSTIMER=y -CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL1=y -# CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL3 is not set -CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER=y +CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER=y +CONFIG_FREERTOS_CORETIMER_0=y +# CONFIG_FREERTOS_CORETIMER_1 is not set +CONFIG_FREERTOS_SYSTICK_USES_CCOUNT=y CONFIG_FREERTOS_HZ=1000 CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y # CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set @@ -1023,6 +984,7 @@ CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y # CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set # CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set CONFIG_FREERTOS_DEBUG_OCDAWARE=y +# CONFIG_FREERTOS_FPU_IN_ISR is not set CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y # CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH is not set # end of FreeRTOS @@ -1088,11 +1050,12 @@ CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y # CONFIG_LWIP_LOCAL_HOSTNAME="espressif" # CONFIG_LWIP_NETIF_API is not set +CONFIG_LWIP_TCPIP_TASK_PRIO=18 # CONFIG_LWIP_TCPIP_CORE_LOCKING is not set # CONFIG_LWIP_CHECK_THREAD_SAFETY is not set CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y # CONFIG_LWIP_L2_TO_L3_COPY is not set -CONFIG_LWIP_IRAM_OPTIMIZATION=y +# CONFIG_LWIP_IRAM_OPTIMIZATION is not set CONFIG_LWIP_TIMERS_ONDEMAND=y CONFIG_LWIP_MAX_SOCKETS=10 # CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set @@ -1237,7 +1200,7 @@ CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y # CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set # CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y -CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 +CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=8192 CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=2048 CONFIG_MBEDTLS_DYNAMIC_BUFFER=y CONFIG_MBEDTLS_DYNAMIC_FREE_PEER_CERT=y @@ -1258,8 +1221,8 @@ CONFIG_MBEDTLS_ECDH_LEGACY_CONTEXT=y # Certificate Bundle # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y -# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set +# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL is not set +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN=y # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set # CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200 @@ -1268,7 +1231,6 @@ CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200 CONFIG_MBEDTLS_ECP_RESTARTABLE=y CONFIG_MBEDTLS_CMAC_C=y CONFIG_MBEDTLS_HARDWARE_AES=y -CONFIG_MBEDTLS_AES_USE_INTERRUPT=y CONFIG_MBEDTLS_HARDWARE_MPI=y CONFIG_MBEDTLS_HARDWARE_SHA=y CONFIG_MBEDTLS_ROM_MD5=y @@ -1448,7 +1410,6 @@ CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" # CONFIG_SPI_FLASH_VERIFY_WRITE is not set # CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y -# CONFIG_SPI_FLASH_ROM_IMPL is not set CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y # CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS is not set # CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is not set @@ -1472,7 +1433,6 @@ CONFIG_SPI_FLASH_SUPPORT_GD_CHIP=y CONFIG_SPI_FLASH_SUPPORT_WINBOND_CHIP=y CONFIG_SPI_FLASH_SUPPORT_BOYA_CHIP=y CONFIG_SPI_FLASH_SUPPORT_TH_CHIP=y -CONFIG_SPI_FLASH_SUPPORT_MXIC_OPI_CHIP=y # end of Auto-detect flash chips CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=y @@ -1526,12 +1486,6 @@ CONFIG_WS_BUFFER_SIZE=1024 # end of Websocket # end of TCP Transport -# -# TinyUSB Stack -# -# CONFIG_TINYUSB is not set -# end of TinyUSB Stack - # # Unity unit testing library # @@ -1544,24 +1498,10 @@ CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y # CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL is not set # end of Unity unit testing library -# -# USB-OTG -# -CONFIG_USB_OTG_SUPPORTED=y -CONFIG_USB_HOST_CONTROL_TRANSFER_MAX_SIZE=256 -CONFIG_USB_HOST_HW_BUFFER_BIAS_BALANCED=y -# CONFIG_USB_HOST_HW_BUFFER_BIAS_IN is not set -# CONFIG_USB_HOST_HW_BUFFER_BIAS_PERIODIC_OUT is not set - # # Root Hub configuration # -CONFIG_USB_HOST_DEBOUNCE_DELAY_MS=250 -CONFIG_USB_HOST_RESET_HOLD_MS=30 -CONFIG_USB_HOST_RESET_RECOVERY_MS=30 -CONFIG_USB_HOST_SET_ADDR_RECOVERY_MS=10 # end of Root Hub configuration -# end of USB-OTG # # Virtual file system @@ -1673,6 +1613,28 @@ CONFIG_STACK_CHECK_NONE=y # CONFIG_ESP32_APPTRACE_DEST_TRAX is not set CONFIG_ESP32_APPTRACE_DEST_NONE=y CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y +CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y +# CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY is not set +# CONFIG_BTDM_CONTROLLER_MODE_BTDM is not set +CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN=3 +CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN_EFF=3 +CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN_EFF=0 +CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN_EFF=0 +CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE=0 +CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI=y +# CONFIG_BTDM_CONTROLLER_HCI_MODE_UART_H4 is not set +CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=y +CONFIG_BLE_SCAN_DUPLICATE=y +CONFIG_SCAN_DUPLICATE_BY_DEVICE_ADDR=y +# CONFIG_SCAN_DUPLICATE_BY_ADV_DATA is not set +# CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR is not set +CONFIG_SCAN_DUPLICATE_TYPE=0 +CONFIG_DUPLICATE_SCAN_CACHE_SIZE=100 +# CONFIG_BLE_MESH_SCAN_DUPLICATE_EN is not set +CONFIG_BTDM_CONTROLLER_FULL_SCAN_SUPPORTED=y +CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED=y +CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_NUM=100 +CONFIG_BLE_ADV_REPORT_DISCARD_THRSHOLD=20 CONFIG_BLUEDROID_ENABLED=y # CONFIG_NIMBLE_ENABLED is not set CONFIG_BTC_TASK_STACK_SIZE=3072 @@ -1681,6 +1643,7 @@ CONFIG_BLUEDROID_PINNED_TO_CORE_0=y CONFIG_BLUEDROID_PINNED_TO_CORE=0 CONFIG_BTU_TASK_STACK_SIZE=4096 # CONFIG_BLUEDROID_MEM_DEBUG is not set +# CONFIG_CLASSIC_BT_ENABLED is not set CONFIG_GATTS_ENABLE=y # CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL is not set CONFIG_GATTS_SEND_SERVICE_CHANGE_AUTO=y @@ -1855,9 +1818,32 @@ CONFIG_SMP_ENABLE=y # CONFIG_BLE_ACTIVE_SCAN_REPORT_ADV_SCAN_RSP_INDIVIDUALLY is not set CONFIG_BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT=30 CONFIG_ADC2_DISABLE_DAC=y +# CONFIG_SPIRAM_SUPPORT is not set +CONFIG_TRACEMEM_RESERVE_DRAM=0x0 +# CONFIG_ULP_COPROC_ENABLED is not set +CONFIG_ULP_COPROC_RESERVE_MEM=0 +CONFIG_BROWNOUT_DET=y +CONFIG_BROWNOUT_DET_LVL_SEL_0=y +# CONFIG_BROWNOUT_DET_LVL_SEL_1 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_7 is not set +CONFIG_BROWNOUT_DET_LVL=0 +CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC=y +# CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL is not set +# CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_OSC is not set +# CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_8MD256 is not set +# CONFIG_DISABLE_BASIC_ROM_CONSOLE is not set +# CONFIG_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set # CONFIG_EVENT_LOOP_PROFILING is not set CONFIG_POST_EVENTS_FROM_ISR=y CONFIG_POST_EVENTS_FROM_IRAM_ISR=y +# CONFIG_TWO_UNIVERSAL_MAC_ADDRESS is not set +CONFIG_FOUR_UNIVERSAL_MAC_ADDRESS=y +CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS=4 CONFIG_ESP_SYSTEM_PD_FLASH=y CONFIG_ESP32C3_LIGHTSLEEP_GPIO_RESET_WORKAROUND=y CONFIG_IPC_TASK_STACK_SIZE=1536 @@ -1866,12 +1852,10 @@ CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 CONFIG_ESP32_PHY_MAX_TX_POWER=20 # CONFIG_ESP32_REDUCE_PHY_TX_POWER is not set -CONFIG_ESP_SYSTEM_PM_POWER_DOWN_CPU=y # CONFIG_ESP32S2_PANIC_PRINT_HALT is not set CONFIG_ESP32S2_PANIC_PRINT_REBOOT=y # CONFIG_ESP32S2_PANIC_SILENT_REBOOT is not set # CONFIG_ESP32S2_PANIC_GDBSTUB is not set -CONFIG_ESP32S2_ALLOW_RTC_FAST_MEM_AS_HEAP=y CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=3072 CONFIG_MAIN_TASK_STACK_SIZE=3584 @@ -1947,7 +1931,6 @@ CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread" CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y # CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS is not set # CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED is not set -# CONFIG_USB_ENABLED is not set CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y CONFIG_SUPPORT_TERMIOS=y CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS=1 diff --git a/sdkconfig.old b/sdkconfig.old index 4326566c3..1d8b06722 100644 --- a/sdkconfig.old +++ b/sdkconfig.old @@ -4,9 +4,9 @@ # CONFIG_IDF_CMAKE=y CONFIG_IDF_TARGET_ARCH_XTENSA=y -CONFIG_IDF_TARGET="esp32s3" -CONFIG_IDF_TARGET_ESP32S3=y -CONFIG_IDF_FIRMWARE_CHIP_ID=0x0009 +CONFIG_IDF_TARGET="esp32" +CONFIG_IDF_TARGET_ESP32=y +CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000 # # SDK tool configuration @@ -38,7 +38,7 @@ CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 # # Bootloader config # -CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x0 +CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x1000 CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y # CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set # CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set @@ -70,48 +70,36 @@ CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT=y # # Security features # -CONFIG_SECURE_BOOT_SUPPORTS_RSA=y -CONFIG_SECURE_TARGET_HAS_SECURE_ROM_DL_MODE=y # CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set # CONFIG_SECURE_BOOT is not set # CONFIG_SECURE_FLASH_ENC_ENABLED is not set # end of Security features -# -# Boot ROM Behavior -# -CONFIG_BOOT_ROM_LOG_ALWAYS_ON=y -# CONFIG_BOOT_ROM_LOG_ALWAYS_OFF is not set -# CONFIG_BOOT_ROM_LOG_ON_GPIO_HIGH is not set -# CONFIG_BOOT_ROM_LOG_ON_GPIO_LOW is not set -# end of Boot ROM Behavior - # # Serial flasher config # CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 # CONFIG_ESPTOOLPY_NO_STUB is not set -# CONFIG_ESPTOOLPY_OCT_FLASH is not set # CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set # CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set CONFIG_ESPTOOLPY_FLASHMODE_DIO=y # CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y CONFIG_ESPTOOLPY_FLASHMODE="dio" -# CONFIG_ESPTOOLPY_FLASHFREQ_120M is not set # CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set CONFIG_ESPTOOLPY_FLASHFREQ_40M=y +# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set # CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set CONFIG_ESPTOOLPY_FLASHFREQ="40m" # CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set -# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set -CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_32MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_64MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_128MB is not set -CONFIG_ESPTOOLPY_FLASHSIZE="8MB" +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y CONFIG_ESPTOOLPY_BEFORE_RESET=y # CONFIG_ESPTOOLPY_BEFORE_NORESET is not set @@ -147,22 +135,19 @@ CONFIG_PARTITION_TABLE_MD5=y # # EzloPi User Config # +CONFIG_EZPI_DEV_TYPE_TEST=y CONFIG_EZPI_UTIL_ENABLE_TRACE=y # CONFIG_EZPI_CORE_ENABLE_ETH is not set CONFIG_EZPI_SERV_ENABLE_MESHBOTS=y # CONFIG_EZLOPI_BLE_ENALBE_PASSKEY is not set -CONFIG_EZLOPI_BLE_ENALBE_PAIRING=y +# CONFIG_EZLOPI_BLE_ENALBE_PAIRING is not set # # EzloPi mDNS config # CONFIG_EZPI_MDNS_HOSTNAME="ezlopi_device" CONFIG_EZPI_MDNS_INSTANCE_NAME="ezlopi_serial" -CONFIG_EZPI_MDNS_ENABLE_EXTRA_SERVICES=y -CONFIG_EZPI_MDNS_ENABLE_MANUFACTURER_SERVICE=y -CONFIG_EZPI_MDNS_ENABLE_BRAND_SERVICE=y -CONFIG_EZPI_MDNS_ENABLE_MODEL_SERVICE=y -CONFIG_EZPI_MDNS_ENABLE_NAME_SERVICE=y +# CONFIG_EZPI_MDNS_ENABLE_EXTRA_SERVICES is not set # end of EzloPi mDNS config # end of EzloPi User Config @@ -212,81 +197,51 @@ CONFIG_APPTRACE_LOCK_ENABLE=y # Bluetooth # CONFIG_BT_ENABLED=y -CONFIG_BT_SOC_SUPPORT_5_0=y # # Bluetooth controller # -CONFIG_BT_CTRL_MODE_EFF=1 -CONFIG_BT_CTRL_BLE_MAX_ACT=10 -CONFIG_BT_CTRL_BLE_MAX_ACT_EFF=10 -CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB=0 -CONFIG_BT_CTRL_PINNED_TO_CORE_0=y -# CONFIG_BT_CTRL_PINNED_TO_CORE_1 is not set -CONFIG_BT_CTRL_PINNED_TO_CORE=0 -CONFIG_BT_CTRL_HCI_MODE_VHCI=y -# CONFIG_BT_CTRL_HCI_MODE_UART_H4 is not set -CONFIG_BT_CTRL_HCI_TL=1 -CONFIG_BT_CTRL_ADV_DUP_FILT_MAX=30 -CONFIG_BT_BLE_CCA_MODE_NONE=y -# CONFIG_BT_BLE_CCA_MODE_HW is not set -# CONFIG_BT_BLE_CCA_MODE_SW is not set -CONFIG_BT_BLE_CCA_MODE=0 -CONFIG_BT_CTRL_HW_CCA_VAL=20 -CONFIG_BT_CTRL_HW_CCA_EFF=0 -CONFIG_BT_CTRL_CE_LENGTH_TYPE_ORIG=y -# CONFIG_BT_CTRL_CE_LENGTH_TYPE_CE is not set -# CONFIG_BT_CTRL_CE_LENGTH_TYPE_SD is not set -CONFIG_BT_CTRL_CE_LENGTH_TYPE_EFF=0 -CONFIG_BT_CTRL_TX_ANTENNA_INDEX_0=y -# CONFIG_BT_CTRL_TX_ANTENNA_INDEX_1 is not set -CONFIG_BT_CTRL_TX_ANTENNA_INDEX_EFF=0 -CONFIG_BT_CTRL_RX_ANTENNA_INDEX_0=y -# CONFIG_BT_CTRL_RX_ANTENNA_INDEX_1 is not set -CONFIG_BT_CTRL_RX_ANTENNA_INDEX_EFF=0 -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N24 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N21 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N18 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N15 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N12 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N9 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N6 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N3 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N0 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P3 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P6 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P9 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P12 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P15 is not set -# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P18 is not set -CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P21=y -CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_EFF=15 -CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP=y -CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM=100 -CONFIG_BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD=20 -CONFIG_BT_CTRL_BLE_SCAN_DUPL=y -CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DEVICE=y -# CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DATA is not set -# CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DATA_DEVICE is not set -CONFIG_BT_CTRL_SCAN_DUPL_TYPE=0 -CONFIG_BT_CTRL_SCAN_DUPL_CACHE_SIZE=100 -CONFIG_BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD=0 -# CONFIG_BT_CTRL_BLE_MESH_SCAN_DUPL_EN is not set -# CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EN is not set -CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_DIS=y -CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EFF=0 +CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y +# CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY is not set +# CONFIG_BTDM_CTRL_MODE_BTDM is not set +CONFIG_BTDM_CTRL_BLE_MAX_CONN=3 +CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF=0 +CONFIG_BTDM_CTRL_PCM_ROLE_EFF=0 +CONFIG_BTDM_CTRL_PCM_POLAR_EFF=0 +CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF=3 +CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF=0 +CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF=0 +CONFIG_BTDM_CTRL_PINNED_TO_CORE_0=y +# CONFIG_BTDM_CTRL_PINNED_TO_CORE_1 is not set +CONFIG_BTDM_CTRL_PINNED_TO_CORE=0 +CONFIG_BTDM_CTRL_HCI_MODE_VHCI=y +# CONFIG_BTDM_CTRL_HCI_MODE_UART_H4 is not set # # MODEM SLEEP Options # -# CONFIG_BT_CTRL_MODEM_SLEEP is not set +CONFIG_BTDM_CTRL_MODEM_SLEEP=y +CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG=y +# CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_EVED is not set +CONFIG_BTDM_CTRL_LPCLK_SEL_MAIN_XTAL=y # end of MODEM SLEEP Options -CONFIG_BT_CTRL_SLEEP_MODE_EFF=0 -CONFIG_BT_CTRL_SLEEP_CLOCK_EFF=0 -CONFIG_BT_CTRL_HCI_TL_EFF=1 -# CONFIG_BT_CTRL_AGC_RECORRECT_EN is not set -# CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX is not set +CONFIG_BTDM_BLE_DEFAULT_SCA_250PPM=y +CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF=1 +CONFIG_BTDM_BLE_SCAN_DUPL=y +CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE=y +# CONFIG_BTDM_SCAN_DUPL_TYPE_DATA is not set +# CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE is not set +CONFIG_BTDM_SCAN_DUPL_TYPE=0 +CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE=100 +CONFIG_BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD=0 +# CONFIG_BTDM_BLE_MESH_SCAN_DUPL_EN is not set +CONFIG_BTDM_CTRL_FULL_SCAN_SUPPORTED=y +CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP=y +CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM=100 +CONFIG_BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD=20 +CONFIG_BTDM_RESERVE_DRAM=0xdb5c +CONFIG_BTDM_CTRL_HLI=y # end of Bluetooth controller CONFIG_BT_BLUEDROID_ENABLED=y @@ -302,6 +257,7 @@ CONFIG_BT_BLUEDROID_PINNED_TO_CORE_0=y CONFIG_BT_BLUEDROID_PINNED_TO_CORE=0 CONFIG_BT_BTU_TASK_STACK_SIZE=4096 # CONFIG_BT_BLUEDROID_MEM_DEBUG is not set +# CONFIG_BT_CLASSIC_ENABLED is not set CONFIG_BT_BLE_ENABLED=y CONFIG_BT_GATTS_ENABLE=y # CONFIG_BT_GATTS_PPCP_CHAR_GAP is not set @@ -316,6 +272,7 @@ CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MODE=0 # CONFIG_BT_GATTS_APPEARANCE_WRITABLE is not set CONFIG_BT_GATTC_ENABLE=y CONFIG_BT_GATTC_MAX_CACHE_CHAR=40 +CONFIG_BT_GATTC_NOTIF_REG_MAX=5 # CONFIG_BT_GATTC_CACHE_NVS_FLASH is not set CONFIG_BT_GATTC_CONNECT_RETRY_COUNT=3 CONFIG_BT_BLE_SMP_ENABLE=y @@ -504,9 +461,8 @@ CONFIG_BT_SMP_ENABLE=y # CONFIG_BT_BLE_ACT_SCAN_REP_ADV_SCAN is not set CONFIG_BT_BLE_ESTAB_LINK_CONN_TOUT=30 CONFIG_BT_MAX_DEVICE_NAME_LEN=32 +# CONFIG_BT_BLE_RPA_SUPPORTED is not set CONFIG_BT_BLE_RPA_TIMEOUT=900 -# CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set -CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y # CONFIG_BT_BLE_HIGH_DUTY_ADV_INTERVAL is not set # end of Bluedroid Options # end of Bluetooth @@ -531,7 +487,6 @@ CONFIG_COAP_LOG_DEFAULT_LEVEL=0 # # CONFIG_ADC_FORCE_XPD_FSM is not set CONFIG_ADC_DISABLE_DAC=y -# CONFIG_ADC_CONTINUOUS_FORCE_USE_ADC2_ON_C3_S3 is not set # end of ADC configuration # @@ -553,6 +508,10 @@ CONFIG_SPI_SLAVE_ISR_IN_IRAM=y # TWAI configuration # # CONFIG_TWAI_ISR_IN_IRAM is not set +# CONFIG_TWAI_ERRATA_FIX_BUS_OFF_REC is not set +# CONFIG_TWAI_ERRATA_FIX_TX_INTR_LOST is not set +# CONFIG_TWAI_ERRATA_FIX_RX_FRAME_INVALID is not set +# CONFIG_TWAI_ERRATA_FIX_RX_FIFO_CORRUPT is not set # CONFIG_TWAI_ERRATA_FIX_LISTEN_ONLY_DOM is not set # end of TWAI configuration @@ -562,6 +521,18 @@ CONFIG_SPI_SLAVE_ISR_IN_IRAM=y CONFIG_UART_ISR_IN_IRAM=y # end of UART configuration +# +# RTCIO configuration +# +# CONFIG_RTCIO_SUPPORT_RTC_GPIO_DESC is not set +# end of RTCIO configuration + +# +# GPIO Configuration +# +# CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL is not set +# end of GPIO Configuration + # # GDMA Configuration # @@ -575,95 +546,87 @@ CONFIG_UART_ISR_IN_IRAM=y # # CONFIG_EFUSE_CUSTOM_TABLE is not set # CONFIG_EFUSE_VIRTUAL is not set -CONFIG_EFUSE_MAX_BLK_LEN=256 +# CONFIG_EFUSE_CODE_SCHEME_COMPAT_NONE is not set +CONFIG_EFUSE_CODE_SCHEME_COMPAT_3_4=y +# CONFIG_EFUSE_CODE_SCHEME_COMPAT_REPEAT is not set +CONFIG_EFUSE_MAX_BLK_LEN=192 # end of eFuse Bit Manager # # ESP-TLS # CONFIG_ESP_TLS_USING_MBEDTLS=y -CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y +# CONFIG_ESP_TLS_USE_SECURE_ELEMENT is not set # CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set # CONFIG_ESP_TLS_SERVER is not set # CONFIG_ESP_TLS_PSK_VERIFICATION is not set -# CONFIG_ESP_TLS_INSECURE is not set +CONFIG_ESP_TLS_INSECURE=y +# CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY is not set # end of ESP-TLS # -# ESP32S3-Specific +# ESP32-specific # -CONFIG_ESP32S3_REV_MIN_0=y -# CONFIG_ESP32S3_REV_MIN_1 is not set -# CONFIG_ESP32S3_REV_MIN_2 is not set -CONFIG_ESP32S3_REV_MIN_FULL=0 +CONFIG_ESP32_REV_MIN_0=y +# CONFIG_ESP32_REV_MIN_1 is not set +# CONFIG_ESP32_REV_MIN_1_1 is not set +# CONFIG_ESP32_REV_MIN_2 is not set +# CONFIG_ESP32_REV_MIN_3 is not set +# CONFIG_ESP32_REV_MIN_3_1 is not set +CONFIG_ESP32_REV_MIN=0 +CONFIG_ESP32_REV_MIN_FULL=0 CONFIG_ESP_REV_MIN_FULL=0 -CONFIG_ESP32S3_REV_MAX_FULL_STR_OPT=y -CONFIG_ESP32S3_REV_MAX_FULL=99 -CONFIG_ESP_REV_MAX_FULL=99 -# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_80 is not set -# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_160 is not set -CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y -CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ=240 - -# -# Cache config -# -CONFIG_ESP32S3_INSTRUCTION_CACHE_16KB=y -# CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB is not set -CONFIG_ESP32S3_INSTRUCTION_CACHE_SIZE=0x4000 -# CONFIG_ESP32S3_INSTRUCTION_CACHE_4WAYS is not set -CONFIG_ESP32S3_INSTRUCTION_CACHE_8WAYS=y -CONFIG_ESP32S3_ICACHE_ASSOCIATED_WAYS=8 -# CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_16B is not set -CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_32B=y -CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_SIZE=32 -# CONFIG_ESP32S3_INSTRUCTION_CACHE_WRAP is not set -# CONFIG_ESP32S3_DATA_CACHE_16KB is not set -CONFIG_ESP32S3_DATA_CACHE_32KB=y -# CONFIG_ESP32S3_DATA_CACHE_64KB is not set -CONFIG_ESP32S3_DATA_CACHE_SIZE=0x8000 -# CONFIG_ESP32S3_DATA_CACHE_4WAYS is not set -CONFIG_ESP32S3_DATA_CACHE_8WAYS=y -CONFIG_ESP32S3_DCACHE_ASSOCIATED_WAYS=8 -# CONFIG_ESP32S3_DATA_CACHE_LINE_16B is not set -CONFIG_ESP32S3_DATA_CACHE_LINE_32B=y -# CONFIG_ESP32S3_DATA_CACHE_LINE_64B is not set -CONFIG_ESP32S3_DATA_CACHE_LINE_SIZE=32 -# CONFIG_ESP32S3_DATA_CACHE_WRAP is not set -# end of Cache config - -# CONFIG_ESP32S3_SPIRAM_SUPPORT is not set -# CONFIG_ESP32S3_TRAX is not set -CONFIG_ESP32S3_TRACEMEM_RESERVE_DRAM=0x0 -# CONFIG_ESP32S3_ULP_COPROC_ENABLED is not set -CONFIG_ESP32S3_ULP_COPROC_RESERVE_MEM=0 -CONFIG_ESP32S3_DEBUG_OCDAWARE=y -CONFIG_ESP32S3_BROWNOUT_DET=y -CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_7=y -# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_6 is not set -# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_5 is not set -# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_4 is not set -# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_3 is not set -# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_2 is not set -# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_1 is not set -CONFIG_ESP32S3_BROWNOUT_DET_LVL=7 -CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC_FRC1=y -# CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC is not set -# CONFIG_ESP32S3_TIME_SYSCALL_USE_FRC1 is not set -# CONFIG_ESP32S3_TIME_SYSCALL_USE_NONE is not set -CONFIG_ESP32S3_RTC_CLK_SRC_INT_RC=y -# CONFIG_ESP32S3_RTC_CLK_SRC_EXT_CRYS is not set -# CONFIG_ESP32S3_RTC_CLK_SRC_EXT_OSC is not set -# CONFIG_ESP32S3_RTC_CLK_SRC_INT_8MD256 is not set -CONFIG_ESP32S3_RTC_CLK_CAL_CYCLES=1024 -CONFIG_ESP32S3_DEEP_SLEEP_WAKEUP_DELAY=2000 -# CONFIG_ESP32S3_RTCDATA_IN_FAST_MEM is not set -# CONFIG_ESP32S3_USE_FIXED_STATIC_RAM_SIZE is not set -# end of ESP32S3-Specific +CONFIG_ESP32_REV_MAX_FULL_STR_OPT=y +CONFIG_ESP32_REV_MAX_FULL=399 +CONFIG_ESP_REV_MAX_FULL=399 +CONFIG_ESP32_DPORT_WORKAROUND=y +# CONFIG_ESP32_DEFAULT_CPU_FREQ_80 is not set +CONFIG_ESP32_DEFAULT_CPU_FREQ_160=y +# CONFIG_ESP32_DEFAULT_CPU_FREQ_240 is not set +CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=160 +# CONFIG_ESP32_SPIRAM_SUPPORT is not set +# CONFIG_ESP32_TRAX is not set +CONFIG_ESP32_TRACEMEM_RESERVE_DRAM=0x0 +# CONFIG_ESP32_ULP_COPROC_ENABLED is not set +CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=0 +CONFIG_ESP32_DEBUG_OCDAWARE=y +CONFIG_ESP32_BROWNOUT_DET=y +CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_0=y +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_1 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_7 is not set +CONFIG_ESP32_BROWNOUT_DET_LVL=0 +CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y +# CONFIG_ESP32_TIME_SYSCALL_USE_RTC is not set +# CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 is not set +# CONFIG_ESP32_TIME_SYSCALL_USE_NONE is not set +CONFIG_ESP32_RTC_CLK_SRC_INT_RC=y +# CONFIG_ESP32_RTC_CLK_SRC_EXT_CRYS is not set +# CONFIG_ESP32_RTC_CLK_SRC_EXT_OSC is not set +# CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256 is not set +CONFIG_ESP32_RTC_CLK_CAL_CYCLES=1024 +CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=2000 +CONFIG_ESP32_XTAL_FREQ_40=y +# CONFIG_ESP32_XTAL_FREQ_26 is not set +# CONFIG_ESP32_XTAL_FREQ_AUTO is not set +CONFIG_ESP32_XTAL_FREQ=40 +# CONFIG_ESP32_DISABLE_BASIC_ROM_CONSOLE is not set +# CONFIG_ESP32_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set +# CONFIG_ESP32_COMPATIBLE_PRE_V3_1_BOOTLOADERS is not set +# CONFIG_ESP32_USE_FIXED_STATIC_RAM_SIZE is not set +CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL=5 +# end of ESP32-specific # # ADC-Calibration # +CONFIG_ADC_CAL_EFUSE_TP_ENABLE=y +CONFIG_ADC_CAL_EFUSE_VREF_ENABLE=y +CONFIG_ADC_CAL_LUT_ENABLE=y # end of ADC-Calibration # @@ -676,6 +639,14 @@ CONFIG_ESP_ERR_TO_NAME_LOOKUP=y # Ethernet # CONFIG_ETH_ENABLED=y +CONFIG_ETH_USE_ESP32_EMAC=y +CONFIG_ETH_PHY_INTERFACE_RMII=y +CONFIG_ETH_RMII_CLK_INPUT=y +# CONFIG_ETH_RMII_CLK_OUTPUT is not set +CONFIG_ETH_RMII_CLK_IN_GPIO=0 +CONFIG_ETH_DMA_BUFFER_SIZE=512 +CONFIG_ETH_DMA_RX_BUFFER_NUM=10 +CONFIG_ETH_DMA_TX_BUFFER_NUM=10 CONFIG_ETH_USE_SPI_ETHERNET=y # CONFIG_ETH_SPI_ETHERNET_DM9051 is not set CONFIG_ETH_SPI_ETHERNET_W5500=y @@ -738,9 +709,10 @@ CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y -# CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES_TWO is not set -CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES_FOUR=y -CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES=4 +# CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_TWO is not set +CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR=y +CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4 +# CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR is not set # end of MAC Config # @@ -750,12 +722,12 @@ CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND=y # CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND is not set +CONFIG_ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS=y # end of Sleep Config # # RTC Clock Config # -CONFIG_RTC_CLOCK_BBPLL_POWER_ON_WITH_USB=y # end of RTC Clock Config # end of Hardware Settings @@ -775,7 +747,6 @@ CONFIG_ESP_IPC_ISR_ENABLE=y # LCD Peripheral Configuration # CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE=32 -# CONFIG_LCD_RGB_ISR_IRAM_SAFE is not set # end of LCD Peripheral Configuration # end of LCD and Touch Panel @@ -796,7 +767,6 @@ CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20 CONFIG_ESP_PHY_MAX_TX_POWER=20 # CONFIG_ESP_PHY_REDUCE_TX_POWER is not set -CONFIG_ESP_PHY_ENABLE_USB=y CONFIG_ESP_PHY_RF_CAL_PARTIAL=y # CONFIG_ESP_PHY_RF_CAL_NONE is not set # CONFIG_ESP_PHY_RF_CAL_FULL is not set @@ -807,8 +777,6 @@ CONFIG_ESP_PHY_CALIBRATION_MODE=0 # Power Management # # CONFIG_PM_ENABLE is not set -CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y -CONFIG_PM_POWER_DOWN_TAGMEM_IN_LIGHT_SLEEP=y # end of Power Management # @@ -826,8 +794,6 @@ CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set -CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK=y -CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y # # Memory protection @@ -843,12 +809,8 @@ CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y CONFIG_ESP_MAIN_TASK_AFFINITY=0x0 CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048 CONFIG_ESP_CONSOLE_UART_DEFAULT=y -# CONFIG_ESP_CONSOLE_USB_CDC is not set -# CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG is not set # CONFIG_ESP_CONSOLE_UART_CUSTOM is not set # CONFIG_ESP_CONSOLE_NONE is not set -# CONFIG_ESP_CONSOLE_SECONDARY_NONE is not set -CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG=y CONFIG_ESP_CONSOLE_UART=y CONFIG_ESP_CONSOLE_MULTIPLE_UART=y CONFIG_ESP_CONSOLE_UART_NUM=0 @@ -863,7 +825,7 @@ CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y # CONFIG_ESP_PANIC_HANDLER_IRAM is not set # CONFIG_ESP_DEBUG_STUBS_ENABLE is not set -CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4=y +CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_5=y # end of ESP System Settings # @@ -875,7 +837,8 @@ CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER=y CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584 CONFIG_ESP_TIMER_INTERRUPT_LEVEL=1 # CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is not set -CONFIG_ESP_TIMER_IMPL_SYSTIMER=y +# CONFIG_ESP_TIMER_IMPL_FRC2 is not set +CONFIG_ESP_TIMER_IMPL_TG0_LAC=y # end of High resolution timer (esp_timer) # @@ -899,13 +862,11 @@ CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y # CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 -CONFIG_ESP32_WIFI_IRAM_OPT=y -CONFIG_ESP32_WIFI_RX_IRAM_OPT=y +# CONFIG_ESP32_WIFI_IRAM_OPT is not set +# CONFIG_ESP32_WIFI_RX_IRAM_OPT is not set CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y # CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set -# CONFIG_ESP_WIFI_FTM_ENABLE is not set # CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is not set -# CONFIG_ESP_WIFI_GCMP_SUPPORT is not set # CONFIG_ESP_WIFI_GMAC_SUPPORT is not set CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y # CONFIG_ESP_WIFI_SLP_BEACON_LOST_OPT is not set @@ -991,10 +952,10 @@ CONFIG_FMB_EVENT_QUEUE_TIMEOUT=20 # # CONFIG_FREERTOS_UNICORE is not set CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF -CONFIG_FREERTOS_TICK_SUPPORT_SYSTIMER=y -CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL1=y -# CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL3 is not set -CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER=y +CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER=y +CONFIG_FREERTOS_CORETIMER_0=y +# CONFIG_FREERTOS_CORETIMER_1 is not set +CONFIG_FREERTOS_SYSTICK_USES_CCOUNT=y CONFIG_FREERTOS_HZ=1000 CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y # CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set @@ -1023,6 +984,7 @@ CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y # CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set # CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set CONFIG_FREERTOS_DEBUG_OCDAWARE=y +# CONFIG_FREERTOS_FPU_IN_ISR is not set CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y # CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH is not set # end of FreeRTOS @@ -1088,11 +1050,12 @@ CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y # CONFIG_LWIP_LOCAL_HOSTNAME="espressif" # CONFIG_LWIP_NETIF_API is not set +CONFIG_LWIP_TCPIP_TASK_PRIO=18 # CONFIG_LWIP_TCPIP_CORE_LOCKING is not set # CONFIG_LWIP_CHECK_THREAD_SAFETY is not set CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y # CONFIG_LWIP_L2_TO_L3_COPY is not set -CONFIG_LWIP_IRAM_OPTIMIZATION=y +# CONFIG_LWIP_IRAM_OPTIMIZATION is not set CONFIG_LWIP_TIMERS_ONDEMAND=y CONFIG_LWIP_MAX_SOCKETS=10 # CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set @@ -1237,7 +1200,7 @@ CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y # CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set # CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y -CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 +CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=8192 CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=2048 CONFIG_MBEDTLS_DYNAMIC_BUFFER=y CONFIG_MBEDTLS_DYNAMIC_FREE_PEER_CERT=y @@ -1258,8 +1221,8 @@ CONFIG_MBEDTLS_ECDH_LEGACY_CONTEXT=y # Certificate Bundle # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y -# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set +# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL is not set +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN=y # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set # CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200 @@ -1268,7 +1231,6 @@ CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200 CONFIG_MBEDTLS_ECP_RESTARTABLE=y CONFIG_MBEDTLS_CMAC_C=y CONFIG_MBEDTLS_HARDWARE_AES=y -CONFIG_MBEDTLS_AES_USE_INTERRUPT=y CONFIG_MBEDTLS_HARDWARE_MPI=y CONFIG_MBEDTLS_HARDWARE_SHA=y CONFIG_MBEDTLS_ROM_MD5=y @@ -1448,7 +1410,6 @@ CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" # CONFIG_SPI_FLASH_VERIFY_WRITE is not set # CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y -# CONFIG_SPI_FLASH_ROM_IMPL is not set CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y # CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS is not set # CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is not set @@ -1472,7 +1433,6 @@ CONFIG_SPI_FLASH_SUPPORT_GD_CHIP=y CONFIG_SPI_FLASH_SUPPORT_WINBOND_CHIP=y CONFIG_SPI_FLASH_SUPPORT_BOYA_CHIP=y CONFIG_SPI_FLASH_SUPPORT_TH_CHIP=y -CONFIG_SPI_FLASH_SUPPORT_MXIC_OPI_CHIP=y # end of Auto-detect flash chips CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=y @@ -1526,12 +1486,6 @@ CONFIG_WS_BUFFER_SIZE=1024 # end of Websocket # end of TCP Transport -# -# TinyUSB Stack -# -# CONFIG_TINYUSB is not set -# end of TinyUSB Stack - # # Unity unit testing library # @@ -1544,24 +1498,10 @@ CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y # CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL is not set # end of Unity unit testing library -# -# USB-OTG -# -CONFIG_USB_OTG_SUPPORTED=y -CONFIG_USB_HOST_CONTROL_TRANSFER_MAX_SIZE=256 -CONFIG_USB_HOST_HW_BUFFER_BIAS_BALANCED=y -# CONFIG_USB_HOST_HW_BUFFER_BIAS_IN is not set -# CONFIG_USB_HOST_HW_BUFFER_BIAS_PERIODIC_OUT is not set - # # Root Hub configuration # -CONFIG_USB_HOST_DEBOUNCE_DELAY_MS=250 -CONFIG_USB_HOST_RESET_HOLD_MS=30 -CONFIG_USB_HOST_RESET_RECOVERY_MS=30 -CONFIG_USB_HOST_SET_ADDR_RECOVERY_MS=10 # end of Root Hub configuration -# end of USB-OTG # # Virtual file system @@ -1632,323 +1572,3 @@ CONFIG_LUA_ROOT="/lua" # # CONFIG_LEGACY_INCLUDE_COMMON_HEADERS is not set # end of Compatibility options - -# Deprecated options for backward compatibility -CONFIG_TOOLPREFIX="xtensa-esp32s3-elf-" -CONFIG_LOG_BOOTLOADER_LEVEL_NONE=y -# CONFIG_LOG_BOOTLOADER_LEVEL_ERROR is not set -# CONFIG_LOG_BOOTLOADER_LEVEL_WARN is not set -# CONFIG_LOG_BOOTLOADER_LEVEL_INFO is not set -# CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set -# CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set -CONFIG_LOG_BOOTLOADER_LEVEL=0 -# CONFIG_APP_ROLLBACK_ENABLE is not set -# CONFIG_FLASH_ENCRYPTION_ENABLED is not set -# CONFIG_FLASHMODE_QIO is not set -# CONFIG_FLASHMODE_QOUT is not set -CONFIG_FLASHMODE_DIO=y -# CONFIG_FLASHMODE_DOUT is not set -# CONFIG_MONITOR_BAUD_9600B is not set -# CONFIG_MONITOR_BAUD_57600B is not set -CONFIG_MONITOR_BAUD_115200B=y -# CONFIG_MONITOR_BAUD_230400B is not set -# CONFIG_MONITOR_BAUD_921600B is not set -# CONFIG_MONITOR_BAUD_2MB is not set -# CONFIG_MONITOR_BAUD_OTHER is not set -CONFIG_MONITOR_BAUD_OTHER_VAL=115200 -CONFIG_MONITOR_BAUD=115200 -CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y -# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set -CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y -# CONFIG_OPTIMIZATION_ASSERTIONS_SILENT is not set -# CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED is not set -CONFIG_OPTIMIZATION_ASSERTION_LEVEL=2 -# CONFIG_CXX_EXCEPTIONS is not set -CONFIG_STACK_CHECK_NONE=y -# CONFIG_STACK_CHECK_NORM is not set -# CONFIG_STACK_CHECK_STRONG is not set -# CONFIG_STACK_CHECK_ALL is not set -# CONFIG_WARN_WRITE_STRINGS is not set -# CONFIG_DISABLE_GCC8_WARNINGS is not set -# CONFIG_ESP32_APPTRACE_DEST_TRAX is not set -CONFIG_ESP32_APPTRACE_DEST_NONE=y -CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y -CONFIG_BLUEDROID_ENABLED=y -# CONFIG_NIMBLE_ENABLED is not set -CONFIG_BTC_TASK_STACK_SIZE=3072 -CONFIG_BLUEDROID_PINNED_TO_CORE_0=y -# CONFIG_BLUEDROID_PINNED_TO_CORE_1 is not set -CONFIG_BLUEDROID_PINNED_TO_CORE=0 -CONFIG_BTU_TASK_STACK_SIZE=4096 -# CONFIG_BLUEDROID_MEM_DEBUG is not set -CONFIG_GATTS_ENABLE=y -# CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL is not set -CONFIG_GATTS_SEND_SERVICE_CHANGE_AUTO=y -CONFIG_GATTS_SEND_SERVICE_CHANGE_MODE=0 -CONFIG_GATTC_ENABLE=y -# CONFIG_GATTC_CACHE_NVS_FLASH is not set -CONFIG_BLE_SMP_ENABLE=y -# CONFIG_SMP_SLAVE_CON_PARAMS_UPD_ENABLE is not set -# CONFIG_HCI_TRACE_LEVEL_NONE is not set -# CONFIG_HCI_TRACE_LEVEL_ERROR is not set -CONFIG_HCI_TRACE_LEVEL_WARNING=y -# CONFIG_HCI_TRACE_LEVEL_API is not set -# CONFIG_HCI_TRACE_LEVEL_EVENT is not set -# CONFIG_HCI_TRACE_LEVEL_DEBUG is not set -# CONFIG_HCI_TRACE_LEVEL_VERBOSE is not set -CONFIG_HCI_INITIAL_TRACE_LEVEL=2 -# CONFIG_BTM_TRACE_LEVEL_NONE is not set -# CONFIG_BTM_TRACE_LEVEL_ERROR is not set -CONFIG_BTM_TRACE_LEVEL_WARNING=y -# CONFIG_BTM_TRACE_LEVEL_API is not set -# CONFIG_BTM_TRACE_LEVEL_EVENT is not set -# CONFIG_BTM_TRACE_LEVEL_DEBUG is not set -# CONFIG_BTM_TRACE_LEVEL_VERBOSE is not set -CONFIG_BTM_INITIAL_TRACE_LEVEL=2 -# CONFIG_L2CAP_TRACE_LEVEL_NONE is not set -# CONFIG_L2CAP_TRACE_LEVEL_ERROR is not set -CONFIG_L2CAP_TRACE_LEVEL_WARNING=y -# CONFIG_L2CAP_TRACE_LEVEL_API is not set -# CONFIG_L2CAP_TRACE_LEVEL_EVENT is not set -# CONFIG_L2CAP_TRACE_LEVEL_DEBUG is not set -# CONFIG_L2CAP_TRACE_LEVEL_VERBOSE is not set -CONFIG_L2CAP_INITIAL_TRACE_LEVEL=2 -# CONFIG_RFCOMM_TRACE_LEVEL_NONE is not set -# CONFIG_RFCOMM_TRACE_LEVEL_ERROR is not set -CONFIG_RFCOMM_TRACE_LEVEL_WARNING=y -# CONFIG_RFCOMM_TRACE_LEVEL_API is not set -# CONFIG_RFCOMM_TRACE_LEVEL_EVENT is not set -# CONFIG_RFCOMM_TRACE_LEVEL_DEBUG is not set -# CONFIG_RFCOMM_TRACE_LEVEL_VERBOSE is not set -CONFIG_RFCOMM_INITIAL_TRACE_LEVEL=2 -# CONFIG_SDP_TRACE_LEVEL_NONE is not set -# CONFIG_SDP_TRACE_LEVEL_ERROR is not set -CONFIG_SDP_TRACE_LEVEL_WARNING=y -# CONFIG_SDP_TRACE_LEVEL_API is not set -# CONFIG_SDP_TRACE_LEVEL_EVENT is not set -# CONFIG_SDP_TRACE_LEVEL_DEBUG is not set -# CONFIG_SDP_TRACE_LEVEL_VERBOSE is not set -CONFIG_BTH_LOG_SDP_INITIAL_TRACE_LEVEL=2 -# CONFIG_GAP_TRACE_LEVEL_NONE is not set -# CONFIG_GAP_TRACE_LEVEL_ERROR is not set -CONFIG_GAP_TRACE_LEVEL_WARNING=y -# CONFIG_GAP_TRACE_LEVEL_API is not set -# CONFIG_GAP_TRACE_LEVEL_EVENT is not set -# CONFIG_GAP_TRACE_LEVEL_DEBUG is not set -# CONFIG_GAP_TRACE_LEVEL_VERBOSE is not set -CONFIG_GAP_INITIAL_TRACE_LEVEL=2 -CONFIG_BNEP_INITIAL_TRACE_LEVEL=2 -# CONFIG_PAN_TRACE_LEVEL_NONE is not set -# CONFIG_PAN_TRACE_LEVEL_ERROR is not set -CONFIG_PAN_TRACE_LEVEL_WARNING=y -# CONFIG_PAN_TRACE_LEVEL_API is not set -# CONFIG_PAN_TRACE_LEVEL_EVENT is not set -# CONFIG_PAN_TRACE_LEVEL_DEBUG is not set -# CONFIG_PAN_TRACE_LEVEL_VERBOSE is not set -CONFIG_PAN_INITIAL_TRACE_LEVEL=2 -# CONFIG_A2D_TRACE_LEVEL_NONE is not set -# CONFIG_A2D_TRACE_LEVEL_ERROR is not set -CONFIG_A2D_TRACE_LEVEL_WARNING=y -# CONFIG_A2D_TRACE_LEVEL_API is not set -# CONFIG_A2D_TRACE_LEVEL_EVENT is not set -# CONFIG_A2D_TRACE_LEVEL_DEBUG is not set -# CONFIG_A2D_TRACE_LEVEL_VERBOSE is not set -CONFIG_A2D_INITIAL_TRACE_LEVEL=2 -# CONFIG_AVDT_TRACE_LEVEL_NONE is not set -# CONFIG_AVDT_TRACE_LEVEL_ERROR is not set -CONFIG_AVDT_TRACE_LEVEL_WARNING=y -# CONFIG_AVDT_TRACE_LEVEL_API is not set -# CONFIG_AVDT_TRACE_LEVEL_EVENT is not set -# CONFIG_AVDT_TRACE_LEVEL_DEBUG is not set -# CONFIG_AVDT_TRACE_LEVEL_VERBOSE is not set -CONFIG_AVDT_INITIAL_TRACE_LEVEL=2 -# CONFIG_AVCT_TRACE_LEVEL_NONE is not set -# CONFIG_AVCT_TRACE_LEVEL_ERROR is not set -CONFIG_AVCT_TRACE_LEVEL_WARNING=y -# CONFIG_AVCT_TRACE_LEVEL_API is not set -# CONFIG_AVCT_TRACE_LEVEL_EVENT is not set -# CONFIG_AVCT_TRACE_LEVEL_DEBUG is not set -# CONFIG_AVCT_TRACE_LEVEL_VERBOSE is not set -CONFIG_AVCT_INITIAL_TRACE_LEVEL=2 -# CONFIG_AVRC_TRACE_LEVEL_NONE is not set -# CONFIG_AVRC_TRACE_LEVEL_ERROR is not set -CONFIG_AVRC_TRACE_LEVEL_WARNING=y -# CONFIG_AVRC_TRACE_LEVEL_API is not set -# CONFIG_AVRC_TRACE_LEVEL_EVENT is not set -# CONFIG_AVRC_TRACE_LEVEL_DEBUG is not set -# CONFIG_AVRC_TRACE_LEVEL_VERBOSE is not set -CONFIG_AVRC_INITIAL_TRACE_LEVEL=2 -# CONFIG_MCA_TRACE_LEVEL_NONE is not set -# CONFIG_MCA_TRACE_LEVEL_ERROR is not set -CONFIG_MCA_TRACE_LEVEL_WARNING=y -# CONFIG_MCA_TRACE_LEVEL_API is not set -# CONFIG_MCA_TRACE_LEVEL_EVENT is not set -# CONFIG_MCA_TRACE_LEVEL_DEBUG is not set -# CONFIG_MCA_TRACE_LEVEL_VERBOSE is not set -CONFIG_MCA_INITIAL_TRACE_LEVEL=2 -# CONFIG_HID_TRACE_LEVEL_NONE is not set -# CONFIG_HID_TRACE_LEVEL_ERROR is not set -CONFIG_HID_TRACE_LEVEL_WARNING=y -# CONFIG_HID_TRACE_LEVEL_API is not set -# CONFIG_HID_TRACE_LEVEL_EVENT is not set -# CONFIG_HID_TRACE_LEVEL_DEBUG is not set -# CONFIG_HID_TRACE_LEVEL_VERBOSE is not set -CONFIG_HID_INITIAL_TRACE_LEVEL=2 -# CONFIG_APPL_TRACE_LEVEL_NONE is not set -# CONFIG_APPL_TRACE_LEVEL_ERROR is not set -CONFIG_APPL_TRACE_LEVEL_WARNING=y -# CONFIG_APPL_TRACE_LEVEL_API is not set -# CONFIG_APPL_TRACE_LEVEL_EVENT is not set -# CONFIG_APPL_TRACE_LEVEL_DEBUG is not set -# CONFIG_APPL_TRACE_LEVEL_VERBOSE is not set -CONFIG_APPL_INITIAL_TRACE_LEVEL=2 -# CONFIG_GATT_TRACE_LEVEL_NONE is not set -# CONFIG_GATT_TRACE_LEVEL_ERROR is not set -CONFIG_GATT_TRACE_LEVEL_WARNING=y -# CONFIG_GATT_TRACE_LEVEL_API is not set -# CONFIG_GATT_TRACE_LEVEL_EVENT is not set -# CONFIG_GATT_TRACE_LEVEL_DEBUG is not set -# CONFIG_GATT_TRACE_LEVEL_VERBOSE is not set -CONFIG_GATT_INITIAL_TRACE_LEVEL=2 -# CONFIG_SMP_TRACE_LEVEL_NONE is not set -# CONFIG_SMP_TRACE_LEVEL_ERROR is not set -CONFIG_SMP_TRACE_LEVEL_WARNING=y -# CONFIG_SMP_TRACE_LEVEL_API is not set -# CONFIG_SMP_TRACE_LEVEL_EVENT is not set -# CONFIG_SMP_TRACE_LEVEL_DEBUG is not set -# CONFIG_SMP_TRACE_LEVEL_VERBOSE is not set -CONFIG_SMP_INITIAL_TRACE_LEVEL=2 -# CONFIG_BTIF_TRACE_LEVEL_NONE is not set -# CONFIG_BTIF_TRACE_LEVEL_ERROR is not set -CONFIG_BTIF_TRACE_LEVEL_WARNING=y -# CONFIG_BTIF_TRACE_LEVEL_API is not set -# CONFIG_BTIF_TRACE_LEVEL_EVENT is not set -# CONFIG_BTIF_TRACE_LEVEL_DEBUG is not set -# CONFIG_BTIF_TRACE_LEVEL_VERBOSE is not set -CONFIG_BTIF_INITIAL_TRACE_LEVEL=2 -# CONFIG_BTC_TRACE_LEVEL_NONE is not set -# CONFIG_BTC_TRACE_LEVEL_ERROR is not set -CONFIG_BTC_TRACE_LEVEL_WARNING=y -# CONFIG_BTC_TRACE_LEVEL_API is not set -# CONFIG_BTC_TRACE_LEVEL_EVENT is not set -# CONFIG_BTC_TRACE_LEVEL_DEBUG is not set -# CONFIG_BTC_TRACE_LEVEL_VERBOSE is not set -CONFIG_BTC_INITIAL_TRACE_LEVEL=2 -# CONFIG_OSI_TRACE_LEVEL_NONE is not set -# CONFIG_OSI_TRACE_LEVEL_ERROR is not set -CONFIG_OSI_TRACE_LEVEL_WARNING=y -# CONFIG_OSI_TRACE_LEVEL_API is not set -# CONFIG_OSI_TRACE_LEVEL_EVENT is not set -# CONFIG_OSI_TRACE_LEVEL_DEBUG is not set -# CONFIG_OSI_TRACE_LEVEL_VERBOSE is not set -CONFIG_OSI_INITIAL_TRACE_LEVEL=2 -# CONFIG_BLUFI_TRACE_LEVEL_NONE is not set -# CONFIG_BLUFI_TRACE_LEVEL_ERROR is not set -CONFIG_BLUFI_TRACE_LEVEL_WARNING=y -# CONFIG_BLUFI_TRACE_LEVEL_API is not set -# CONFIG_BLUFI_TRACE_LEVEL_EVENT is not set -# CONFIG_BLUFI_TRACE_LEVEL_DEBUG is not set -# CONFIG_BLUFI_TRACE_LEVEL_VERBOSE is not set -CONFIG_BLUFI_INITIAL_TRACE_LEVEL=2 -# CONFIG_BLE_HOST_QUEUE_CONGESTION_CHECK is not set -CONFIG_SMP_ENABLE=y -# CONFIG_BLE_ACTIVE_SCAN_REPORT_ADV_SCAN_RSP_INDIVIDUALLY is not set -CONFIG_BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT=30 -CONFIG_ADC2_DISABLE_DAC=y -# CONFIG_EVENT_LOOP_PROFILING is not set -CONFIG_POST_EVENTS_FROM_ISR=y -CONFIG_POST_EVENTS_FROM_IRAM_ISR=y -CONFIG_ESP_SYSTEM_PD_FLASH=y -CONFIG_ESP32C3_LIGHTSLEEP_GPIO_RESET_WORKAROUND=y -CONFIG_IPC_TASK_STACK_SIZE=1536 -CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y -# CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set -CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 -CONFIG_ESP32_PHY_MAX_TX_POWER=20 -# CONFIG_ESP32_REDUCE_PHY_TX_POWER is not set -CONFIG_ESP_SYSTEM_PM_POWER_DOWN_CPU=y -# CONFIG_ESP32S2_PANIC_PRINT_HALT is not set -CONFIG_ESP32S2_PANIC_PRINT_REBOOT=y -# CONFIG_ESP32S2_PANIC_SILENT_REBOOT is not set -# CONFIG_ESP32S2_PANIC_GDBSTUB is not set -CONFIG_ESP32S2_ALLOW_RTC_FAST_MEM_AS_HEAP=y -CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 -CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=3072 -CONFIG_MAIN_TASK_STACK_SIZE=3584 -CONFIG_CONSOLE_UART_DEFAULT=y -# CONFIG_CONSOLE_UART_CUSTOM is not set -# CONFIG_ESP_CONSOLE_UART_NONE is not set -CONFIG_CONSOLE_UART=y -CONFIG_CONSOLE_UART_NUM=0 -CONFIG_CONSOLE_UART_BAUDRATE=115200 -CONFIG_INT_WDT=y -CONFIG_INT_WDT_TIMEOUT_MS=300 -CONFIG_INT_WDT_CHECK_CPU1=y -CONFIG_TASK_WDT=y -# CONFIG_TASK_WDT_PANIC is not set -CONFIG_TASK_WDT_TIMEOUT_S=5 -CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y -CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=y -# CONFIG_ESP32_DEBUG_STUBS_ENABLE is not set -CONFIG_TIMER_TASK_STACK_SIZE=3584 -CONFIG_SW_COEXIST_ENABLE=y -# CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set -# CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set -CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y -CONFIG_MB_MASTER_TIMEOUT_MS_RESPOND=150 -CONFIG_MB_MASTER_DELAY_MS_CONVERT=200 -CONFIG_MB_QUEUE_LENGTH=20 -CONFIG_MB_SERIAL_TASK_STACK_SIZE=4096 -CONFIG_MB_SERIAL_BUF_SIZE=256 -CONFIG_MB_SERIAL_TASK_PRIO=10 -CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT=y -CONFIG_MB_CONTROLLER_SLAVE_ID=0x00112233 -CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT=20 -CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 -CONFIG_MB_CONTROLLER_STACK_SIZE=4096 -CONFIG_MB_EVENT_QUEUE_TIMEOUT=20 -# CONFIG_MB_TIMER_PORT_ENABLED is not set -# CONFIG_ENABLE_STATIC_TASK_CLEAN_UP_HOOK is not set -CONFIG_TIMER_TASK_PRIORITY=1 -CONFIG_TIMER_TASK_STACK_DEPTH=2048 -CONFIG_TIMER_QUEUE_LENGTH=10 -# CONFIG_L2_TO_L3_COPY is not set -# CONFIG_USE_ONLY_LWIP_SELECT is not set -CONFIG_ESP_GRATUITOUS_ARP=y -CONFIG_GARP_TMR_INTERVAL=60 -CONFIG_TCPIP_RECVMBOX_SIZE=16 -CONFIG_TCP_MAXRTX=12 -CONFIG_TCP_SYNMAXRTX=12 -CONFIG_TCP_MSS=1440 -CONFIG_TCP_MSL=60000 -CONFIG_TCP_SND_BUF_DEFAULT=5744 -CONFIG_TCP_WND_DEFAULT=5744 -CONFIG_TCP_RECVMBOX_SIZE=6 -CONFIG_TCP_QUEUE_OOSEQ=y -# CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set -CONFIG_TCP_OVERSIZE_MSS=y -# CONFIG_TCP_OVERSIZE_QUARTER_MSS is not set -# CONFIG_TCP_OVERSIZE_DISABLE is not set -CONFIG_UDP_RECVMBOX_SIZE=6 -CONFIG_TCPIP_TASK_STACK_SIZE=3072 -CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y -# CONFIG_TCPIP_TASK_AFFINITY_CPU0 is not set -# CONFIG_TCPIP_TASK_AFFINITY_CPU1 is not set -CONFIG_TCPIP_TASK_AFFINITY=0x7FFFFFFF -# CONFIG_PPP_SUPPORT is not set -CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 -CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 -CONFIG_ESP32_PTHREAD_STACK_MIN=768 -CONFIG_ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY=y -# CONFIG_ESP32_DEFAULT_PTHREAD_CORE_0 is not set -# CONFIG_ESP32_DEFAULT_PTHREAD_CORE_1 is not set -CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT=-1 -CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread" -CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y -# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS is not set -# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED is not set -# CONFIG_USB_ENABLED is not set -CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y -CONFIG_SUPPORT_TERMIOS=y -CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS=1 -# End of deprecated options