Damien, thanks for helping;
Yes, that works, but it appears that I need to declare the nic module in the scope that the socket will be created, which would mean that all of the modules that I already have would need to be re-written to declare the nic card inside the module.
Also, see this thread:
viewtopic.php?f=6&t=6180&p=35206#p35206
The pyboard socket appears to be so restricted in terms of it's functions and options.
If I run these from the REPL:
Code: Select all
import socket, network
nic = network.WIZNET5K(pyb.SPI(1), pyb.Pin.board.X5, pyb.Pin.board.X4)
nic.ifconfig()
nic.isconnected()
def subcb(val):
pass
from umqtt_simple import MQTTClient
client = MQTTClient('123456789','xxxnet.com',port=1883)
client.set_callback(subcb)
client.connect()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/nfs/qnap/data/uPython/bash/../flash/lib/umqtt_simple.py", line 74, in connect
AttributeError: 'socket' object has no attribute 'write'
As you can see it fails, so umqtt_simple would need to be re-written to use 'send', but also this fails:
Code: Select all
>>> import socket, network
>>> nic = network.WIZNET5K(pyb.SPI(1), pyb.Pin.board.X5, pyb.Pin.board.X4)
>>> nic.ifconfig()
('192.168.0.18', '255.255.255.0', '192.168.0.1', '8.8.8.8')
>>> nic.isconnected()
True
>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> sf = s.makefile('rwb')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'socket' object has no attribute 'makefile'
And without makefile, and there is no readline(), it difficult to be able to read the socket line by line.