Skip to content
This repository was archived by the owner on May 7, 2025. It is now read-only.

Commit a94dfd7

Browse files
committed
Cleanup
1 parent f4c1924 commit a94dfd7

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

BlynkLib.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
try:
1111
import machine
1212
gettime = lambda: time.ticks_ms()
13+
SOCK_TIMEOUT = 0
1314
except ImportError:
1415
const = lambda x: x
1516
gettime = lambda: int(time.time() * 1000)
17+
SOCK_TIMEOUT = 0.05
1618

1719
def dummy(*args):
1820
pass
@@ -158,7 +160,7 @@ def process(self, data=None):
158160
if dlen == STA_SUCCESS:
159161
self.state = CONNECTED
160162
dt = now - self.lastSend
161-
info = ['ver', __version__, 'h-beat', self.heartbeat//1000, 'buff-in', self.buffin, 'dev', 'python']
163+
info = ['ver', __version__, 'h-beat', self.heartbeat//1000, 'buff-in', self.buffin, 'dev', sys.platform+'-py']
162164
if self.tmpl_id:
163165
info.extend(['tmpl', self.tmpl_id])
164166
info.extend(['fw-type', self.tmpl_id])
@@ -207,11 +209,6 @@ def process(self, data=None):
207209

208210
import socket
209211

210-
try:
211-
SOCK_TIMEOUT = eval('0.05')
212-
except:
213-
SOCK_TIMEOUT = 0
214-
215212
class Blynk(BlynkProtocol):
216213
def __init__(self, auth, **kwargs):
217214
self.insecure = kwargs.pop('insecure', False)
@@ -251,18 +248,18 @@ def connect(self):
251248
BlynkProtocol.connect(self)
252249

253250
def _write(self, data):
254-
#print('<', data.hex())
251+
#print('<', data)
255252
self.conn.write(data)
256253
# TODO: handle disconnect
257254

258255
def run(self):
259256
data = b''
260257
try:
261258
data = self.conn.read(self.buffin)
262-
#print('>', data.hex())
259+
#print('>', data)
263260
except KeyboardInterrupt:
264261
raise
265262
except: # TODO: handle disconnect
266-
pass
263+
return
267264
self.process(data)
268265

0 commit comments

Comments
 (0)