skaarj1989 / mWebSockets

WebSockets for microcontrollers
https://skaarj1989.github.io/mWebSockets/autobahn-testsuite/servers/
MIT License
106 stars 22 forks source link

Support for Portenta H7 #53

Open fkromer opened 3 years ago

fkromer commented 3 years ago

Describe the feature

Higher end devices like the Portenta H7 do not provide pgmspace.h. This leads to a compilation error when trying to build code which uses mWebSockets on such a device (file not found error). One way to solve this issue is to provide a pgmspace.h file on the device driver side (more info about this here: https://github.com/arduino/ArduinoCore-mbed/issues/343). Another way is to implement device conditional compilation, meaning adding Portenta H7 to here and here.

@skaarj1989 @facchinm I could provide a PR if you are ok with the second alternative how to extend support of the lib. If not one would have to take the first approach instead. It seems like there is no best practice about which approach to prefer over the other in the Arduino ecosystem BTW.

Environment info

n.a.

Expected behavior

Should compile on Portenta H7.

Additional context

n.a.

skaarj1989 commented 3 years ago

@fkromer I added initial support in mbed_portenta branch. It compiles, but I don't have a Portenta board, so I can't verify whether it works or not.

fkromer commented 3 years ago

@skaarj1989 Thanks a lot. simple-server.ino compiles 🚀

skaarj1989 commented 3 years ago

@fkromer If you have a Portenta board, could you verify if the code is working?

fkromer commented 3 years ago

@skaarj1989 Mh, the example will not work via Wifi I guess. According to the schematic of the Portenta H7 the Wifi chip on the Portenta H7 is LBEE5KL1DX. You are expecting some Wxxxx chip, right?

skaarj1989 commented 3 years ago

(...) You are expecting some Wxxxx chip, right?

Yes, that would be nice.

fkromer commented 3 years ago

@skaarj1989 The Portenta H7 passes the ethernet signals via one of the two 80 pin connectors to the board in use. I've a machine control board at hand and can try this one.

fkromer commented 3 years ago

(...) You are expecting some Wxxxx chip, right?

Yes, that would be nice.

The Wifi chip on the Portenta H7 is LBEE5KL1DX. Should be ok to just get rid of the outer #if NETWORK_CONTROLLER == ETHERNET_CONTROLLER_W5X00 probably.

fkromer commented 3 years ago

@skaarj1989 This ethernet connection

byte mac[]{0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(192, 168, 1, 2);

means random mac should be ok. The ip address is in the subnet range of my interface. Should be ok as well. I get this serial terminal output:

Initializing ... 
Server running at 0.0.0.0:3000

However I cannot establish a websocket connection.

skaarj1989 commented 3 years ago

@fkromer Server running at 0.0.0.0:3000 Obviously this is bad. Try to run WebClient demo and see if you can get valid IP address.

fkromer commented 3 years ago

Obviously this is bad.

@skaarj1989 Yepp

fkromer commented 3 years ago

@skaarj1989 The WebClient demo works with DHCP. The random mac address is the same like in simple-server.ino. There is no need to watch out for a mac printed on a sticker. I'll try the websockets example with dhcp as well.

fkromer commented 3 years ago

@skaarj1989 I've tried with a router and static IP. The server should be running on the static IP.

Initializing ... 
Server running at 192.168.178.211:3000

However I cannot establish a websocket connection. I get an error: socket hang up.

fkromer commented 3 years ago

I've tried with static IP again. The server seems to have an IP.

Initializing ... 
Server running at 192.168.1.2:3000

However I still cannot estabish a connection due to error: socket hang up.

Is the print output Server running ... really indicating a running server or does it just return the local IP (_SERIAL.print(Ethernet.localIP());)?

skaarj1989 commented 3 years ago

@fkromer Could you verify if WebSocketClient is working?

fkromer commented 3 years ago

@skaarj1989 Sure. ATM I cannot span a websocket server on my machine. Do you know some public websocket server I could connect to? I used to use http://www.websocket.org/ however the service is not available anymore.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

fkromer commented 2 years ago

@skaarj1989 Just want let you know that I do not need this feature anymore.

skaarj1989 commented 2 years ago

Anyways, support for Portenta board would be nice to have.