开发者社区> 问答> 正文

华东节点2设备端SDKv2.0官方例程大端模式下订阅时接收的消息长度为0

官方例程, sample/mqtt-example.c
首先控制台订阅topic为data且属性为订阅和发布, 以实现自发自收的测试.


sub的消息到底时的代码如下
static void _demo_message_arrive(void *pcontext, void *pclient, iotx_mqtt_event_msg_pt msg)
{
    iotx_mqtt_topic_info_pt ptopic_info = (iotx_mqtt_topic_info_pt) msg->msg;

    // print topic name and topic message
    EXAMPLE_TRACE("----");
    EXAMPLE_TRACE("Topic(%d): '%.*s'", ptopic_info->topic_len, ptopic_info->topic_len, ptopic_info->ptopic);
    EXAMPLE_TRACE("Payload(%d): '%.*s'", ptopic_info->payload_len, ptopic_info->payload_len, ptopic_info->payload);
    EXAMPLE_TRACE("----");
}

  
小端模式下sub消息是OK的. [dbg] iotx_mc_cycle(1568): PUBACK
event_handle|160 :: publish success, packet-id=2
[dbg] iotx_mc_cycle(1585): PUBLISH
[dbg] iotx_mc_handle_recv_PUBLISH(1420): msg.id = | 8570 |
[dbg] iotx_mc_handle_recv_PUBLISH(1421): topicName = | /WTbJ0ETJacK/device_01/data |
[dbg] iotx_mc_handle_recv_PUBLISH(1431): delivering msg ...
[dbg] iotx_mc_deliver_message(1158): topic be matched
_demo_message_arrive|191 :: ----
_demo_message_arrive|192 :: Topic(27): '/WTbJ0ETJacK/device_01/data'
_demo_message_arrive|193 :: Payload(45): '{"attr_name":"temperature", "attr_value":"1"}'
_demo_message_arrive|194 :: ----
mqtt_client|312 :: packet-id=3, publish topic msg={"attr_name":"temperature", "attr_value":"1"}
[dbg] iotx_mc_cycle(1568): PUBACK
event_handle|160 :: publish success, packet-id=3
[dbg] iotx_mc_cycle(1585): PUBLISH
[dbg] iotx_mc_handle_recv_PUBLISH(1420): msg.id = | 8614 |
[dbg] iotx_mc_handle_recv_PUBLISH(1421): topicName = | /WTbJ0ETJacK/device_01/data |
[dbg] iotx_mc_handle_recv_PUBLISH(1431): delivering msg ...
[dbg] iotx_mc_deliver_message(1158): topic be matched
_demo_message_arrive|191 :: ----
_demo_message_arrive|192 :: Topic(27): '/WTbJ0ETJacK/device_01/data'
_demo_message_arrive|193 :: Payload(45): '{"attr_name":"temperature", "attr_value":"1"}'
_demo_message_arrive|194 :: ----


但是大端模式下执行结果如下, 消息长度为0?







展开
收起
qiushui_007 2017-09-25 15:43:08 2394 0
1 条回答
写回答
取消 提交回答
  • 大小端要转换一下吧,直接使用官方的例子是正常的吗?
    2017-10-08 12:33:17
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
基于RocketMQ Connect 构建全新数据流转处理平 立即下载
探索连接的最后十秒”落时”的网关 立即下载
低代码开发师(初级)实战教程 立即下载