unetstack - 使用 JSON 远程访问 Unet 调制解调器
问题描述
我正在尝试在调制解调器中使用 JsonTypeAdapter 从远程源传输一些数据。适配器通过调制解调器启动脚本 (JsonAdapter.enable()) 启用,并在端口 1100 处与调制解调器建立 TCP 连接。我按照 Fjåge 文档中的“Hello world”示例,将以下 JSON 发送到调制解调器:
{"action":"send","message":{"clazz":"org.arl.unet.DatagramReq","data":{"data":{"clazz":"[B","data":"aGVsbG8gd29ybGQh"},"msgID":"8152310b-155d-4303-9621-c610e036b373","perf":"REQUEST","recipient":"phy","sender":"MyCustomInterface"}}}
我已将 logLevel 设置为“ALL”,并且可以看到我在日志中获得了传入的 TCP 连接,但调制解调器没有传输任何数据。我订阅了物理代理,但在 WebShell 中没有收到任何通知(尽管使用 UnetSocket 可以正常工作)。
我猜测要么 JsonAdapter 在这个 TCP 连接上没有激活,要么 JSON 字符串有问题,要么我的应用程序没有正确发送,或者我错过了其他东西。
解决方案
我复制了任何粘贴的 JSON 消息,对我来说效果很好。我采取的步骤:
- 我使用
unet audio
SDOAM 进行了测试:
$ bin/unet -c audio
Modem web: http://localhost:8080/
> iface
tcp://192.168.1.8:1100 [API]
ws://192.168.1.8:8080/ws [API]
tcp:///192.168.1.8:1100//127.0.0.1.55832 [API]
unetsh: console://- [GroovyScriptEngine]
websh: ws://192.168.1.8:8080/fjage/shell/ws [GroovyScriptEngine]
API 接口告诉我调制解调器正在侦听哪个端口(192.168.1.8:1100
端口 1100)。所以,我连接到它:
$ nc 192.168.1.8 1100
{"alive": true}
{"alive": true}
告诉我我已连接到正确的端口,并且调制解调器正在说“你好” :-)
现在,我复制并粘贴您的 JSON 消息:
{"action":"send","message":{"clazz":"org.arl.unet.DatagramReq","data":{"data":{"clazz":"[B","data":"aGVsbG8gd29ybGQh"},"msgID":"8152310b-155d-4303-9621-c610e036b373","perf":"REQUEST","recipient":"phy","sender":"MyCustomInterface"}}}
我得到回复:
{"action":"send","message":{"clazz":"org.arl.fjage.Message","data":{"msgID":"41b8264c-be98-4bbe-8b72-8986606513ae","perf":"AGREE","recipient":"MyCustomInterface","sender":"phy","inReplyTo":"8152310b-155d-4303-9621-c610e036b373","sentAt":1586233766542}},"relay":false}
确认消息已收到,并正在转发到其他从属容器。紧随其后的是我的 SDOAM 发出的“嗡嗡”声以通过声卡发送帧,以及两个消息(TxFrameStartNtf
和TxFrameNtf
)确认传输已成功完成:
{"action":"send","message":{"clazz":"org.arl.unet.phy.TxFrameStartNtf","data":{"txTime":15784016,"txDuration":1511416,"type":2,"msgID":"0a5bae1e-b16c-4bbb-8fcf-36ad55ffc64e","perf":"INFORM","recipient":"#phy__ntf","sender":"phy","inReplyTo":"8152310b-155d-4303-9621-c610e036b373","sentAt":1586233767349}},"relay":false}
{"action":"send","message":{"clazz":"org.arl.unet.phy.TxFrameNtf","data":{"txTime":15759432,"type":2,"location":{"clazz":"[D","data":""},"msgID":"f6e1dee6-ed31-4850-9d90-7b591a740971","perf":"INFORM","recipient":"MyCustomInterface","sender":"phy","inReplyTo":"8152310b-155d-4303-9621-c610e036b373","sentAt":1586233768761}},"relay":false}
推荐阅读
- javascript - findAllAsync() android webview 的问题
- python - 在 Windows 10 中配置 Tor 以散列新密码时面临问题
- linux - ffmpeg 在以 root 身份运行的 crontab 中失败
- css - 我下载了一个网络字体,但它只能在括号中使用
- azure-cosmosdb - Azure Cosmos Db 文档分区键重复,但发现重复文档与其他列的组合
- arduino - Arduino键盘破解整个代码(闹钟)
- java - 错误:android.content.res.Resources$NotFoundException:字符串资源 ID #0x1
- node.js - 发布请求无法正常工作,有些数据正在传输,但有些数据没有
- python - 子矩阵上的 Python absdiff 性能
- javascript - Vue 将数据 URI 绑定到 img src 属性。仅当我的其他道具以某种方式发生变化时,浏览器中的图像才会更新