|
10 | 10 | try:
|
11 | 11 | import machine
|
12 | 12 | gettime = lambda: time.ticks_ms()
|
| 13 | + SOCK_TIMEOUT = 0 |
13 | 14 | except ImportError:
|
14 | 15 | const = lambda x: x
|
15 | 16 | gettime = lambda: int(time.time() * 1000)
|
| 17 | + SOCK_TIMEOUT = 0.05 |
16 | 18 |
|
17 | 19 | def dummy(*args):
|
18 | 20 | pass
|
@@ -158,7 +160,7 @@ def process(self, data=None):
|
158 | 160 | if dlen == STA_SUCCESS:
|
159 | 161 | self.state = CONNECTED
|
160 | 162 | 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'] |
162 | 164 | if self.tmpl_id:
|
163 | 165 | info.extend(['tmpl', self.tmpl_id])
|
164 | 166 | info.extend(['fw-type', self.tmpl_id])
|
@@ -207,11 +209,6 @@ def process(self, data=None):
|
207 | 209 |
|
208 | 210 | import socket
|
209 | 211 |
|
210 |
| -try: |
211 |
| - SOCK_TIMEOUT = eval('0.05') |
212 |
| -except: |
213 |
| - SOCK_TIMEOUT = 0 |
214 |
| - |
215 | 212 | class Blynk(BlynkProtocol):
|
216 | 213 | def __init__(self, auth, **kwargs):
|
217 | 214 | self.insecure = kwargs.pop('insecure', False)
|
@@ -251,18 +248,18 @@ def connect(self):
|
251 | 248 | BlynkProtocol.connect(self)
|
252 | 249 |
|
253 | 250 | def _write(self, data):
|
254 |
| - #print('<', data.hex()) |
| 251 | + #print('<', data) |
255 | 252 | self.conn.write(data)
|
256 | 253 | # TODO: handle disconnect
|
257 | 254 |
|
258 | 255 | def run(self):
|
259 | 256 | data = b''
|
260 | 257 | try:
|
261 | 258 | data = self.conn.read(self.buffin)
|
262 |
| - #print('>', data.hex()) |
| 259 | + #print('>', data) |
263 | 260 | except KeyboardInterrupt:
|
264 | 261 | raise
|
265 | 262 | except: # TODO: handle disconnect
|
266 |
| - pass |
| 263 | + return |
267 | 264 | self.process(data)
|
268 | 265 |
|
0 commit comments