/* * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED. * 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. */ #include #include #include #include #include "ohos_init.h" #include "cmsis_os2.h" #include "iot_config.h" #include "iot_log.h" #include "iot_main.h" #include "iot_profile.h" /* attribute initiative to report */ #define TAKE_THE_INITIATIVE_TO_REPORT /* oc request id */ #define CN_COMMAND_INDEX "commands/request_id=" // this is the callback function, set to the mqtt, and if any messages come, it will be called // The payload here is the json string static void DemoMsgRcvCallBack(int qos, const char *topic, const char *payload) { const char *requesID; char *tmp; IoTCmdRespT resp; IOT_LOG_DEBUG("RCVMSG:QOS:%d TOPIC:%s PAYLOAD:%s\r\n", qos, topic, payload); tmp = strstr(topic, CN_COMMAND_INDEX); if (tmp != NULL) { //