Main Site Documentation

FEZWiFi example


#1

I’m trying to get the example program FEZWiFi working. Everything seems to work until the program gets to ResourceManager.GetObject call in the Resources class. A System.ArgumentException occurred in mscorlib.dll. I am at a standstill on how to solve this exception.


#2

Did you add the resource you need?http://docs.ghielectronics.com/software/tinyclr/tutorials/resources.html


#3

Thanks, that suggestion got me a little bit further. Now I get an unhandled exeception of type ‘System.InvalidOperationException’ occurred in GHIElectronics.TinyCLR.Drivers.STMicroelectronics.SPWF04Sx.dll
Additional information: Unexpected payload.

Apparently the exception occurred in routine TestSocket when wifi.OpenSocket was called.
Again, thanks for the help.


#4

There is a very recent thread on this forum with a lot of info. For example, it talks about giving the module time to connect


#5

Did you try to open a TLS secured socket or without security?
I would first try without TLS:
TestSocket(“www.ghielectronics.com”, “/robots.txt”, 80, SPWF04SxConnectionType.Tcp, SPWF04SxConnectionSecurityType.None);


#6

Thanks for your suggestion. I still got the same exception. I’m fairly new at this network stuff and am just trying to get the example project FEZWiFi to work. Could this exception have anything to do with certificates?


#7

I think it is the best if you show your code and perhaps only use the TestSocket call I mentioned above.


#8

I’m new to these forums. What would be the avenue for me to show you my code?


#9

Copy and paste. If you then type some (I think 4) spaces at the beginning of a line it is formated as code.
Please try to keep it short.


#10

my code is the FEZWiFi project from /github.com/ghi-electronics/TinyClr-Samples. I didn’t add/change anything.


#11

I would first try without TLS:
–>
comment out this line:
//wifi.SetTlsServerRootCertificate(Resources.GetBytes(Resources.BinaryResources.DigiCertGlobalRootCA));

include this line in the while loop and comment out all the other calls:

TestSocket(“www.ghielectronics.com”, “/robots.txt”, 80, SPWF04SxConnectionType.Tcp, SPWF04SxConnectionSecurityType.None);


#12

the call to wifi.OpenSocket resulted in following exception:

Exception System.Exception - 0x00000000 (1)

#### Message: Request failed
#### GHIElectronics.TinyCLR.Drivers.STMicroelectronics.SPWF04Sx.SPWF04SxInterface::OpenSocket [IP: 0083] ####
#### FEZWiFi_1.Program::TestSocket [IP: 001a] ####
#### FEZWiFi_1.Program::Main [IP: 00f8] ####

Exception thrown: ‘System.Exception’ in GHIElectronics.TinyCLR.Drivers.STMicroelectronics.SPWF04Sx.dll
Request failed


#13

Some questions:
Did you make the firmware update of the WiFi module?
Did you leave enough time (try 20 sec) before pressing BTN1 to led the module scan and than connect to the router?
Did you see the messages WIND: WiFiUp 0:xxx.xxx.xxx.xxx (Ip-Address)
and WIND: NtpServerDelivery 2019.3.21… ?


#14

Yes, to all three of your questions.


#15

Don’t know why it doesn’t work for you, here the same code works. Something with your WiFi Network? Repeater? Firewall?
You could download the WiFi driver from Github and use this instead of the .dll. Then you can set breakpoints inside the driver.
If you want you can download and try my App -https://github.com/RoSchmi/AzureDataSender_FEZ which uses the GHI driver with little modifications.


#16

I get errors building your app since the files that are referenced in your resources are missing on my computer.

Debugging the OpenSocket routine in the driver, I find that var a is always “13.82.175.96:0\r\n” which is what causes the exception. My guess is that this string comes from the router.


#17

That is the Ip-Address of the url you want to access, that is correct


#18

Do you have any idea why a socket wan’t opened?


#19

Is it valid to have cr and nl in url?


#20

Is port 0 valid?