ESP8266怎么把数据通过mqtt发送给云端
8266怎么获得串口数据以后通过mqtt主动上传给云端,我的代码是:
uart_test_rx()
{
if(,uart_buf==1)
{
bstyunReady=true;
//os_memcpy(Mqtt_Send_Buff, uart_buf, len);
memset(uart_buf,0,sizeof(uart_buf));
os_sprintf(uart_buf,"tahao\r\n",sizeof("nihao\r\n"));
tx_buff_enq(uart_buf,strlen("nihao\r\n"));
// MQTT_Publish(client, "/mqtt/topic/0", "LED status is off ...",
// strlen("LED status is off ..."), 0, 0);
}
void mqttPublishedCb(uint32_t *args)
{
uint8 uart_buf[128]={0};
MQTT_Client* client = (MQTT_Client*)args;
if(bstyunReady)
{
bstyunReady=false;
os_sprintf(uart_buf,"pphao\r\n",sizeof("pphao\r\n"));
tx_buff_enq(uart_buf,strlen("pphao\r\n"));
MQTT_Publish(client, "/mqtt/topic/1", "LED status is open ...",
strlen("LED status is open ..."), 0, 0);
}
INFO("MQTT: Published\r\n");
}
但为什么上传不到云端???