diff --git a/examples/node_infos.py b/examples/ble_t1000_infos.py similarity index 65% rename from examples/node_infos.py rename to examples/ble_t1000_infos.py index 1c494c6..132da32 100755 --- a/examples/node_infos.py +++ b/examples/ble_t1000_infos.py @@ -1,14 +1,14 @@ #!/usr/bin/python -from meshcore import TCPConnection -from meshcore import MeshCore import asyncio -HOSTNAME = "mchome" -PORT = 5000 +from meshcore import MeshCore +from meshcore import BLEConnection + +ADDRESS = "t1000" async def main () : - con = TCPConnection(HOSTNAME, PORT) + con = BLEConnection(ADDRESS) await con.connect() mc = MeshCore(con) await mc.connect() diff --git a/examples/mchome_msg.py b/examples/ble_t1000_msg.py similarity index 100% rename from examples/mchome_msg.py rename to examples/ble_t1000_msg.py index 3f9d99a..d3f751e 100755 --- a/examples/mchome_msg.py +++ b/examples/ble_t1000_msg.py @@ -2,8 +2,8 @@ import asyncio import json -from meshcore import TCPConnection from meshcore import MeshCore +from meshcore import TCPConnection HOSTNAME = "mchome" PORT = 5000 diff --git a/examples/mepo_mc_gps.py b/examples/mepo_mc_gps.py index c10636f..08d56ad 100755 --- a/examples/mepo_mc_gps.py +++ b/examples/mepo_mc_gps.py @@ -1,10 +1,11 @@ #!/usr/bin/python DISPLAYNAME="Center at MC node location" -from meshcore import BLEConnection -from meshcore import MeshCore import asyncio +from meshcore import MeshCore +from meshcore import BLEConnection + ADDRESS = "t1000" async def main () : diff --git a/examples/serial_infos.py b/examples/serial_infos.py new file mode 100755 index 0000000..cb41be5 --- /dev/null +++ b/examples/serial_infos.py @@ -0,0 +1,21 @@ +#!/usr/bin/python + +import asyncio + +from meshcore import MeshCore +from meshcore import SerialConnection + +PORT = "/dev/ttyUSB0" +BAUDRATE = 115200 + +async def main () : + con = SerialConnection(PORT, BAUDRATE) + await con.connect() + await asyncio.sleep(0.1) # time for transport to establish + + mc = MeshCore(con) + await mc.connect() + + print(mc.self_info) + +asyncio.run(main()) diff --git a/examples/serial_msg.py b/examples/serial_msg.py new file mode 100755 index 0000000..6a093ec --- /dev/null +++ b/examples/serial_msg.py @@ -0,0 +1,24 @@ +#!/usr/bin/python + +import asyncio +import json +from meshcore import MeshCore +from meshcore import SerialConnection + +PORT = "/dev/ttyUSB0" +BAUDRATE = 115200 +DEST = "mchome" +MSG = "hello from serial" + +async def main () : + con = SerialConnection(PORT, BAUDRATE) + await con.connect() + await asyncio.sleep(0.1) # time for transport to establish + + mc = MeshCore(con) + await mc.connect() + + await mc.ensure_contacts() + await mc.send_msg(bytes.fromhex(mc.contacts[DEST]["public_key"])[0:6],MSG) + +asyncio.run(main()) diff --git a/examples/mchome_contacts.py b/examples/tcp_mchome_contacts.py similarity index 100% rename from examples/mchome_contacts.py rename to examples/tcp_mchome_contacts.py diff --git a/examples/mchome_infos.py b/examples/tcp_mchome_infos.py similarity index 99% rename from examples/mchome_infos.py rename to examples/tcp_mchome_infos.py index 1c494c6..d1ec958 100755 --- a/examples/mchome_infos.py +++ b/examples/tcp_mchome_infos.py @@ -1,9 +1,10 @@ #!/usr/bin/python -from meshcore import TCPConnection -from meshcore import MeshCore import asyncio +from meshcore import MeshCore +from meshcore import TCPConnection + HOSTNAME = "mchome" PORT = 5000 diff --git a/examples/tcp_mchome_msg.py b/examples/tcp_mchome_msg.py new file mode 100755 index 0000000..b2a5dbd --- /dev/null +++ b/examples/tcp_mchome_msg.py @@ -0,0 +1,21 @@ +#!/usr/bin/python + +import asyncio +import json +from meshcore import MeshCore +from meshcore import BLEConnection + +ADDRESS = "t1000" # node ble adress or name +DEST = "mchome" +MSG = "Hello World" + +async def main () : + con = BLEConnection(ADDRESS) + await con.connect() + mc = MeshCore(con) + await mc.connect() + + await mc.ensure_contacts() + await mc.send_msg(bytes.fromhex(mc.contacts[DEST]["public_key"])[0:6],MSG) + +asyncio.run(main()) diff --git a/examples/mchome_readmsgs.py b/examples/tcp_mchome_readmsgs.py similarity index 100% rename from examples/mchome_readmsgs.py rename to examples/tcp_mchome_readmsgs.py