Files
esp-rainmaker/components/esp_rainmaker/include/esp_rmaker_standard_services.h
Piyush Shah 7e2ee79b20 esp_rmaker_groups: Add handling for group ids for direct MQTT messaging
This change allows adding a RainMaker service on which phone apps can
set id of the parent group (group_id) in which the node is added.

Once set, all local params will be reported on
node/<node_id>/params/local/<group_id> instead of node/<node_id>/params/local/

Additionally, application code can use the esp_rmaker_publish_direct()
API to publish any message on node/<node_id>/direct/params/local/<group_id>

Phone apps can subscribe to these topics to get these messages directly
from the MQTT broker

node/+/params/local/<group_id>
node/+/direct/params/local/<group_id>

For local params update, this change just helps to improve the latency
of param reporting.

The direct reporting allows to bypass the cloud side processing to send
messages directly to phone apps at very low cost

Phone apps can also publish param updates directly to node/<node_id>/params/remote/<group_id>
instead of using the set params API.
2025-12-22 17:00:42 +05:30

156 lines
6.5 KiB
C

// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <esp_err.h>
#include <esp_rmaker_core.h>
#ifdef __cplusplus
extern "C"
{
#endif
/** Create a standard OTA service
*
* This creates an OTA service with the mandatory parameters. The default parameter names will be used.
* Refer \ref esp_rmaker_standard_params.h for default names.
*
* @param[in] serv_name The unique service name
* @param[in] priv_data (Optional) Private data associated with the service. This should stay
* allocated throughout the lifetime of the service.
*
* @return service_handle on success.
* @return NULL in case of any error.
*/
esp_rmaker_device_t *esp_rmaker_ota_service_create(const char *serv_name, void *priv_data);
/** Create a standard Time service
*
* This creates a Time service with the mandatory parameters. The default parameter names will be used.
* Refer \ref esp_rmaker_standard_params.h for default names.
*
* @param[in] serv_name The unique service name
* @param[in] timezone Default value of timezone string (Eg. "Asia/Shanghai"). Can be kept NULL.
* @param[in] timezone_posix Default value of posix timezone string (Eg. "CST-8"). Can be kept NULL.
* @param[in] priv_data (Optional) Private data associated with the service. This should stay
* allocated throughout the lifetime of the service.
*
* @return service_handle on success.
* @return NULL in case of any error.
*/
esp_rmaker_device_t *esp_rmaker_time_service_create(const char *serv_name, const char *timezone,
const char *timezone_posix, void *priv_data);
/** Create a standard Schedule service
*
* This creates a Schedule service with the mandatory parameters. The default parameter names will be used.
* Refer \ref esp_rmaker_standard_params.h for default names.
*
* @param[in] serv_name The unique service name
* @param[in] write_cb Write callback.
* @param[in] read_cb Read callback.
* @param[in] max_schedules Maximum number of schedules supported.
* @param[in] priv_data (Optional) Private data associated with the service. This should stay
* allocated throughout the lifetime of the service.
*
* @return service_handle on success.
* @return NULL in case of any error.
*/
esp_rmaker_device_t *esp_rmaker_create_schedule_service(const char *serv_name, esp_rmaker_device_write_cb_t write_cb, esp_rmaker_device_read_cb_t read_cb, int max_schedules, void *priv_data);
/** Create a standard Scenes service
*
* This creates a Scenes service with the mandatory parameters. The default parameter names will be used.
* Refer \ref esp_rmaker_standard_params.h for default names.
*
* @param[in] serv_name The unique service name
* @param[in] write_cb Write callback.
* @param[in] read_cb Read callback.
* @param[in] max_scenes Maximum number of scenes supported.
* @param[in] deactivation_support Deactivation callback support.
* @param[in] priv_data (Optional) Private data associated with the service. This should stay
* allocated throughout the lifetime of the service.
*
* @return service_handle on success.
* @return NULL in case of any error.
*/
esp_rmaker_device_t *esp_rmaker_create_scenes_service(const char *serv_name, esp_rmaker_device_write_cb_t write_cb, esp_rmaker_device_read_cb_t read_cb, int max_scenes, bool deactivation_support, void *priv_data);
/** Create a standard System service
*
* This creates an empty System service. Appropriate parameters should be added by the caller.
*
* @param[in] serv_name The unique service name
* @param[in] priv_data (Optional) Private data associated with the service. This should stay
* allocated throughout the lifetime of the service.
*
* @return service_handle on success.
* @return NULL in case of any error.
*/
esp_rmaker_device_t *esp_rmaker_create_system_service(const char *serv_name, void *priv_data);
/** Create a standard Local Control service
*
* This creates a Local Control service with the mandatory parameters. The default parameter names will be used.
* Refer \ref esp_rmaker_standard_params.h for default names.
*
* @param[in] serv_name The unique service name
* @param[in] pop Proof of possession
* @param[in] sec_type Security type
* @param[in] priv_data (Optional) Private data associated with the service. This should stay
* allocated throughout the lifetime of the service.
*
* @return service_handle on success.
* @return NULL in case of any error.
*/
esp_rmaker_device_t *esp_rmaker_create_local_control_service(const char *serv_name, const char *pop, int sec_type, void *priv_data);
/** Create a standard User Auth service
*
* This creates a User Auth service with the mandatory parameters. The default parameter names will be used.
* Refer \ref esp_rmaker_standard_params.h for default names.
*
* @param[in] serv_name The unique service name
* @param[in] write_cb Write callback.
* @param[in] read_cb Read callback.
* @param[in] priv_data (Optional) Private data associated with the service. This should stay
* allocated throughout the lifetime of the service.
*
* @return service_handle on success.
* @return NULL in case of any error.
*/
esp_rmaker_device_t *esp_rmaker_create_user_auth_service(const char *serv_name, esp_rmaker_device_bulk_write_cb_t bulk_write_cb, esp_rmaker_device_bulk_read_cb_t read_cb, void *priv_data);
/** Create a standard Groups service
*
* This creates a Groups service with the mandatory parameters. The default parameter names will be used.
* Refer \ref esp_rmaker_standard_params.h for default names.
*
* @param[in] serv_name The unique service name
* @param[in] write_cb Bulk write callback.
* @param[in] priv_data (Optional) Private data associated with the service. This should stay
* allocated throughout the lifetime of the service.
*
* @return service_handle on success.
* @return NULL in case of any error.
*/
esp_rmaker_device_t *esp_rmaker_create_groups_service(const char *serv_name, esp_rmaker_device_bulk_write_cb_t write_cb, char *group_id, void *priv_data);
#ifdef __cplusplus
}
#endif