From 89be0be23c2087ee66227ff7fc591377b54a3021 Mon Sep 17 00:00:00 2001 From: jfekete1 Date: Mon, 26 Jun 2023 19:27:19 +0200 Subject: [PATCH] added send notification feature Signed-off-by: jfekete1 --- tools/wasptool | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/wasptool b/tools/wasptool index 2453b58..6cbe30d 100755 --- a/tools/wasptool +++ b/tools/wasptool @@ -368,6 +368,13 @@ def handle_upload(c, fname, tname): c.expect('>>> ') +def send_notification(c, title, body, id): + msg= {'title': title, 'body': body} + c.sendline(f'wasp.system.notify(id, {msg})') + c.sendline(f'watch.vibrator.pulse(ms=wasp.system.notify_duration)') + c.expect('>>> ') + + if __name__ == '__main__': parser = argparse.ArgumentParser( description='Wasp-os command and control client') @@ -377,6 +384,8 @@ if __name__ == '__main__': help="Report remaining battery charge") parser.add_argument('--bootloader', action='store_true', help="Reboot into the bootloader mode for OTA update") + parser.add_argument('--body', default='Body', + help='Body of the notification') parser.add_argument('--binary', action='store_true', help="Enable non-ASCII mode for upload command") parser.add_argument('--console', action='store_true', @@ -389,6 +398,8 @@ if __name__ == '__main__': help='Execute the contents of a file') parser.add_argument('--eval', help='Execute the provided python string') + parser.add_argument('--id', default=1, + help='ID of the notification') parser.add_argument('--memfree', action='store_true', help='Report on the current memory usage.') parser.add_argument('--pull', @@ -403,6 +414,10 @@ if __name__ == '__main__': help="Deliver an OTA update to the device") parser.add_argument('--rtc', action='store_true', help='Set the time on the wasp-os device') + parser.add_argument('--send-notification', action='store_true', + help='Send a notification to the wasp-os device (e.g. wasptool --send-notification --title hello --body world --id 1') + parser.add_argument('--title', default='Title', + help='Title of the notification') parser.add_argument('--upload', help='Copy the specified file to the wasp-os device') parser.add_argument('--verbose', action='store_true', @@ -450,6 +465,9 @@ if __name__ == '__main__': if args.check_rtc: check_rtc(console) + if args.send_notification: + send_notification(console, args.title, args.body, args.id) + if args.exec: handle_exec(console, args.exec)