Skip to content

Commit

Permalink
add initial protobuf and BLE functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
nkraetzschmar committed Feb 6, 2024
1 parent 1f9acc6 commit 80ff770
Show file tree
Hide file tree
Showing 4 changed files with 570 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*_pb2.py
__pycache__
44 changes: 44 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python3

import asyncio
from libikawa import *

async def main():
async with Ikawa() as ikawa:
cmd = Cmd(cmd_type=BOOTLOADER_GET_VERSION)
resp = await ikawa.send_cmd(cmd)
print(resp)
cmd = Cmd(cmd_type=MACH_PROP_GET_TYPE)
resp = await ikawa.send_cmd(cmd)
print(resp)
cmd = Cmd(cmd_type=PROFILE_GET)
resp = await ikawa.send_cmd(cmd)
print(resp)

print("enumerating settings...")
settings=dict()
cmd = Cmd(cmd_type=SETTING_GET_LIST, setting_get_list=CmdSettingGetList(offset=0))
resp = await ikawa.send_cmd(cmd)
# print(resp)
for i in resp.resp_setting_get_list.number:
cmd = Cmd(cmd_type=SETTING_GET_INFO, setting_get_info=CmdSettingGetInfo(number=i))
resp = await ikawa.send_cmd(cmd)
# print(resp)
settings[resp.resp_setting_get_info.name] = i
print(f"settings={settings}\n")

cmd = Cmd(cmd_type=SETTING_GET, setting_get=CmdSettingGet(number=settings['ROASTER_ID']))
resp = await ikawa.send_cmd(cmd)
print(resp)

while True:
cmd = Cmd(cmd_type=MACH_STATUS_GET_ALL)
resp = await ikawa.send_cmd(cmd)
status = resp.resp_mach_status_get_all
print(f"{status.time}, {MachState.Name(status.state)}, {status.temp_above*0.1:.1f}, {status.temp_below*0.1:.1f}, {status.setpoint*0.1:.1f}, {status.heater}, {status.fan/255.0:.2f}, {(status.fan_measured/12.0)*60:.0f}")
await asyncio.sleep(0.1)

try:
asyncio.run(main())
except KeyboardInterrupt:
print("Received interrupt signal, bye")
Loading

0 comments on commit 80ff770

Please sign in to comment.