1#!/usr/bin/env python3 2# 3# Copyright (c) 2024 Nordic Semiconductor 4# 5# Connect to Zephyr websocket console and give remote commands 6# 7 8import websocket 9import threading 10 11def reader(ws): 12 while True: 13 print(ws.recv().strip("\n")) 14 15if __name__ == "__main__": 16 websocket.enableTrace(False) 17 ws = websocket.WebSocket() 18 ws.connect("ws://192.0.2.1/console") 19 20 x = threading.Thread(target=reader, daemon=True, args=(ws,)) 21 x.start() 22 23 while True: 24 line = input("> ") 25 if line == "quit": 26 break 27 ws.send(line + "\n") 28 29 ws.close() 30