阿里云的组件包例子mqtt_example_main主函数里有句: IOT_MQTT_Yield(pclient, 200);
这应该是接收mqtt消息的 我下发的是{led:1}
,
那应该在例程哪个地方判断呢?????让PB1拉高
是不是应该有个接受消息的回调函数 在回调函数里进行逻辑判断
希望大佬贴出在例程里改的代码指教 真的头疼死了
在线等 感谢
static void example_message_arrive(void *pcontext, void *pclient, iotx_mqtt_event_msg_pt msg)
{
iotx_mqtt_topic_info_t *topic_info = (iotx_mqtt_topic_info_pt) msg->msg;
static rt_base_t led_state = PIN_LOW;
switch (msg->event_type) {
case IOTX_MQTT_EVENT_PUBLISH_RECEIVED:
/* print topic name and topic message */
EXAMPLE_TRACE("Message Arrived:");
EXAMPLE_TRACE("Topic : %.*s", topic_info->topic_len, topic_info->ptopic);
EXAMPLE_TRACE("Payload: %.*s", topic_info->payload_len, topic_info->payload);
EXAMPLE_TRACE("\n");
rt_int32_t rec=rt_strcmp(topic_info->payload,"led");
if(rec==0){
// 反转当前的 LED 状态
if (led_state == PIN_LOW) {
led_state = PIN_HIGH;
} else {
led_state = PIN_LOW;
}
rt_pin_write(GPIO_LED_R, led_state);
}
break;
default:
break;
}
}
大佬 那在腾讯云的组件包里应该在哪个地方判断呢