meshcore 0.3__tar.gz → 0.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meshcore
3
- Version: 0.3
3
+ Version: 0.3.3
4
4
  Summary: Base classes for communicating with meshcore companion radios
5
5
  Project-URL: Homepage, https://github.com/fdlamotte/meshcore_py
6
6
  Project-URL: Issues, https://github.com/fdlamotte/meshcore_py/issues
@@ -18,5 +18,7 @@ Description-Content-Type: text/markdown
18
18
 
19
19
  Bindings to access your [MeshCore](https://meshcore.co.uk) companion radio nodes in python.
20
20
 
21
- Used by [mccli](https//github.com/fdlamotte/mccli).
21
+ Can be installed via `pip` using `pip install meshcore`
22
+
23
+ Used by [mccli](https://github.com/fdlamotte/mccli).
22
24
 
@@ -2,5 +2,7 @@
2
2
 
3
3
  Bindings to access your [MeshCore](https://meshcore.co.uk) companion radio nodes in python.
4
4
 
5
- Used by [mccli](https//github.com/fdlamotte/mccli).
5
+ Can be installed via `pip` using `pip install meshcore`
6
+
7
+ Used by [mccli](https://github.com/fdlamotte/mccli).
6
8
 
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/python
2
+
3
+ import asyncio
4
+ import json
5
+ from meshcore import TCPConnection
6
+ from meshcore import MeshCore
7
+
8
+ HOSTNAME = "mchome"
9
+ PORT = 5000
10
+
11
+ async def main () :
12
+ con = TCPConnection(HOSTNAME, PORT)
13
+ await con.connect()
14
+ mc = MeshCore(con)
15
+ await mc.connect()
16
+
17
+ print(json.dumps(await mc.get_contacts(),indent=4))
18
+ asyncio.run(main())
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/python
2
+
3
+ from meshcore import TCPConnection
4
+ from meshcore import MeshCore
5
+ import asyncio
6
+
7
+ HOSTNAME = "mchome"
8
+ PORT = 5000
9
+
10
+ async def main () :
11
+ con = TCPConnection(HOSTNAME, PORT)
12
+ await con.connect()
13
+ mc = MeshCore(con)
14
+ await mc.connect()
15
+
16
+ print(mc.self_info)
17
+
18
+ asyncio.run(main())
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/python
2
+
3
+ import asyncio
4
+ import json
5
+ from meshcore import TCPConnection
6
+ from meshcore import MeshCore
7
+
8
+ HOSTNAME = "mchome"
9
+ PORT = 5000
10
+ DEST = "t1000"
11
+ MSG = "Hello World"
12
+
13
+ async def main () :
14
+ con = TCPConnection(HOSTNAME, PORT)
15
+ await con.connect()
16
+ mc = MeshCore(con)
17
+ await mc.connect()
18
+
19
+ await mc.ensure_contacts()
20
+ await mc.send_msg(bytes.fromhex(mc.contacts[DEST]["public_key"])[0:6],MSG)
21
+
22
+ asyncio.run(main())
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/python
2
+
3
+ import asyncio
4
+ import json
5
+ from meshcore import TCPConnection
6
+ from meshcore import MeshCore
7
+
8
+ HOSTNAME = "mchome"
9
+ PORT = 5000
10
+ DEST = "t1000"
11
+ MSG = "Hello World"
12
+
13
+ async def main () :
14
+ con = TCPConnection(HOSTNAME, PORT)
15
+ await con.connect()
16
+ mc = MeshCore(con)
17
+ await mc.connect()
18
+
19
+ res = True
20
+ while res:
21
+ res = await mc.get_msg()
22
+ if res :
23
+ print (res)
24
+
25
+ asyncio.run(main())
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/python
2
+ DISPLAYNAME="Center at MC node location"
3
+
4
+ from meshcore import BLEConnection
5
+ from meshcore import MeshCore
6
+ import asyncio
7
+
8
+ ADDRESS = "t1000"
9
+
10
+ async def main () :
11
+ con = BLEConnection(ADDRESS)
12
+ await con.connect()
13
+ mc = MeshCore(con)
14
+ await mc.connect()
15
+
16
+ infos = mc.self_info
17
+
18
+ lat=infos["adv_lat"]
19
+ lon=infos["adv_lon"]
20
+
21
+ print('[{"cmd":"prefset_n","args":{"pref":"lat","value":' + str(lat) + '}},')
22
+ print('{"cmd":"prefset_n","args":{"pref":"lon","value":' + str(lon) + '}}]')
23
+
24
+ asyncio.run(main())
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/python
2
+
3
+ from meshcore import TCPConnection
4
+ from meshcore import MeshCore
5
+ import asyncio
6
+
7
+ HOSTNAME = "mchome"
8
+ PORT = 5000
9
+
10
+ async def main () :
11
+ con = TCPConnection(HOSTNAME, PORT)
12
+ await con.connect()
13
+ mc = MeshCore(con)
14
+ await mc.connect()
15
+
16
+ print(mc.self_info)
17
+
18
+ asyncio.run(main())
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "meshcore"
7
- version = "0.3"
7
+ version = "0.3.3"
8
8
  authors = [
9
9
  { name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
10
10
  ]
@@ -364,7 +364,7 @@ class MeshCore:
364
364
  case 11: # contact
365
365
  self.result.set_result("meshcore://" + data[1:].hex())
366
366
  case 12: # battery voltage
367
- self.result.set_result(int.from_bytes(data[1:2], byteorder='little'))
367
+ self.result.set_result(int.from_bytes(data[1:3], byteorder='little'))
368
368
  case 13: # device info
369
369
  res = {}
370
370
  res["fw ver"] = data[1]
@@ -376,6 +376,10 @@ class MeshCore:
376
376
  res["model"] = data[20:60].decode().replace("\0","")
377
377
  res["ver"] = data[60:80].decode().replace("\0","")
378
378
  self.result.set_result(res)
379
+ case 50: # cli response
380
+ res = {}
381
+ res["response"] = data[1:].decode()
382
+ self.result.set_result(res)
379
383
  # push notifications
380
384
  case 0x80:
381
385
  printerr ("Advertisment received")
@@ -624,3 +628,7 @@ class MeshCore:
624
628
  except TimeoutError :
625
629
  printerr("Timeout waiting ack")
626
630
  return False
631
+
632
+ async def send_cli(self, cmd):
633
+ data = b"\x32" + cmd.encode('ascii')
634
+ return await self.send(data)
File without changes