123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #include "gateway_message.h"
- #include "string.h"
- #include <stdlib.h>
- static GATEWAY_PARAMS gateway_config_params = {0};
- GATEWAY_PARAMS *get_gateway_config_params()
- {
- return &gateway_config_params;
- }
- /**
- * @brief 向网关结构体内新增一个节点信息
- * @param cJSON *data_obj 网关结构体信息、const char* nodeId新增的节点ID
- * @retval 无
- */
- void addNode(GATEWAY_PARAMS* gateway, const char* nodeId) {
- // 增加节点数量
- NODE_PARAMS* newNode = (NODE_PARAMS*)malloc(sizeof(NODE_PARAMS));
- strcpy((char *)&newNode->node_address,nodeId);
- newNode->device_params = NULL; //先将其设备挂载为NULL
- newNode->nextNode = NULL; //下一个设备的挂载为NULL
- // 添加节点到网关链表中
- if (gateway->node_params == NULL) {
- gateway->node_params = newNode;
- }
- else
- {
- NODE_PARAMS* current = gateway->node_params;
- while (current->nextNode != NULL) {
- current = current->nextNode;
- }
- current->nextNode = newNode;
- }
- }
- /**
- * @brief 向节点下新增设备
- * @param NODE_PARAMS* node往那个节点中加入新的设备,const char* deviceName将设备地址当作其唯一标识
- * @retval 无
- */
- void addDevice(NODE_PARAMS* node,const uint8_t* deviceName)
- {
- // 创建新设备页
- DEVICE_PARAMS* newDevicePage = (DEVICE_PARAMS*)malloc(sizeof(DEVICE_PARAMS));
- newDevicePage->nextDevice = NULL;
- // 添加设备页到链表末尾
- if (node->device_params == NULL) {
- node->device_params = newDevicePage;
- } else {
- DEVICE_PARAMS* current = node->device_params;
- while (current->nextDevice != NULL) {
- current = current->nextDevice;
- }
- current->nextDevice = newDevicePage;
- }
- }
- void addParams()
- {
- }
|