Skip to content

Commit a5aa8d3

Browse files
Tinyu-Zhaolbuque
authored andcommitted
lib/driver: RUI3 Driver p2p add convert str.
Signed-off-by: Tinyu-Zhao <[email protected]>
1 parent 32653ad commit a5aa8d3

File tree

6 files changed

+101
-10
lines changed

6 files changed

+101
-10
lines changed

docs/en/units/lorawan_rui3.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,12 +1062,13 @@ Methods
10621062

10631063
:returns: The result of the AT command execution.
10641064

1065-
.. method:: LoRaWAN_X.send_p2p_data(payload, timeout)
1065+
.. method:: LoRaWAN_X.send_p2p_data(payload, timeout, to_hex=False)
10661066

10671067
Sends P2P data with a given payload.
10681068

10691069
:param str payload: The payload to send, 2 to 500 characters in length, must be an even number of characters composed of 0-9, a-f, A-F, representing 1 to 256 hexadecimal values.
10701070
:param int timeout: The timeout for the data transmission, default is 1000 ms.
1071+
:param bool to_hex: A boolean indicating whether to convert the payload to hexadecimal format.
10711072

10721073
:returns: True if the data was sent successfully ("TXFSK DONE" or "TXP2P DONE"), False otherwise.
10731074

@@ -1091,11 +1092,12 @@ Methods
10911092

10921093
:returns: The response from the command execution.
10931094

1094-
.. method:: LoRaWAN_X.get_p2p_receive_data(timeout)
1095+
.. method:: LoRaWAN_X.get_p2p_receive_data(timeout=500, to_str=False)
10951096

10961097

10971098
:param int timeout: Timeout for listening to P2P LoRa data packets.
10981099
Valid values are 1~65535, with special cases for continuous listening and no timeout.
1100+
:param bool to_str: A boolean indicating whether to convert the payload to a string.
10991101

11001102
:returns: A tuple (RSSI, SNR, Payload) if data is received; False if no data is received.
11011103

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"V2.0","versionNumber":"V2.2.0","type":"cores3","components":[{"name":"screen","type":"screen","layer":0,"screenId":"builtin","screenName":"","id":"__cores3_screen","createTime":1736158258484,"x":0,"y":0,"width":320,"height":240,"backgroundColor":"#222222","size":0,"isSelected":true},{"name":"title0","type":"title","layer":1,"screenId":"builtin","screenName":"","id":"oB&L@4ES+hbSpu1S","createTime":1736234556476,"x":0,"y":0,"color":"#ffffff","backgroundColor":"#0000FF","text":"LoRaWAN P2P Send CoreS3 e.g.","textOffset":3,"font":"Widgets.FONTS.DejaVu18","isSelected":false},{"name":"label0","type":"label","layer":2,"screenId":"builtin","screenName":"","id":"a#V!8a2rGyub&CV%","createTime":1736234582481,"x":3,"y":115,"color":"#ffffff","backgroundColor":"#222222","text":"P2P Message Send State:","engine":"gfx","font":"Widgets.FONTS.DejaVu18","rotation":0,"isSelected":false}],"resources":[{"hardware":["hardware_button","hardware_pin_button","imu","speaker","touch","als","mic"]},{"unit":["unit_lorawancn470"]}],"units":[{"type":"unit_lorawancn470","name":"lorawancn470_0","portList":["A","B","C","Custom"],"portType":"A","userPort":[22,21],"id":"msXW5HBMEydy=`2h","createTime":1736240258072,"initBlockId":":{Fa0Fg^}P-D1B6w#r?@"}],"hats":[],"bases":[],"i2cs":[],"blockly":"<block type=\"basic_on_setup\" id=\"setup_block\" deletable=\"false\" x=\"70\" y=\"-310\"><mutation isBegin=\"true\"></mutation><field name=\"UPDATEOP\">true</field><statement name=\"FUNC\"><block type=\"system_m5_begin\" id=\"system_m5_begin\"><next><block type=\"unit_lorawancn470_init\" id=\":{Fa0Fg^}P-D1B6w#r?@\"><field name=\"NAME\">lorawancn470_0</field><value name=\"UART\"><shadow type=\"unit_lorawancn470_id_option\" id=\"W/[M*=gapb1K(_/^mr~w\"><field name=\"VALUE\">2</field></shadow></value><next><block type=\"unit_lorawancn470_set_network_mode\" id=\"cRvIs6_5/}lpW,!]x+J*\"><field name=\"NAME\">lorawancn470_0</field><field name=\"MODE\">0</field><next><block type=\"unit_lorawancn470_set_p2p_frequency\" id=\"*#~NPL*G(]^lgY3QiWW3\"><field name=\"NAME\">lorawancn470_0</field><value name=\"VALUE\"><shadow type=\"math_slider\" id=\"4NUytsUXtO}VtGT)O)w?\"><mutation max=\"600000000\" min=\"150000000\" step=\"100000\" precision=\"1\"></mutation><field name=\"NUM\">470000000</field></shadow></value><next><block type=\"unit_lorawancn470_set_p2p_spreading_factor\" id=\"d5,poPAQlWrfJe%D[19T\"><field name=\"NAME\">lorawancn470_0</field><value name=\"VALUE\"><shadow type=\"math_slider\" id=\"u|~4J#K}uX6URyYQiY*z\"><mutation max=\"12\" min=\"5\" step=\"1\" precision=\"1\"></mutation><field name=\"NUM\">7</field></shadow></value><next><block type=\"unit_lorawancn470_set_p2p_lora_bandwidth\" id=\"i#nZ}JDdGz/crL|1(/#?\"><field name=\"NAME\">lorawancn470_0</field><value name=\"VALUE\"><shadow type=\"unit_lorawancn470_bandwidth_option\" id=\"zv@xsWt.=t;_fm#eXNJ{\"><field name=\"VALUE\">0</field></shadow></value><next><block type=\"unit_lorawancn470_set_p2p_tx_power\" id=\"A*x{=`Y)_WJj:4NE*5p+\"><field name=\"NAME\">lorawancn470_0</field><value name=\"VALUE\"><shadow type=\"math_slider\" id=\":@Gb0IDfZU%~Xz0-RcDg\"><mutation max=\"22\" min=\"5\" step=\"1\" precision=\"1\"></mutation><field name=\"NUM\">14</field></shadow></value><next><block type=\"unit_lorawancn470_set_p2p_code_rate\" id=\"UF00$Bt~%i~hU]V=cV%z\"><field name=\"NAME\">lorawancn470_0</field><field name=\"MODE\">0</field><next><block type=\"unit_lorawancn470_set_p2p_preamble_length\" id=\"LsctAZ/#JU3DX4n(#GhW\"><field name=\"NAME\">lorawancn470_0</field><value name=\"VALUE\"><shadow type=\"math_slider\" id=\",@?/|K$zu|?8l.n7SCqv\"><mutation max=\"65535\" min=\"5\" step=\"1\" precision=\"1\"></mutation><field name=\"NUM\">8</field></shadow></value><next><block type=\"unit_lorawancn470_set_p2p_sync_word\" id=\"uXiH@+K4T#_6atLB[.uT\"><field name=\"NAME\">lorawancn470_0</field><value name=\"VALUE\"><shadow type=\"math_number\" id=\"21!8d#)Jf0V^Z*Um@c0a\"><mutation max=\"Infinity\" min=\"-Infinity\" precision=\"0\"></mutation><field name=\"NUM\">0xffff</field></shadow></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block><block type=\"unit_lorawancn470_send_p2p_data\" id=\"f;Jk4b|shGGC@{^:e,C9\" disabled=\"true\" x=\"0\" y=\"0\"><field name=\"NAME\">lorawancn470_0</field><value name=\"VALUE\"><shadow type=\"text\" id=\"4$A(*A/W_Q^lF+BoO_LU\" disabled=\"true\"><field name=\"TEXT\">1122</field></shadow></value></block><block type=\"basic_on_loop\" id=\"loop_block\" deletable=\"false\" x=\"70\" y=\"130\"><mutation isUpdate=\"true\"></mutation><field name=\"UPDATEOP\">true</field><statement name=\"FUNC\"><block type=\"system_m5_update\" id=\"system_m5_update\"><next><block type=\"label_set_text\" id=\"qmdG|V|X-?siZZQNf[x+\"><field name=\"NAME\">label0</field><value name=\"TEXT\"><shadow type=\"text\" id=\"q=yi0r#T#:%).7(Fw+*p\"><field name=\"TEXT\">Label</field></shadow><block type=\"text_add_str\" id=\"DtY%bgh4622m1FeBV^9P\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"/Fv-?7[VC[|RFHp-,3W.\"><field name=\"TEXT\">P2P Message Send State:</field></shadow></value></block></value><next><block type=\"time_sleep_second\" id=\"{D=f00!WZv]rWo60U3!c\"><value name=\"SECOND\"><shadow type=\"math_number\" id=\"ppolr%2ulm7^|Q0Y?}oe\"><mutation max=\"Infinity\" min=\"0\" precision=\"0\"></mutation><field name=\"NUM\">3.5</field></shadow></value></block></next></block></next></block></statement></block>","screen":[{"simulationName":"Built-in","type":"builtin","width":320,"height":240,"scale":0.78,"screenName":"","blockId":"","screenColorType":0,"id":"builtin","createTime":1736158258481}],"logicWhenNum":0,"customList":[]}
1+
{"version":"V2.0","versionNumber":"V2.2.1","type":"cores3","components":[{"name":"screen","type":"screen","layer":0,"screenId":"builtin","screenName":"","id":"__cores3_screen","createTime":1736158258484,"x":0,"y":0,"width":320,"height":240,"backgroundColor":"#222222","size":0,"isSelected":true},{"name":"title0","type":"title","layer":1,"screenId":"builtin","screenName":"","id":"oB&L@4ES+hbSpu1S","createTime":1736234556476,"x":0,"y":0,"color":"#ffffff","backgroundColor":"#0000FF","text":"LoRaWAN P2P Send CoreS3 e.g.","textOffset":3,"font":"Widgets.FONTS.DejaVu18","isSelected":false},{"name":"label0","type":"label","layer":2,"screenId":"builtin","screenName":"","id":"a#V!8a2rGyub&CV%","createTime":1736234582481,"x":3,"y":115,"color":"#ffffff","backgroundColor":"#222222","text":"P2P Message Send State:","engine":"gfx","font":"Widgets.FONTS.DejaVu18","rotation":0,"isSelected":false}],"resources":[{"hardware":["hardware_button","hardware_pin_button","imu","speaker","touch","als","mic"]},{"unit":["unit_lorawancn470"]}],"units":[{"type":"unit_lorawancn470","name":"lorawancn470_0","portList":["A","B","C","Custom"],"portType":"A","userPort":[22,21],"id":"msXW5HBMEydy=`2h","createTime":1737174696827,"initBlockId":":{Fa0Fg^}P-D1B6w#r?@"}],"hats":[],"bases":[],"i2cs":[],"blockly":"<block type=\"basic_on_setup\" id=\"setup_block\" deletable=\"false\" x=\"70\" y=\"-310\"><mutation isBegin=\"true\"></mutation><field name=\"UPDATEOP\">true</field><statement name=\"FUNC\"><block type=\"system_m5_begin\" id=\"system_m5_begin\"><next><block type=\"unit_lorawancn470_init\" id=\":{Fa0Fg^}P-D1B6w#r?@\"><field name=\"NAME\">lorawancn470_0</field><value name=\"UART\"><shadow type=\"unit_lorawancn470_id_option\" id=\"W/[M*=gapb1K(_/^mr~w\"><field name=\"VALUE\">2</field></shadow></value><next><block type=\"unit_lorawancn470_set_network_mode\" id=\"cRvIs6_5/}lpW,!]x+J*\"><field name=\"NAME\">lorawancn470_0</field><field name=\"MODE\">0</field><next><block type=\"unit_lorawancn470_set_p2p_frequency\" id=\"*#~NPL*G(]^lgY3QiWW3\"><field name=\"NAME\">lorawancn470_0</field><value name=\"VALUE\"><shadow type=\"math_slider\" id=\"4NUytsUXtO}VtGT)O)w?\"><mutation max=\"600000000\" min=\"150000000\" step=\"100000\" precision=\"1\"></mutation><field name=\"NUM\">470000000</field></shadow></value><next><block type=\"unit_lorawancn470_set_p2p_spreading_factor\" id=\"d5,poPAQlWrfJe%D[19T\"><field name=\"NAME\">lorawancn470_0</field><value name=\"VALUE\"><shadow type=\"math_slider\" id=\"u|~4J#K}uX6URyYQiY*z\"><mutation max=\"12\" min=\"5\" step=\"1\" precision=\"1\"></mutation><field name=\"NUM\">7</field></shadow></value><next><block type=\"unit_lorawancn470_set_p2p_lora_bandwidth\" id=\"i#nZ}JDdGz/crL|1(/#?\"><field name=\"NAME\">lorawancn470_0</field><value name=\"VALUE\"><shadow type=\"unit_lorawancn470_bandwidth_option\" id=\"zv@xsWt.=t;_fm#eXNJ{\"><field name=\"VALUE\">0</field></shadow></value><next><block type=\"unit_lorawancn470_set_p2p_tx_power\" id=\"A*x{=`Y)_WJj:4NE*5p+\"><field name=\"NAME\">lorawancn470_0</field><value name=\"VALUE\"><shadow type=\"math_slider\" id=\":@Gb0IDfZU%~Xz0-RcDg\"><mutation max=\"22\" min=\"5\" step=\"1\" precision=\"1\"></mutation><field name=\"NUM\">14</field></shadow></value><next><block type=\"unit_lorawancn470_set_p2p_code_rate\" id=\"UF00$Bt~%i~hU]V=cV%z\"><field name=\"NAME\">lorawancn470_0</field><field name=\"MODE\">0</field><next><block type=\"unit_lorawancn470_set_p2p_preamble_length\" id=\"LsctAZ/#JU3DX4n(#GhW\"><field name=\"NAME\">lorawancn470_0</field><value name=\"VALUE\"><shadow type=\"math_slider\" id=\",@?/|K$zu|?8l.n7SCqv\"><mutation max=\"65535\" min=\"5\" step=\"1\" precision=\"1\"></mutation><field name=\"NUM\">8</field></shadow></value><next><block type=\"unit_lorawancn470_set_p2p_sync_word\" id=\"uXiH@+K4T#_6atLB[.uT\"><field name=\"NAME\">lorawancn470_0</field><value name=\"VALUE\"><shadow type=\"math_number\" id=\"21!8d#)Jf0V^Z*Um@c0a\"><mutation max=\"Infinity\" min=\"-Infinity\" precision=\"0\"></mutation><field name=\"NUM\">0xffff</field></shadow></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block><block type=\"unit_lorawancn470_send_p2p_data\" id=\"f;Jk4b|shGGC@{^:e,C9\" disabled=\"true\" x=\"0\" y=\"0\"><field name=\"NAME\">lorawancn470_0</field><value name=\"VALUE\"><shadow type=\"text\" id=\"4$A(*A/W_Q^lF+BoO_LU\" disabled=\"true\"><field name=\"TEXT\">1122</field></shadow></value></block><block type=\"basic_on_loop\" id=\"loop_block\" deletable=\"false\" x=\"70\" y=\"130\"><mutation isUpdate=\"true\"></mutation><field name=\"UPDATEOP\">true</field><statement name=\"FUNC\"><block type=\"system_m5_update\" id=\"system_m5_update\"><next><block type=\"label_set_text\" id=\"qmdG|V|X-?siZZQNf[x+\"><field name=\"NAME\">label0</field><value name=\"TEXT\"><shadow type=\"text\" id=\"q=yi0r#T#:%).7(Fw+*p\"><field name=\"TEXT\">Label</field></shadow><block type=\"text_add_str\" id=\"DtY%bgh4622m1FeBV^9P\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"/Fv-?7[VC[|RFHp-,3W.\"><field name=\"TEXT\">P2P Message Send State:</field></shadow></value><value name=\"VALUE2\"><block type=\"unit_lorawancn470_send_p2p_data_return\" id=\"XWz5kGXPKafh,Bg=:ip3\"><field name=\"NAME\">lorawancn470_0</field><value name=\"VALUE\"><shadow type=\"text\" id=\"Zg$Ey89FplMcP2GdFJy`\"><field name=\"TEXT\">M5</field></shadow></value><value name=\"TIMEOUT\"><shadow type=\"math_number\" id=\"*AM;dpdM-8wEf:L!11B3\"><mutation max=\"Infinity\" min=\"-Infinity\" precision=\"0\"></mutation><field name=\"NUM\">1000</field></shadow></value><value name=\"BOOL\"><shadow type=\"unit_lorawancn470_bool_option\" id=\"1-n)Y5rVlxVok=.|mWlM\"><field name=\"VALUE\">True</field></shadow></value></block></value></block></value><next><block type=\"time_sleep_second\" id=\"{D=f00!WZv]rWo60U3!c\"><value name=\"SECOND\"><shadow type=\"math_number\" id=\"ppolr%2ulm7^|Q0Y?}oe\"><mutation max=\"Infinity\" min=\"0\" precision=\"0\"></mutation><field name=\"NUM\">3.5</field></shadow></value></block></next></block></next></block></statement></block>","screen":[{"simulationName":"Built-in","type":"builtin","width":320,"height":240,"scale":0.78,"screenName":"","blockId":"","screenColorType":0,"id":"builtin","createTime":1736158258481}],"logicWhenNum":0,"customList":[]}

examples/unit/lorawan_rui3/lorawan_p2p_cores3_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def loop():
4444
str(
4545
(
4646
str("P2P Message Send State:")
47-
+ str((lorawancn470_0.send_p2p_data("1122", timeout=3000)))
47+
+ str((lorawancn470_0.send_p2p_data("M5", timeout=1000, to_hex=True)))
4848
)
4949
)
5050
)

0 commit comments

Comments
 (0)