mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
get/set repeat mode
This commit is contained in:
parent
b8294cfb2f
commit
03a2a7c64e
2 changed files with 13 additions and 10 deletions
|
|
@ -66,16 +66,16 @@ class DeviceCommands(CommandHandlerBase):
|
|||
b"\x0c" + int(val).to_bytes(4, "little"), [EventType.OK, EventType.ERROR]
|
||||
)
|
||||
|
||||
async def set_radio(self, freq: float, bw: float, sf: int, cr: int) -> Event:
|
||||
logger.debug(f"Setting radio params: freq={freq}, bw={bw}, sf={sf}, cr={cr}")
|
||||
return await self.send(
|
||||
b"\x0b"
|
||||
+ int(float(freq) * 1000).to_bytes(4, "little")
|
||||
+ int(float(bw) * 1000).to_bytes(4, "little")
|
||||
+ int(sf).to_bytes(1, "little")
|
||||
+ int(cr).to_bytes(1, "little"),
|
||||
[EventType.OK, EventType.ERROR],
|
||||
)
|
||||
async def set_radio(self, freq: float, bw: float, sf: int, cr: int, repeat = None) -> Event:
|
||||
logger.debug(f"Setting radio params: freq={freq}, bw={bw}, sf={sf}, cr={cr}, repeat={repeat}")
|
||||
data = b"\x0b"
|
||||
data += int(float(freq) * 1000).to_bytes(4, "little")
|
||||
data += int(float(bw) * 1000).to_bytes(4, "little")
|
||||
data += int(sf).to_bytes(1, "little")
|
||||
data += int(cr).to_bytes(1, "little")
|
||||
if not repeat is None:
|
||||
data += int(repeat).to_bytes(1,"little")
|
||||
return await self.send(data, [EventType.OK, EventType.ERROR])
|
||||
|
||||
async def set_tuning(self, rx_dly: int, af: int) -> Event:
|
||||
logger.debug(f"Setting tuning params: rx_dly={rx_dly}, af={af}")
|
||||
|
|
|
|||
|
|
@ -278,6 +278,9 @@ class MessageReader:
|
|||
res["fw_build"] = dbuf.read(12).decode("utf-8", "ignore").replace("\0", "")
|
||||
res["model"] = dbuf.read(40).decode("utf-8", "ignore").replace("\0", "")
|
||||
res["ver"] = dbuf.read(20).decode("utf-8", "ignore").replace("\0", "")
|
||||
rpt = dbuf.read(1)
|
||||
if len(rpt) > 0:
|
||||
res["repeat"] = (rpt[0] != 0)
|
||||
await self.dispatcher.dispatch(Event(EventType.DEVICE_INFO, res))
|
||||
|
||||
elif packet_type_value == PacketType.CUSTOM_VARS.value:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue