使用 JSON 远程访问 Unet 调制解调器
Remote access to Unet modems using JSON
我正在尝试使用调制解调器中的 JsonTypeAdapter 从远程源传输一些数据。
通过调制解调器启动脚本 (JsonAdapter.enable()) 启用适配器,并建立 TCP 连接
到端口 1100 的调制解调器。我遵循 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]
192.168.1.8:1100
API 界面告诉我调制解调器正在监听哪个端口(端口 1100)。所以,我连接到它:
$ nc 192.168.1.8 1100
{"alive": true}
{"alive": true}
告诉我连接到正确的端口,调制解调器显示 "hello" :-)
现在,我复制并粘贴您的 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 发出 "buzz" 声音以通过声卡发送帧,以及两条消息(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}
我正在尝试使用调制解调器中的 JsonTypeAdapter 从远程源传输一些数据。 通过调制解调器启动脚本 (JsonAdapter.enable()) 启用适配器,并建立 TCP 连接 到端口 1100 的调制解调器。我遵循 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]
192.168.1.8:1100
API 界面告诉我调制解调器正在监听哪个端口(端口 1100)。所以,我连接到它:
$ nc 192.168.1.8 1100
{"alive": true}
{"alive": true}
告诉我连接到正确的端口,调制解调器显示 "hello" :-)
现在,我复制并粘贴您的 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 发出 "buzz" 声音以通过声卡发送帧,以及两条消息(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}