iSpindel-TCP-Server
iSpindel-TCP-Server copied to clipboard
Server on Python3 - changes required
The code as it stands doesnt like sending the NAKs or AKs
eg.
in handler clientsock.send(NAK) TypeError: a bytes-like object is required, not 'str'
so I commented this out (line 104 i think) and found that the string being received is as follows received:b'{' which looks like the ispindel is sending the code to convert a { into a byte value rather than the actual { so if I bypass this as its essentially sending the { and change the check to
if inpstr[2] != "{" :
then things continue to the next step and I get stuff like
_('xxx.xxx.xxx.xxx', 2043) received:b'"name":"iSpindel001","ID":748188,"angle":73.62824,"temperature":32.375,"battery":4.035453,"gravity":1.239934,"interval":30,"RSSI":-49}\r\n'
('xxx.xxx.xxx.xxx', 2043) Not JSON. ('xxx.xxx.xxx.xxx', 2043) - closed connection_
So two questions
- How best to fix the original NAK issue (& do I need to fork a seperate version for Python 3)?
- Is the problem of the extra characters with the iSpindel software (Sorry I know nothing of JSON yet)?
iSpindel is at 5.85
I will look into this. It might have to do with Python 3 indeed as I have not noticed this behaviour with 2.7. I am currently working on this part of the code anyway, so stay tuned and thanks for the info!
We'll switch to Python3 with the next release.
Any word on Python 3?
I would be happy to contribute if you don't have the time...