mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
set custom vars
This commit is contained in:
parent
27f87075d2
commit
ec5077110d
3 changed files with 38 additions and 1 deletions
17
examples/ble_t1000_custom_vars.py
Executable file
17
examples/ble_t1000_custom_vars.py
Executable file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
from meshcore import MeshCore
|
||||||
|
from meshcore import BLEConnection
|
||||||
|
|
||||||
|
ADDRESS = "T1000_S" # node ble adress or name
|
||||||
|
|
||||||
|
async def main () :
|
||||||
|
con = BLEConnection(ADDRESS)
|
||||||
|
await con.connect()
|
||||||
|
mc = MeshCore(con)
|
||||||
|
await mc.connect()
|
||||||
|
|
||||||
|
print(await mc.commands.get_custom_vars())
|
||||||
|
|
||||||
|
asyncio.run(main())
|
||||||
20
examples/ble_t1000_set_cv.py
Executable file
20
examples/ble_t1000_set_cv.py
Executable file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
from meshcore import MeshCore
|
||||||
|
from meshcore import BLEConnection
|
||||||
|
|
||||||
|
ADDRESS = "T1000_S" # node ble adress or name
|
||||||
|
VAR = "gps"
|
||||||
|
VALUE = "1"
|
||||||
|
|
||||||
|
async def main () :
|
||||||
|
con = BLEConnection(ADDRESS)
|
||||||
|
await con.connect()
|
||||||
|
mc = MeshCore(con, debug=True)
|
||||||
|
await mc.connect()
|
||||||
|
|
||||||
|
print(await mc.commands.set_custom_var(VAR, VALUE))
|
||||||
|
|
||||||
|
|
||||||
|
asyncio.run(main())
|
||||||
|
|
@ -320,7 +320,7 @@ class CommandHandler:
|
||||||
|
|
||||||
async def set_custom_var(self, key, value) -> Event:
|
async def set_custom_var(self, key, value) -> Event:
|
||||||
logger.debug(f"Setting custom var {key} to {value}")
|
logger.debug(f"Setting custom var {key} to {value}")
|
||||||
data = b"\x29" + key.encode("utf-8") + ":" + value.encode("utf-8")
|
data = b"\x29" + key.encode("utf-8") + b":" + value.encode("utf-8")
|
||||||
return await self.send(data, [EventType.OK, EventType.ERROR])
|
return await self.send(data, [EventType.OK, EventType.ERROR])
|
||||||
|
|
||||||
async def send_cli(self, cmd) -> Event:
|
async def send_cli(self, cmd) -> Event:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue