IoT with FEZ rules them all

Maybe there is a newer version in dev branch. What is online is what is the latest we have.

Hi Gus,

The compilers complains about the GHI package signer:
This project references NuGet package(s) that are missing on this computer. The missing file is The missing file is ā€¦\packages\GHIElectronics.Tools.AssemblySigner.1.0.3\build\GHIElectronics.Tools.AssemblySigner.targets

Hi,
I have deleted the references to the GHI assembly signer and ST driver compiles. Also I have copy OpenSockect to OpenServerSocket in GHI SPWF04Sx driver. This worked! The response was catched in the event handler: wifi.IndicationReceived += (s, e) => ā€¦ as defined in wifi.cs. I have succesfully catched:
SPWF04SxIndication.IncomingSocketClient and SPWF04SxIndication.PendingData in this event handler. I donā€™t know if this the recommanded way. May be a callback should be used? I am still not sucessfully received data because IncomingSocketClient and PendingData didnā€™t contain any data. What was received the IP address of the client and som numbers. I canā€™t find any spec of these numbers. Also it was tested with webbrouwser as client. I am searching for socket client app but not found (one from google play store didnā€™t download).

May be the GHI assmeblysigner had to be used only if the GHI publish the drivers. To delete the references i had to edit the ST driver project file.

Q: Do I have to catch incomming sockets in the event handler or is tthere a better way? How to read the socket data?

Thanks for all your help!

Best regards,
Aart

Good Progress !! I Would not compile the driver as .dll but would add all of its classes to my project.Then you can set breakpoints an better see what is going on.

1 Like

Some years ago I played around with RN171 WiFi Module. To test the http server I used a simple homemade http client for PC. Perhaps it can be helpful. The client App is included in this project.
https://old.ghielectronics.com/community/codeshare/entry/927

1 Like

I have compiled the GHIElectronics.TinyCLR.Drivers.STMicroelectronics project in the GHIElectronics.TinyCLR.Drivers solution in debug mode. After that I copied (can be automated) to the Packages folder of my project. I can now ā€˜Step Intoā€™ (with F11) the SPWF04Sx.DLL and it open SPWF04SxInterface.cs and others ro see what happens and I can even set breakpoint there! Work great. BTW the Wifi model doesnā€™t connect to an Unify access point but a Fritzbox AP is not a problem!

Hi RoSchmi,

This WiFi module used a preprogrammed web server with which you can (dynamical) create html files in flash wiich are then being served. I don;t know how to use this to make a kind of SOAP or REST service. The Wifi module supports a socket server which looks very usable. I used the SPWF04Sx training pdf found on STā€™s website. Here are not all the return values defined. May be I had to seach a document with full spec. Further I downloaded from a Android phone the SP socket tester in Google Play store. The same one that is used in the ST training PDF. But if I entered the wifi moduleā€™s IP addess and the port (i choose 3333) the handler is not fired with IncomingSocketClient. Probably I had to open port 3333 in the firewall in this situation. If I type in a desktop web browser http://<FEZ_IP>:3333 then several IncomingSocketClient are received. So I can continue for now!

Did you download my http client? Itā€™s a C# windows forms application. You can run it with debugger and can see what you send and what you get (only port 80 I think).

Hi RoSchmi,

I havenā€™t downloaded your http client because I have installed the SP socket tester on an android phone. May be I will do later to learn new things from your software.

The downloaded SP socket tester is the same as the one used in ST Microelectronics training PDF. Problem was that ST WiFi module didnā€™t connect to our Unify Access Point. This AP is in our domain and gives local IP addresses. After reconnecting the USB of the FEZ it was suddenly able to connect to the Unify AP. After that I could test access over the public internet. And it worked very well!!!

If I click ā€˜Connectā€™ in the SP app than I receive: WIND: IncomingSocketClient :39876:0:0. 39876 is the Remote Port. What 0:0 is I am not sure but the first zero I think is the socket numer. I will see later. After entering some text in the SP Google app and I click ā€˜Sendā€™ then I receive: WIND: PendingData 0:0:4:8. The last 8 is the number of characters I entered in the app. The first 0 is probably the spocket number but what is second 0 and 4? The Send button can be clicked repeatedly with different text. I receive new PendingDataā€™s with the last number changed according the length of the eneterd text.

Next problem is to read the text entered in the SP app and this goes with other AT commands not implemented yet. So I am on my to get started with IoT but I never had expected that this wasnā€™t possibly out of the box.

Only strange that the ST WiFi module could not connect to the AP from Unify in the first place. Now the connection was succesfull I get WpaCrunchingPsk xxx:16 is stead of xxx:14.

Best Regards,
Aart

Only strange that the ST WiFi module could not connect to the AP from Unify in the first place. Now the connection was succesfull I get WpaCrunchingPsk xxx:16 is stead of xxx:14.

I think you must have a look if ā€˜SPWF04SxWiFiState.ReadyToTransmitā€™ state is reached before you can continue to write to the module
ā€“https://github.com/RoSchmi/AzureDataSender_FEZ/blob/master/AzureDataSender_FEZ/RoSchmi/Net/WiFi_SPWF04S_Device.cs

Hi RoSchmi,

Thank you again!

I have waited until the event SPWF04SxIndication.WiFiUp occured. But this event never occured however. After a power Off and On suddenly everyting start to work. Also Socket Connect and Socket Send works as expected. I will also test if (Wifi.State == SPWF04SxWiFiState.ReadyToTransmit). I never use ā€˜Stateā€™ but i expect that this State occors before the WiFiUp event.

Best regards,
Aart

Hi RoSchmi,

Forgot to ask: Where can I find a specifiction the return messages of the AT commands? In the ST training manual i found for example: +WIND:61:Incoming Socket Client:192.168.1.XX:12345:0:0. I have found that 12345 is remote port number but what is 0:0. Also in the PDF +WIND:55:Pending Data:0:0:4:4. The last 4 is the number of characters of the entered text (test in this case). But what are 0:0:4 or where is the spec?

Thanks for your support.

Best Regards,
Aart

Sorry, I have all ready found the specs on the ST website: en.DM00329655.pdf

2 Likes

Hi RoSchmi,

I have now used: if (Wifi.State == SPWF04SxWiFiState.ReadyToTransmit) and everything works reliable at the moment. Thank very much for the hint!

In the mean I can receive incoming sockets and read the data entered in the SP Google app over the public internet. I have only added:
public int OpenServerSocket(int port, SPWF04SxConnectionType connectionType, SPWF04SxConnectionSecurityType connectionSecurity)
and
public int ReadServerSocket(int SockIdServer, int SockIdClient, byte[] buffer, int buflen=0)

Next: to implement: WriteServerSocket and CloseServerSocket.

So nearly ready to start!

Best Regards,
Aart

1 Like

Hi all,

I would let you know that everything has been solved! I have added OpenServerSocket, ReadServerSocket, WriteServerSocket and SocketClientGone to the GHI ST Wifi driver. With tests with SP Google app last problem was when SP closses the socket (after a time out). In that case the wait for: SPWF04SxIndication.PendingData: had to be stopped on the event: SPWF04SxIndication.SocketClientGone so that SP can reconnect. Last test will be with multiple SP clients (module support max 8 sockets). After that I can start the IoT with FEZ rules them all board.

Thanks a lot for all the help!

Best Regards,
Aart

2 Likes

Sorry this text:

had to be:
WriteServerSocket and CloseServerSocket to the

1 Like

Thanks for posting your results. Would be very nice if you could post some code on Github or elsewhere for download.

2 Likes

Hi RoSchmi,

The new functions are merely copies of the existing ones in the GHI SPWF04SxInterface.cs file but changed with the needed AT command. But if you want them it is OK. Where I ahd tom upload?

May be I should finish the orher functions first. I have allready made the MiniAP mode functions and I can use the FEZ as an AP now. I that this the mode after a reset with an easy predefined IP. This actualy works. I have the AP now with IP: 222.222.222.222 and my phone gets IP 222.222.222.223.

Strange thing is that this dinā€™t work with a Winoows phone but it did with an Android. With this the user should be able to join an existing network or keep this ip for ad hoc device control. This user config had to be remembered but also flash and memory function are not implemented. Also after a reset the device had to return to the MiniAP mode with the easy IP address.

In had read everything about the memory and flash control functions of the ST Wifi module. Mentioned was that this module is obsolete?

Best Regards,
Aart

Yes sir. Replacing the ST WiFi Modules

@aartastona Yes, I think it is the best to post the code when all intended functions are ready. A good place to upload is Github.
@Gus_Issa Curios that STM stopped SPWF04SA without having a successor. Is there any information if they are going to have a successor in the next time and why the gave up this product. How about your efforts to find another WiFi module?