WIFI Modul & Transmission

Hello,
I’m trying to establish a WIFI connection to the cloud with the M220 / Base Starter and
now I’ve a bunch of questions:

I already used the command rM2M_RegSetString(RM2M_REG_APP_FLASH, “[SSID]”,“WPA_PSK:[PW]”)
to write the SSID and PW in the flash memory.
The network is secured with WPA2-Personal.
First I used the Basic Example “12_Transmission_1_uplink” which only contains the functions “RegSetString”, “TxSelectItf” and “TxStart”. The return values of these fct are OK, thus the connection to the server successful.
But this isn’t true: The response light in the rapidM2M Toolset shows that the “Last connection failed”.
To verify this I implemented the fct “TXGetStatus”. The return value is “1” (“last GPRS connection establishment failed”?) and the errorcode is “227”.
I can’t find the description of the errorcode 227. What is it?

Regarding the longer basic examples “70_wifi_scan” and “70_wifi_devinfo”, with included WIFI library,
I’d like to know the sequence of the functions “TxSelectItf”, “WIFI_Init”, “WIFI_Connect” and “TXStart”.
Is there a need to scan for available accesspoints to indicate a successful connection with "WIFI_connect?
Initialisation of the WIFI Module is OK and the module is at the state READY, but if i try to connect at this point, the return value is -1 (scan fail?). If i try to select the TXModule at this point, the return value is -104.
(WEP Password length invalid?)
Is the syntax RegSetString(RM2M_REG_APP_FLASH, “[SSID]”,“WPA_PSK:[PW]” especially the set string “WPA_PSK:[PW]” correct?

And the last question:
I tried to use another WIFI network. Therfore I wrote a second SSID and PW with the command RegSetString into the flash.
How can I specify the SSID the module should connect with?

Best regards,
Benjamin

Hello @Funk_Fuchs

The WiFi-Module can be used either as uplink to communicate with the rapidM2M Portal (controlled by the Firmware) or to communicate with sensors or other devices (controlled by the user generated script).

The example “12_Transmission_1_uplink.p” demonstrate the use as uplink. The two examples “70_wifi_scan.p” and “70_wifi_scan_devinfo.p” demonstrate how to uses the WiFi-module in conjunction with the user generated script.

I Think your Problem is that you have tried to write the SSID and Password with one call of the rM2M_RegSetString function. For the rM2M_RegSetString function are three Parameters required:

  • registration memory block into which the string should be written (e.g. “RM2M_REG_APP_FLASH”)
  • The Designation for the string (e.g. “wifiSSID”, neccessary for finding and reading out the string again)
  • The string that should be written (e.g. “TRAINING”)
    (see Registry for a detailed description of the rM2M_RegSetString function )

You have to write the SSID and Password with separate calls of the rM2M_RegSetString function.

rM2M_RegSetString(RM2M_REG_APP_FLASH, "wifiSSID", "TRAINING");           // Writes SSID ("wifiSSID" =^ Designator, "TRAINING" =^ SSID as String)
rM2M_RegSetString(RM2M_REG_APP_FLASH, "wifiPwd", "Password-training"); // Writes Password ("wifiPwd" =^ Designator, "Password-training" =^ Password as String)

The Firmware uses the Designator “wifiSSID” to find the entry containing the SSID and the Designator “wifiPwd” to find the entry containing the Password.

If you also want to specify the security type you have to add this to the String containing the SSID (see example below)

rM2M_RegSetString(RM2M_REG_APP_FLASH, "wifiSSID", "WPA_PSK;TRAINING"); // Writes security type and SSID (Alternative to the line above)

Now to your Return result:

  • RegSetString returned OK because it was possible to write the String into registration memory block although it was not a valid entry for a SSID or Password
  • TxSelectItf returned OK because it was possible to activate the WiFi module for uplink
  • TxStart retruned OK because it was possible to Trigger the Connection (WiFi Interface is active). At this Point it was not clear that the SSID or Password is wrong.

That a Connection was established via WiFi you can see in the list of sites in the “Sites / Application” area of the rapidM2M portal.

If you want to try another WiFi Network you have to write the new SSID and Password using two calls of the rM2M_RegSetString function. Use the same Designators as described above. The previously written Settings are overwritten. I.e it is only possible to write the SSID and Password for one WiFi Network to the registration memory block

Kind regards
Josef