Ok, or code that actually does the splitting for you:
# based on https://github.com/rlangoy/bluepy_examples_nRF51822_mbed/blob/master/writeLed2.py
import sys
from bluepy.btle import UUID, Peripheral
if len(sys.argv) != 2:
print "Fatal, must pass device address:", sys.argv[0], "<device address="">"
quit()
# \x03 -> Ctrl-C clears line
# \x10 -> Echo off for line so don't try and send any text back
# command = "\x03\x10reset()\nLED.toggle()\n"
command = "\x03\x10clearInterval()\n\x10setInterval(function() {LED.toggle()}, 500);\n"
p = Peripheral(sys.argv[1], "random")
UartService=p.getServiceByUUID(UUID("6E400001-B5A3-F393-E0A9-E50E24DCCA9E"))
ch = UartService.getCharacteristics(UUID("6E400002-B5A3-F393-E0A9-E50E24DCCA9E"))[0]
while len(command)>0:
ch.write(command[0:20]);
command = command[20:];
p.disconnect()
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Ok, or code that actually does the splitting for you: