[英]How to encode string to hex for sending downlink to iot devices?
According to this document根据这份文件
I need to send downlink of type 080100ff
to open the supply of the socket.我需要发送080100ff
类型的下行链路来打开套接字的供应。
However, I can not send 080100ff
since I got this error The payload field is not a valid hexadecimal payload in upper case.
但是,我无法发送080100ff
,因为我收到此错误The payload field is not a valid hexadecimal payload in upper case.
Here is my so far works in python这是我目前在 python 中的作品
'080100ff'.encode('utf-8').hex() -> 3038303130306666 '080100ff'.encode('utf-8').hex() -> 3038303130306666
I can send it now, but I think it is incorrectly hex encoded because the device is not turned on我现在可以发送了,但我认为它的十六进制编码不正确,因为设备未打开
In your example you are converting a hexadecimal string (080100ff) into hexadecimal value.在您的示例中,您将十六进制字符串 (080100ff) 转换为十六进制值。 You already have the hexadecimal value, it is: 080100ff您已经有了十六进制值,它是:080100ff
Would that work?那行得通吗?
bytes.fromhex('080100ff')
Could be maybe you need to try, 080100FF也许你需要试试, 080100FF
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.