iot - Mxchip IOT 开发套件从 IOT 集线器接收数据
问题描述
我刚开始玩mxchip。我希望我的设备在收到某些命令时触发警报。在我看来,我发现的所有示例都是设备收集信息并发送到物联网集线器。mxchip 可以从 iothub 或 azure 函数接收数据吗?也许还有一些入门指南?
解决方案
是的,假设您使用 MXChip 示例中的 SDK,您可以使用这些处理程序:
DevKitMQTTClient_SetMessageCallback(MessageCallback);
DevKitMQTTClient_SetDeviceMethodCallback(DeviceMethodCallback);
例子:
static void MessageCallback(const char *payLoad, int size)
{
Screen.print(1, payLoad, true);
}
static int DeviceMethodCallback(const char *methodName, const unsigned char *payload,
int size, unsigned char **response, int *response_size)
{
LogInfo("Try to invoke method %s", methodName);
// Do your logic...
int result = 200;
return result;
}
推荐阅读
- npm - 更新 package.json 和 package-lock.json 中的版本号而不更新依赖项
- mongodb - Mongodb 3.2(聚合):按同一属性的多个值分组
- java - Java:使用列标题创建临时文件的最快方法
- javascript - Firestore 从数组创建复合查询
- r - 你如何绘制 R 可格式化对象?
- phpmailer - HTML 在 PHPMailer 中显示为纯文本正文
- node.js - snapshot.val() 在有数据时返回 null
- mysql - 如何修复“参数必须是字符串”类型错误
- image - 通过expo图像选择器上传到firebase时文件图像大小增加使用XMLHttpRequest进行本机反应
- java - 无法使用 CSS、Class 或 XPath 定位器单击元素