Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf57a5ec

Browse files
committed
Merge branch 'feature/scenes' into 'master'
esp_rmaker_scenes: Add scenes support.See merge request app-frameworks/esp-rainmaker!245
2 parents5af4f64 +764db8d commitf57a5ec

File tree

16 files changed

+683
-5
lines changed

16 files changed

+683
-5
lines changed

‎components/esp_rainmaker/CMakeLists.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ set(core_srcs "src/core/esp_rmaker_core.c"
99
"src/core/esp_rmaker_system_service.c"
1010
"src/core/esp_rmaker_user_mapping.pb-c.c"
1111
"src/core/esp_rmaker_user_mapping.c"
12-
"src/core/esp_rmaker_schedule.c")
12+
"src/core/esp_rmaker_schedule.c"
13+
"src/core/esp_rmaker_scenes.c")
1314

1415
set(priv_req protobuf-c json_parser json_generator wifi_provisioning nvs_flash esp_http_client app_update esp-tls mbedtls esp_https_ota console esp_local_ctrl esp_https_server mdns esp_schedule)
1516

‎components/esp_rainmaker/Kconfig.projbuild‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,24 @@ menu "ESP RainMaker Config"
195195

196196
endmenu
197197

198+
menu "ESP RainMaker Scenes"
199+
200+
config ESP_RMAKER_SCENES_MAX_SCENES
201+
int "Maximum scenes"
202+
default 10
203+
range 1 50
204+
help
205+
Maximum Number of scenes allowed. The json size for report params increases as the number of scenes increases.
206+
207+
config ESP_RMAKER_SCENES_DEACTIVATE_SUPPORT
208+
bool "Enable Deactivate support"
209+
default n
210+
help
211+
This enables the deactivate callback support. The application callback will be invoked with the source
212+
set to ESP_RMAKER_REQ_SRC_SCENE_DEACTIVATE when the deactivate operation is received. However, the
213+
param values would be the same as those for activate, since the RainMaker core does not know what the
214+
expected values are for scene deactivation.
215+
216+
endmenu
217+
198218
endmenu

‎components/esp_rainmaker/include/esp_rmaker_core.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ typedef enum {
154154
ESP_RMAKER_REQ_SRC_CLOUD,
155155
/** Request received when a schedule has triggered */
156156
ESP_RMAKER_REQ_SRC_SCHEDULE,
157+
/** Request received when a scene has been activated */
158+
ESP_RMAKER_REQ_SRC_SCENE_ACTIVATE,
159+
/** Request received when a scene has been deactivated */
160+
ESP_RMAKER_REQ_SRC_SCENE_DEACTIVATE,
157161
/** Request received from a local controller */
158162
ESP_RMAKER_REQ_SRC_LOCAL,
159163
/** This will always be the last value. Any value equal to or
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2022 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#pragma once
16+
17+
#ifdef__cplusplus
18+
extern"C"
19+
{
20+
#endif
21+
22+
#include<esp_err.h>
23+
24+
/** Enable Scenes
25+
*
26+
* This API enables the scenes service for the node. For more information,
27+
* check [here](https://rainmaker.espressif.com/docs/scenes.html)
28+
*
29+
* @note This API should be called after esp_rmaker_node_init() but before esp_rmaker_start().
30+
*
31+
* @return ESP_OK on success.
32+
* @return error in case of failure.
33+
*/
34+
esp_err_tesp_rmaker_scenes_enable(void);
35+
36+
#ifdef__cplusplus
37+
}
38+
#endif

‎components/esp_rainmaker/include/esp_rmaker_standard_params.h‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ extern "C"
4545
#defineESP_RMAKER_DEF_TIMEZONE_NAME "TZ"
4646
#defineESP_RMAKER_DEF_TIMEZONE_POSIX_NAME "TZ-POSIX"
4747
#defineESP_RMAKER_DEF_SCHEDULE_NAME "Schedules"
48+
#defineESP_RMAKER_DEF_SCENES_NAME "Scenes"
4849
#defineESP_RMAKER_DEF_REBOOT_NAME "Reboot"
4950
#defineESP_RMAKER_DEF_FACTORY_RESET_NAME "Factory-Reset"
5051
#defineESP_RMAKER_DEF_WIFI_RESET_NAME "Wi-Fi-Reset"
@@ -265,6 +266,20 @@ esp_rmaker_param_t *esp_rmaker_timezone_posix_param_create(const char *param_nam
265266
*/
266267
esp_rmaker_param_t*esp_rmaker_schedules_param_create(constchar*param_name,intmax_schedules);
267268

269+
/**
270+
* Create standard Scenes param
271+
*
272+
* This will create the standard scenes parameter. Default value
273+
* is set internally.
274+
*
275+
* @param[in] param_name Name of the parameter
276+
* @param[in] max_scenes Maximum number of scenes allowed
277+
*
278+
* @return Parameter handle on success.
279+
* @return NULL in case of failures.
280+
*/
281+
esp_rmaker_param_t*esp_rmaker_scenes_param_create(constchar*param_name,intmax_scenes);
282+
268283
/**
269284
* Create standard Reboot param
270285
*

‎components/esp_rainmaker/include/esp_rmaker_standard_services.h‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,24 @@ esp_rmaker_device_t *esp_rmaker_time_service_create(const char *serv_name, const
7171
*/
7272
esp_rmaker_device_t*esp_rmaker_create_schedule_service(constchar*serv_name,esp_rmaker_device_write_cb_twrite_cb,esp_rmaker_device_read_cb_tread_cb,intmax_schedules,void*priv_data);
7373

74+
/** Create a standard Scenes service
75+
*
76+
* This creates a Scenes service with the mandatory parameters. The default parameter names will be used.
77+
* Refer \ref esp_rmaker_standard_params.h for default names.
78+
*
79+
* @param[in] serv_name The unique service name
80+
* @param[in] write_cb Write callback.
81+
* @param[in] read_cb Read callback.
82+
* @param[in] max_scenes Maximum number of scenes supported.
83+
* @param[in] deactivation_support Deactivation callback support.
84+
* @param[in] priv_data (Optional) Private data associated with the service. This should stay
85+
* allocated throughout the lifetime of the service.
86+
*
87+
* @return service_handle on success.
88+
* @return NULL in case of any error.
89+
*/
90+
esp_rmaker_device_t*esp_rmaker_create_scenes_service(constchar*serv_name,esp_rmaker_device_write_cb_twrite_cb,esp_rmaker_device_read_cb_tread_cb,intmax_scenes,booldeactivation_support,void*priv_data);
91+
7492
/** Create a standard System service
7593
*
7694
* This creates an empty System service. Appropriate parameters should be added by the caller.

‎components/esp_rainmaker/include/esp_rmaker_standard_types.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ extern "C"
4444
#defineESP_RMAKER_PARAM_TIMEZONE "esp.param.tz"
4545
#defineESP_RMAKER_PARAM_TIMEZONE_POSIX "esp.param.tz_posix"
4646
#defineESP_RMAKER_PARAM_SCHEDULES "esp.param.schedules"
47+
#defineESP_RMAKER_PARAM_SCENES "esp.param.scenes"
4748
#defineESP_RMAKER_PARAM_REBOOT "esp.param.reboot"
4849
#defineESP_RMAKER_PARAM_FACTORY_RESET "esp.param.factory-reset"
4950
#defineESP_RMAKER_PARAM_WIFI_RESET "esp.param.wifi-reset"
@@ -63,6 +64,7 @@ extern "C"
6364
#defineESP_RMAKER_SERVICE_OTA "esp.service.ota"
6465
#defineESP_RMAKER_SERVICE_TIME "esp.service.time"
6566
#defineESP_RMAKER_SERVICE_SCHEDULE "esp.service.schedule"
67+
#defineESP_RMAKER_SERVICE_SCENES "esp.service.scenes"
6668
#defineESP_RMAKER_SERVICE_SYSTEM "esp.service.system"
6769
#defineESP_RMAKER_SERVICE_LOCAL_CONTROL "esp.service.local_control"
6870

‎components/esp_rainmaker/src/core/esp_rmaker_device.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,6 @@ esp_err_t esp_rmaker_device_add_attribute(const esp_rmaker_device_t *device, con
170170
returnESP_ERR_INVALID_ARG;
171171
}
172172
_esp_rmaker_device_t*_device= (_esp_rmaker_device_t*)device;
173-
if (_device->is_service) {
174-
ESP_LOGE(TAG,"Cannot add attribute to a service");
175-
returnESP_ERR_INVALID_ARG;
176-
}
177173
esp_rmaker_attr_t*attr=_device->attributes;
178174
while(attr) {
179175
if (strcmp(attr_name,attr->name)==0) {

‎components/esp_rainmaker/src/core/esp_rmaker_param.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ static const char *cb_srcs[ESP_RMAKER_REQ_SRC_MAX] = {
5252
[ESP_RMAKER_REQ_SRC_INIT]="Init",
5353
[ESP_RMAKER_REQ_SRC_CLOUD]="Cloud",
5454
[ESP_RMAKER_REQ_SRC_SCHEDULE]="Schedule",
55+
[ESP_RMAKER_REQ_SRC_SCENE_ACTIVATE]="Scene Activate",
56+
[ESP_RMAKER_REQ_SRC_SCENE_DEACTIVATE]="Scene Deactivate",
5557
[ESP_RMAKER_REQ_SRC_LOCAL]="Local",
5658
};
5759

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp