Skip to content

Commit

Permalink
fix(pando): use pando str prefix in eim message
Browse files Browse the repository at this point in the history
  • Loading branch information
wangshub committed Apr 16, 2019
1 parent 065d6e8 commit 435f37b
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions servers/pando_server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
import zmq
from zmq import Context
import time
Expand Down Expand Up @@ -25,11 +26,11 @@
RX_CHAR_UUID = uuid.UUID('6E400003-B5A3-F393-E0A9-E50E24DCCA9E')

move_map = {
"forward": [0xd1],
"backward": [0xd2],
"left": [0xd3],
"right": [0xd4],
"stop": [0xda]
"pando_forward": [0xd1],
"pando_backward": [0xd2],
"pando_left": [0xd3],
"pando_right": [0xd4],
"pando_stop": [0xda]
}


Expand Down Expand Up @@ -68,6 +69,7 @@ def ble_thread():
time.sleep(0.1)
if not ble_cmd_queue.empty():
cmd = ble_cmd_queue.get()
print('send ', cmd)
tx.write_value(bytes(cmd))
except Exception as err:
print(err)
Expand All @@ -80,9 +82,6 @@ def ble_send(cmd_list):


def ble_run():
while True:
time.sleep(1)

ble.initialize()
ble.run_mainloop_with(ble_thread)

Expand All @@ -92,23 +91,24 @@ def run_in_backend(func):
task.start()


def terminate():
sys.exit(1)


def server_loop():
while True:
action = socket.recv_json().get("action")
socket.send_json({"result": "nothing"})
print('rcv action = {}'.format(action))
if not action:
continue
if action == "pando_quit":
socket.send_json({"result": "quit!"})
terminate()
break
cmd = move_map.get(action)
if cmd:
print(cmd)
ble_send(cmd)


if __name__ == '__main__':
# run_in_backend(server_loop)
server_loop()
# ble_run()
run_in_backend(server_loop)
ble_run()

0 comments on commit 435f37b

Please sign in to comment.