Four days of work without any progress. Let me give the details and maybe anyone can help.
Connecting to Wifi: OK
Resolving addresses: not working!
Code:
s = socket.socket()
ai = socket.getaddrinfo("wikipedia.com", 80)
print("Bind address info:", ai)
Result on Windows (as expected):
Bind address info: [(<AddressFamily.AF_INET: 2>, 0, 0, '', ('91.198.174.194', 80))]
Result on board (0.0.0.0 is not useful):
Bind address info: [(2, 1, 0, '', ('0.0.0.0', 80))]
Listening to ports: impossible
code:
s = socket.socket()
print([n for n in dir(s) if not n.startswith('_')])
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(addr)
s.listen(5)
Result: these three command all fail because they were ‘taken out’ of the socket library in this firmware:
['close', 'read', 'readinto', 'readline', 'send', 'write', 'connect', 'recv', 'recvfrom', 'sendto', 'setblocking', 'settimeout']
AttributeError: 'socket' object has no attribute 'setsockopt'
sendind data: ok , until it is stuck
Code:
s.send('ABCDEFGH' * 2)
I used the NetAssistant as a tcp server in ‘group chat’ mode that echos back every sent data.
When using ‘* 2’ for sending 16 bytes, it’s usually ok. When changing to ‘* 10’ for 80 bytes, after several tries it is stuck on sending, in a way that the COM port will become useless even if I disconnect and reconnect the board. Sometimes only reloading a firmware will make it usable again!
reading data: ok , but only for small amounts
s.send('ABCDEFGH' * 10)
while True:
data = s.recv(8)
Reading 8 bytes usually succeeds. Reading 80 bytes fails 50% of the time (with a timeout). And the loop NEVER succeeds more than once. If the server send more than the bytes specified for the recv parameter, it will not read the rest and will fail with a timeout.
Conclusion: I’d be happy to hear of anybody with better results.
And BTW the support team is quite responsive, but pointed me to demo code which fails to run. I tested on two different boards, so I don’t think my board is broken.