Overview
This Tutorial provides a walk-through of the steps to perform WIFI operation using MAUI RFID3 API.
Wifi is supported only with RFD40XX/90XX premium and premium plus devices.
Create the Project
- Start by creating a new project in Visual Studio. For help, see the Create Project.
- Refer Hello RFID to prepare basic setup to work with RFID Reader and then follow this guide
Details
New WIFI API in the SDK enables user to use RFD40/RFD90 devices to perform WIFI operations. Following wifi operations can be executed.
- WIFI SCAN
- WIFI Profile creation
- WIFI Profile save
- WIFI Profile connect/disconnect.
NOTE: Certificates that needs to be used for WIFI profile needs to be installed on the device using Certificate Management feature
Wifi Scan
Call API wifiScan() to start scan. Once scan is started notification will be triggered for scan started and scan stopped events, these events are pushed to application via RfidEventsListener.
To enable the event notifications:
EventHandler eventHandler = new EventHandler();
rfidReader.Events.AddEventsListener(eventHandler);
rfidReader.Events.SetWPAEvent(true);
WiFi Scan
Call API wifiScan() to start scan. Once scan is started notification will be triggered for scan started and scan stopped events, these events are pushed to application via Readers.IRFIDReaderEventHandler
//wifi Scan
RFIDResults rFIDResults = rfidReader.Config.WifiScan();
//wifi Events
public class EventHandler : Java.Lang.Object, IRfidEventsListener, IWifiScanDataEventsListener
{
public void EventStatusNotify (RfidStatusEvents rfidStatusEvents)
{
if (rfidStatusEvents.StatusEventData.StatusEventType == STATUS_EVENT_TYPE.WpaEvent) {
string scanStatus = rfidStatusEvents.StatusEventData.WPAEventData.Type;
}
}
}
Scan data results will be pushed to application via IWifiScanDataEventsListener
public class EventHandler : Java.Lang.Object, IWifiScanDataEventsListener
{
//wifi Scan Data
public void EventWifiScanNotify(RfidWifiScanEvents wifiScanEvent)
{
IEvents.WifiScanEventData data = wifiScanEvent.WifiScanEventData;
}
}
WiFi Add Profile
Please refer the sample code to add WiFi WPA3 Personal profile
WifiProfile wifiProfile = new WifiProfile();
WifiSecureConfig wifiSecureConfig = new WifiSecureConfig();
wifiProfile.Setssid("Zebra WiFi");
wifiProfile.Setprotocol(ENUM_WIFI_PROTOCOL_TYPE.WPA2PersonalCCMP);
wifiProfile.Setpassword("zebra@12345");
wifiProfile.Setconfig(wifiSecureConfig);
RFIDResults rFIDResults = rfidReader.Config.WifiAddProfile(wifiProfile);
Please refer the sample code to add WiFi WPA2 Enterprise profile
WifiProfile wifiProfile = new WifiProfile();
WifiSecureConfig wifiSecureConfig = new WifiSecureConfig();
wifiProfile.Setssid("Zebra WiFi");
wifiProfile.Setprotocol(ENUM_WIFI_PROTOCOL_TYPE.WPA2PersonalCCMP);
wifiProfile.Setpassword("zebra@12345");
wifiProfile.Setconfig(wifiSecureConfig);
RFIDResults rFIDResults = rfidReader.Config.WifiAddProfile(wifiProfile);
WiFi Saved Profile List
This list out the number of profile saved in the Reader. As of now we can save maximum 10 profiles in reader.
IList wifiProfiles = rfidReader.Config.WifiListProfile();
WiFi Save Profile
API is used to save all the user configured wifi profiles .
rFIDResults = rfidReader.Config.WifiSaveProfile();
WiFi Delete Profile List
Please refer the sample code to delete profile from saved profile list.
rFIDResults =rfidReader.Config.WifiDeleteProfile("Zebra WiFi");
Get Installed WiFi Certificates
This API will return back the list of installed certificate in string format, by using this we can add enterprise profiles of different EAP.
IList<string> certList = rfidReader.Config.WifiGetCertificates();
wifiSecureConfig.Setcacert("ca_cert.pem");
wifiSecureConfig.Setclientcert("client_cert.pem");
wifiSecureConfig.PrivateKey = "key.pem";
WiFi Connect Non Roaming
This API used to connect the Reader WiFi from the saved profile list. Pass the SSID to connect.
RFIDResults rFIDResults=rfidReader.Config.WifiConnectNonRoaming("Zebra WiFi");
//wifi Events
public class EventHandler : Java.Lang.Object, IRfidEventsListener, IWifiScanDataEventsListener
{
public void EventStatusNotify (RfidStatusEvents rfidStatusEvents)
{
if (rfidStatusEvents.StatusEventData.StatusEventType == STATUS_EVENT_TYPE.WpaEvent) {
string scanStatus = rfidStatusEvents.StatusEventData.WPAEventData.Type;
}
}
}
WiFi Disconnect
Call WiFi disconnect API as shown in code below
RFIDResults rFIDResults = rfidReader.Config.WifiDisconnect();
//wifi Events
public class EventHandler : Java.Lang.Object, IRfidEventsListener, IWifiScanDataEventsListener
{
public void EventStatusNotify (RfidStatusEvents rfidStatusEvents)
{
if (rfidStatusEvents.StatusEventData.StatusEventType == STATUS_EVENT_TYPE.WpaEvent) {
string scanStatus = rfidStatusEvents.StatusEventData.WPAEventData.Type;
WiFiNotificationEvent(scanStatus);
}
}
public void WiFiNotificationEvent(string scanStatus)
{
switch (scanStatus)
{
case "Disconnect":
//update UI on disconnect
break;
case "Operation Failed":
break;
}
}
}
WiFi Status
WiFi Status API will return back RSSI, Address, channel, state, band, ssid name, mac, netmask as a key pair values as shown in below code
try
{
if (rfidReader != null && rfidReader.IsConnected)
{
IDictionary<string, string>? statusResults = new Dictionary<string, string>();
statusResults = rfidModel.rfidReader.Config.WifiStatusMap(statusResults); // API call
if (statusResults.Count > 0)
{
foreach (var key in statusResults.Keys)
{
System.Diagnostics.Debug.WriteLine($"Key {key} Value {statusResults[key]}");
}
}
}
}
catch (InvalidUsageException iuex)
{
System.Diagnostics.Debug.WriteLine("InvalidUsageException in Getting WifiStatus: " + iuex.Message);
}
catch (OperationFailureException ofex)
{
System.Diagnostics.Debug.WriteLine("OperationFailureException in Getting WifiStatus: " + ofex.Message);
}
WiFi ChannelBand Enable
we are supporting three enum for enbaling the respective ChannelBand.
- ENUM_WIFI_BAND.B24GHz
- ENUM_WIFI_BAND.B5GHzDFS
- ENUM_WIFI_BAND.B5GHzNONDFS
This API used to configure the wifi channels band with the enumValue of the respective enum.
Reader.Config.EnableWifiChannelBand(int enumValue);
// Enable 2,4GZ only
Reader.Config.EnableWifiChannelBand(ENUM_WIFI_BAND.B24GHz.EnumValue);
For enabling multiple channelBand the enumValue should be OR of the respective enum values.
//Enable 2.4GZ and 5GZ DFS
Reader.Config.EnableWifiChannelBand(ENUM_WIFI_BAND.B24GHz.EnumValue | ENUM_WIFI_BAND.B5GHzDFS.EnumValue);
//Enable 2.4GZ and 5GZ non DFS and 5GZ DFS
Reader.Config.EnableWifiChannelBand(ENUM_WIFI_BAND.B24GHz.EnumValue | ENUM_WIFI_BAND.B5GHzDFS.EnumValue | ENUM_WIFI_BAND.B5GHzNONDFS.EnumValue);
NOTE:
- In terms of design, user can call
enableWifiChannelBandapi only after callingwifiGetStatusat least once beforehand. - If a user attempts to enable a channelband that is not supported for the respective country, the setting will revert to the previous channel band.
- If a user attempts to enable multiple channel bands, including one that is not supported for the respective country, only the supported channel bands will be set.