+ def handle_host_command(self, ss, es, rxtx, s):
+ if s.startswith('AT+JSEC'):
+ pin = s[s.find('\r\n') - 4:len(s) - 2]
+ self.put(ss, es, self.out_ann,
+ [ANN_ASCII, ['Host set the Bluetooth PIN to ' + pin]])
+ elif s.startswith('AT+JSLN'):
+ name = s[s.find(',') + 1:-2]
+ self.put(ss, es, self.out_ann,
+ [ANN_ASCII, ['Host set the Bluetooth name to ' + name]])
+ else:
+ self.put(ss, es, self.out_ann,
+ [ANN_ASCII, ['Host sent unsupported command']])
+ self.cmd[rxtx] = ''
+
+ def handle_device_reply(self, ss, es, rxtx, s):
+ if s == 'ROK\r\n':
+ self.put(ss, es, self.out_ann,
+ [ANN_ASCII, ['Device initialized correctly']])
+ elif s == 'OK\r\n':
+ self.put(ss, es, self.out_ann,
+ [ANN_ASCII, ['Device acknowledged last command']])
+ elif s.startswith('ERR'):
+ error = s[s.find('=') + 1:]
+ self.put(ss, es, self.out_ann,
+ [ANN_ASCII, ['Device sent error code ' + error]])
+ else:
+ self.put(ss, es, self.out_ann,
+ [ANN_ASCII, ['Device sent an unknown reply']])
+ self.cmd[rxtx] = ''
+