def _read(self):
#read until the client is stopped or the client disconnects
while self._connected:
#read data from Bluetooth socket
try:
data = self._client_sock.recv(1024, socket.MSG_DONTWAIT)
except IOError as e:
self._handle_bt_error(e)
data = b""
if data:
#print("received [%s]" % data)
if self._data_received_callback:
if self._encoding:
data = data.decode(self._encoding)
self.data_received_callback(data)
if self._conn_thread.stopping.wait(BLUETOOTH_TIMEOUT):
break
评论列表
文章目录