- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
嗨,我尝试将 cooja simluator 中的 mqtt mote 连接到桌面上的 mosquitto 服务器。但它一直无法连接,我能够 ping rpl 路由器,但不能 ping 我的 mqtt 客户端节点。我正在使用 https://github.com/esar/contiki-mqtt 中的示例.
有人可以告诉我我所犯的错误吗?谢谢
这是我使用的代码
#include "stdio.h"
#include "contiki.h"
#include "contiki-net.h"
#include "mqtt-service.h"
PROCESS(mqtt_publisher_process, "MQTT Publisher");
PROCESS_NAME(mqtt_process);
AUTOSTART_PROCESSES(&mqtt_process, &mqtt_publisher_process);
PROCESS_THREAD(mqtt_publisher_process, ev, data)
{
static uip_ip6addr_t server_address;
// printf("address %d\n",server_address);
// Allocate buffer space for the MQTT client
static uint8_t in_buffer[64];
static uint8_t out_buffer[64];
// Setup an mqtt_connect_info_t structure to describe
// how the connection should behave
static mqtt_connect_info_t connect_info =
{
.client_id = "contiki",
.username = "user",
.password = "user",
.will_topic = "dev/text",
.will_message = NULL,
.keepalive = 60,
.will_qos = 0,
.will_retain = 0,
.clean_session = 1
};
// The list of topics that we want to subscribe to
static const char* topics[] =
{
"0", "1", "2", "3", "4", "5", NULL
};
PROCESS_BEGIN();
// Set the server address
uip_ip6addr(&server_address,0,0,0,0,0,0,0,1);
// Initialise the MQTT client
mqtt_init(in_buffer, sizeof(in_buffer),
out_buffer, sizeof(out_buffer));
// Ask the client to connect to the server
// and wait for it to complete.
mqtt_connect(&server_address, UIP_HTONS(33065),1, &connect_info);
// mqtt_connect(&server_address, 1883,1, &connect_info);
PROCESS_WAIT_EVENT_UNTIL(ev == mqtt_event);
if(mqtt_connected())
{
static int i;
for(i = 0; topics[i] != NULL; ++i)
{
// Ask the client to subscribe to the topic
// and wait for it to complete
mqtt_subscribe(topics[i]);
PROCESS_WAIT_EVENT_UNTIL(ev == mqtt_event);
}
// Loop waiting for events from the MQTT client
while(1)
{
PROCESS_WAIT_EVENT_UNTIL(ev == mqtt_event);
// If we've received a publish event then print
// out the topic and message
if(mqtt_event_is_publish(data))
{
const char* topic = mqtt_event_get_topic(data);
const char* message = mqtt_event_get_data(data);
int level = 0;
printf("%s = %s\n", topic, message);
// Relay the received message to a new topic
mqtt_publish("new_topic", message, 0, 1);
}else{
}
}
} else
printf("mqtt service connect failed\n");
PROCESS_END();
}
最佳答案
我怀疑您所说的在桌面上运行的 MQTT 服务器是否具有 IPv6 地址::1,对吗?
而不是:
uip_ip6addr(&server_address,0,0,0,0,0,0,0,1);
您可能想输入运行 Mosquitto 的台式计算机的地址?
关于Contiki os MQTT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41628649/
我想知道如果我只连接到 MQTT 服务器(不发送或接收任何消息),一个月内(大约)会消耗多少数据。 我需要计算它来衡量我应该为物联网应用程序中使用的 sim 卡充值什么数据计划。 谢谢 最佳答案 编辑
对于单个消息,在 mqtt 中向主题(代理或接收器)发送(发布)数据是否有任何限制? 提前致谢.. 最佳答案 IBM 写了一个 article关于 MQTT。 A payload up to 256
我一直在阅读有关 MQTT 的资料,我知道它使用 TCP 进行网络传输。因此,如果我有一个将发送订阅请求的移动应用程序,我假设这将是一个全双工连接,以便客户端可以收到传入推送数据的通知。 那么如何提高
最近看了一篇物联网文章 http://www.eclipse.org/community/eclipse_newsletter/2014/february/article2.php 在这里他说,通过
我有一个项目涉及与众多客户进行后端通信。我正在寻找要使用的最佳协议(protocol)。 MQTT 适合我的项目吗? 最佳答案 Mqtt 最适合涉及大量用户的项目。目标是提供一个围绕发布/订阅模型优化
是否允许在 MQTT 主题中使用多个 #? 例如: sensors/data/#/something/else/# 最佳答案 没有 MQTT 规范(v3 和 v5)规定主题只能在主题中使用一次“#”,
如果 MQTT 已经是一个轻量级协议(protocol),而且它使用的功率和带宽很少,那么为什么我们有 MQTT-SN?什么时候适合使用 MQTT,什么时候适合使用 MQTT-SN? 最佳答案 与 M
我正在使用 Paho 和 Mosqitto 进行 MQTT 通信。我们必须支持两种序列化模型——xml 和 json。所以我正在寻找如何识别 MQTT 中的内容类型或有效负载类型。 MQTT 中是否有
我想知道消息发送顺序是否被保留。也就是说,当发布者发送消息序列时,是否保证每个订阅者收到与发布者发送的序列相同的序列?对于干净和持久的 session ? 最佳答案 MQTT 3.1.1 中消息排序功
我正在使用 Paho 和 Mosqitto 进行 MQTT 通信。我们必须支持两种序列化模型——xml 和 json。所以我正在寻找如何识别 MQTT 中的内容类型或有效负载类型。 MQTT 中是否有
我已经在我的本地机器上安装了 MQTT 的 mosquitto 客户端。 我有以下配置: listener 1883 protocol mqtt listener 9001 protocol webs
MQTT 客户端每分钟轮询服务器多少次?是不是大数据流量?我知道数据包的大小可以很小,但是客户端 ping 代理多少次才能使自己在代理中“在线”。 如果我不清楚,请评论这个问题,我会尝试更好地解释我的
我们在不同的场所安装了许多本地网关。这些网关将托管一个 MQTT 代理,用于连接所有本地服务。然后需要本地 MQTT 代理将此数据发送到两个远程 MQTT 代理(每个托管于不同的一方)。我已阅读有关
无论我做什么,我都无法在我的 angular 应用程序中通过 websocket 连接到 mqtt 代理(在 chrome 和 firefox 中尝试)。 为简单起见,我使用 HiveMQ broke
我有一个 MQTT 客户端想要订阅以下主题 node1/数据/更新 节点1/数据/增量 节点1/数据 当然我有多个节点,所以我必须使用通配符,如下所述:https://www.hivemq.com/b
我正在使用 mosquitto (http://mosquitto.org/) 作为 MQTT 代理,并正在寻找有关负载平衡订阅者的建议(针对同一主题)。这是如何实现的?我读到的关于协议(protoc
如题,我可以区分新的和保留的MQTT消息吗?以及如何知道客户端何时发布消息?所有这些没有在主题或消息中指定时间戳字符串。 最佳答案 客户端使用保留标志向代理指示代理应将消息保留为要发布到的主题的“最后
有什么方法可以从另一个客户端找到所有连接的客户端详细信息(IP 和名称)?我知道有一个主题“$SYS/broker/clients/active”给出了当前连接的客户端的数量,但是如果我想了解更多关于
当处于 QOS 1 和 2 时,它会重播所有过去的消息。标准实现中是否有一种方法可以在再次生效时接收整个过去的队列(作为数组)? (当然仅限订阅的) 最佳答案 当客户端以 QOS 1 或 2 订阅主题
我想连接一个客户端,该客户端将监视代理的所有主题,以便在我不知道主题名称是什么时响应事件。 最佳答案 订阅 # 可以让您订阅除以 $ 开头的主题之外的所有内容(无论如何,这些主题通常都是控制主题)。
我是一名优秀的程序员,十分优秀!