+ elif s.startswith('AT+JSDA'):
+ # AT+JSDA=<l>,<d> (l: length in bytes, d: data)
+ # l is (max?) 3 decimal digits and ranges from 1 to MTU size.
+ # Data can be ASCII or binary values (l bytes total).
+ l, d = s[s.find('=') + 1:].split(',')
+ if not l.isnumeric():
+ self.putx([2, ['Warning: Invalid data length "%s".' % l]])
+ if int(l) != len(d):
+ self.putx([2, ['Warning: Data length mismatch (%d != %d).' % \
+ (int(l), len(d))]])
+ # TODO: Warn if length > MTU size (which is firmware-dependent
+ # and is negotiated by both Bluetooth devices upon connection).
+ b = ''.join(['%02x ' % ord(c) for c in d])[:-1]
+ self.putx([0, ['Sending %d data bytes: %s' % (int(l), b)]])
+ self.putx([1, ['Send %d = %s' % (int(l), b)]])