Skip to content

Server error - has to reconnect to device for each API call #9

@gebjohn

Description

@gebjohn

Hi,

Love your work.

Sometimes immediately, sometimes after a couple of calls on the API, I get an error where the bluetooth device disconnects. It reconnects automatically and does what its meant to, but it makes it laggy (about 1 second to reconnect each time). I've put the output from the server.py below.

Can you point me in the direction for fixing it?

(Environment: I am using bluepy1.1.4. Latest version of ubuntu. Using a TP-Link USB bluetooth adapter if that makes any difference)

Gareth

isabel@Isabels-Computer:~/sbrickpy$ sudo python3 sbrick_server.py --connect --broker-ip 127.0.0.1 --broker-port 1883 --log-level debug --sbrick-id D0:CF:5E:52:3A:A8
2021-02-04 20:36:05,053 [sbrick_server.py:104(INFO)] MainThread - SBrick server settings
2021-02-04 20:36:05,053 [sbrick_server.py:106(INFO)] MainThread - connect:True
2021-02-04 20:36:05,053 [sbrick_server.py:106(INFO)] MainThread - scan:False
2021-02-04 20:36:05,053 [sbrick_server.py:106(INFO)] MainThread - broker_ip:127.0.0.1
2021-02-04 20:36:05,053 [sbrick_server.py:106(INFO)] MainThread - broker_port:1883
2021-02-04 20:36:05,053 [sbrick_server.py:106(INFO)] MainThread - broker_user:None
2021-02-04 20:36:05,053 [sbrick_server.py:106(INFO)] MainThread - broker_passwd:None
2021-02-04 20:36:05,053 [sbrick_server.py:106(INFO)] MainThread - sbrick_id:['D0:CF:5E:52:3A:A8']
2021-02-04 20:36:05,053 [sbrick_server.py:106(INFO)] MainThread - log_level:debug
2021-02-04 20:36:08,075 [sbrick_api.py:154(INFO)] MainThread - Try to connect to SBrick (D0:CF:5E:52:3A:A8)
2021-02-04 20:36:10,435 [sbrick_api.py:173(INFO)] MainThread - Connect to SBrick (D0:CF:5E:52:3A:A8) successfully
2021-02-04 20:36:10,435 [sbrick_api.py:177(INFO)] MainThread - Get rcc characteristic
2021-02-04 20:36:11,028 [sbrick_m2mipc.py:60(INFO)] MainThread - Connect to mosquitto broker 127.0.0.1:1883
2021-02-04 20:36:15,300 [sbrick_m2mipc.py:97(DEBUG)] MainThread - Accept drive() event: {'sbrick_id': 'D0:CF:5E:52:3A:A8', 'channel': '00', 'direction': '00', 'power': 'f0', 'exec_time': 10}
2021-02-04 20:36:15,301 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:15,301 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:16,302 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:16,302 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:17,304 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:17,304 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:18,305 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:18,305 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:19,306 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:19,306 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:20,307 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:20,308 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:21,309 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:21,309 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:22,310 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:22,310 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:23,312 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:23,312 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:24,313 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:24,313 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:25,301 [sbrick_api.py:70(DEBUG)] timer_00 - Drive action times_up 010000f0
2021-02-04 20:36:25,314 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 0000
2021-02-04 20:36:25,314 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x00\x00'
2021-02-04 20:36:27,438 [sbrick_m2mipc.py:97(DEBUG)] MainThread - Accept drive() event: {'sbrick_id': 'D0:CF:5E:52:3A:A8', 'channel': '00', 'direction': '00', 'power': 'f0', 'exec_time': 10}
2021-02-04 20:36:27,438 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:27,439 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'

2021-02-04 20:36:27,439 [sbrick_api.py:282(ERROR)] channel_00 - SBrick (D0:CF:5E:52:3A:A8): Device disconnected
2021-02-04 20:36:27,439 [sbrick_api.py:145(INFO)] channel_00 - Construct a new bluetooth object
2021-02-04 20:36:27,440 [sbrick_api.py:226(INFO)] channel_00 - Re-connect to SBrick (D0:CF:5E:52:3A:A8)
2021-02-04 20:36:27,440 [sbrick_api.py:221(INFO)] channel_00 - Disconnect from SBrick(D0:CF:5E:52:3A:A8) successfully
2021-02-04 20:36:27,440 [sbrick_api.py:154(INFO)] channel_00 - Try to connect to SBrick (D0:CF:5E:52:3A:A8)
2021-02-04 20:36:30,314 [sbrick_api.py:173(INFO)] channel_00 - Connect to SBrick (D0:CF:5E:52:3A:A8) successfully
2021-02-04 20:36:30,315 [sbrick_api.py:177(INFO)] channel_00 - Get rcc characteristic
2021-02-04 20:36:32,026 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:32,027 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:33,028 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:33,028 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:34,029 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:34,029 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:35,031 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:35,031 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:36,032 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:36,032 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:37,033 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:37,034 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:37,438 [sbrick_api.py:70(DEBUG)] timer_00 - Drive action times_up 010000f0
2021-02-04 20:36:38,035 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 0000
2021-02-04 20:36:38,035 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x00\x00'
2021-02-04 20:36:48,345 [sbrick_m2mipc.py:97(DEBUG)] MainThread - Accept drive() event: {'sbrick_id': 'D0:CF:5E:52:3A:A8', 'channel': '00', 'direction': '00', 'power': 'f0', 'exec_time': 10}
2021-02-04 20:36:48,346 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:48,346 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'

2021-02-04 20:36:48,346 [sbrick_api.py:282(ERROR)] channel_00 - SBrick (D0:CF:5E:52:3A:A8): Device disconnected
2021-02-04 20:36:48,346 [sbrick_api.py:145(INFO)] channel_00 - Construct a new bluetooth object
2021-02-04 20:36:48,347 [sbrick_api.py:226(INFO)] channel_00 - Re-connect to SBrick (D0:CF:5E:52:3A:A8)
2021-02-04 20:36:48,347 [sbrick_api.py:221(INFO)] channel_00 - Disconnect from SBrick(D0:CF:5E:52:3A:A8) successfully
2021-02-04 20:36:48,347 [sbrick_api.py:154(INFO)] channel_00 - Try to connect to SBrick (D0:CF:5E:52:3A:A8)
2021-02-04 20:36:50,692 [sbrick_api.py:173(INFO)] channel_00 - Connect to SBrick (D0:CF:5E:52:3A:A8) successfully
2021-02-04 20:36:50,692 [sbrick_api.py:177(INFO)] channel_00 - Get rcc characteristic
2021-02-04 20:36:52,571 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:52,571 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:53,572 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:53,572 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:54,573 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:54,574 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:55,575 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:55,575 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:56,576 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:56,576 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:57,578 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 010000f0
2021-02-04 20:36:57,578 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x01\x00\x00\xf0'
2021-02-04 20:36:58,346 [sbrick_api.py:70(DEBUG)] timer_00 - Drive action times_up 010000f0
2021-02-04 20:36:58,579 [sbrick_api.py:104(DEBUG)] channel_00 - Exec command 0000
2021-02-04 20:36:58,579 [sbrick_api.py:266(DEBUG)] channel_00 - RCC characteristic writes binary: b'\x00\x00'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions