libsmartpen
libsmartpen copied to clipboard
Fix error when downloading large file
The Livescribe SmartPen firmware (at least v1.5) requires a Connection header after every Continue response (which contradicts the Obex spec). We convince openobex to send the header by calling OBEX_ObjectAddHeader in the event callback.
The problem is that openobex keeps counting request bytes, and when you set OBEX_FL_FIT_ONE_PACKET it will return error once all your Connection headers reach the 1kB MTU. The solution is to turn off that flag.
Example of getting error when the pen has a lot of data (in my case, PaperReplay is 1GB):
>>> import pysmartpen
>>> s = pysmartpen.Smartpen()
>>> s.connect(vendor=0x1cfb, product=0x1010)
>>> s.get_paperreplay('paperreplay')
oah fail -1
oah fail -1
FAIL 53 3
python: smartpen.c:83: obex_event: Assertion `0' failed.
Aborted (core dumped)
btw the maintainers of the LibreScribe smartpen.c fork seem to have already come across this solution
Sorry, I didn't fix the right file. I have modified the commit to also fix smartpen.c (not just obex.c).