ch582与FS800

蓝牙芯片收到另外蓝牙芯片传来的信息(一个长度为4个数组),现在想通过FS800把这些数据发给阿里云,想通过串口把数据输出给FS800模块,但是代码有些问题。请问有相关参考吗?

 if(ctx->addr==0x0002)
        {
            // 自定义随机数据发送版本
            uint8_t *received_data = val->vendor_model_srv_Event.trans.pdata;
            int len = val->vendor_model_srv_Event.trans.len;

            if(len >= 4)  // 假设数据至少有4字节
            {
                // 解析数据
                char dataStr[200];
                int offset = sprintf(dataStr, "data={");
                for(int i = 0; i < len; i++) {
                    offset += sprintf(dataStr + offset, "%d", received_data[i]);
                    if(i < len - 1)
                        offset += sprintf(dataStr + offset, ",");
                }
                sprintf(dataStr + offset, "},src:0x%04x", ctx->addr);
                APP_DBG("%s\n", dataStr);

                float Temperature = received_data[0] * 1.0;  
                float Humidity = received_data[1] * 1.0;
                float co2 = received_data[2] * 1.0;
                float WindSpeed = received_data[3] * 1.0;

                // 发送带有CO2, 风速, 湿度, 温度的JSON数据
                Serial_Printf(USART2,
                    "{\"method\":\"thing.event.property.post\","
                    "\"id\":\"******\","
                    "\"params\":{"
                        "\"co2\":%.1f,"
                        "\"WindSpeed\":%.1f,"
                        "\"Humidity\":%.1f,"
                        "\"temperature\":%.1f"
                    "},"
                    "\"version\":\"1.0\"}",
                    co2, WindSpeed, Humidity, Temperature);


想问一下怎么通过串口把JSON格式的数据,通过串口发给FS800模块


只有登录才能回复,可以选择微信账号登录