Zebra Integrated RFID SDK for .NET MAUI
Setup RFID SDK
Following code segments provide the setup procedure for the RFID SDK.
IsrfidISdkApi apiInstance;
apiInstance = srfidSdkFactory.CreateRfidSdkApiInstance;
apiInstance.SrfidSetDelegate(instance);
apiInstance.SrfidSetOperationalMode((int)NativeRfidOpMode.OPMODE_MFI);
apiInstance.SrfidSubsribeForEvents((int)NotificationsRFID.READER_APPEARANCE + (int)NotificationsRFID.READER_DISAPPEARANCE + (int)NotificationsRFID.SESSION_ESTABLISHMENT + (int)NotificationsRFID.SESSION_TERMINATION);
apiInstance.SrfidSubsribeForEvents((int)NotificationsRFID.MASK_READ +
(int)NotificationsRFID.MASK_STATUS + (int)NotificationsRFID.MASK_PROXIMITY
+ (int)NotificationsRFID.MASK_TRIGGER);
apiInstance.SrfidSubsribeForEvents((int)NotificationsRFID.MASK_BATTERY +
(int)NotificationsRFID.MASK_STATUS_OPERENDSUMMARY +
(int)NotificationsRFID.MASK_TEMPERATURE +
(int)NotificationsRFID.MASK_POWER);
apiInstance.SrfidSubsribeForEvents((int)NotificationsRFID.MASK_DATABASE +
(int)NotificationsRFID.MASK_RADIOERROR);
apiInstance.SrfidEnableAvailableReadersDetection(true);
apiInstance.SrfidEnableAutomaticSessionReestablishment(true);
Get RFID SDK version
RFID SDK version information could be obtained as follows:
apiInstance.GetSrfidGetSdkVersion();
Get RFID available scanners
Following code segment outputs the paired device list. Reader must be paired with the iOS device via Bluetooth before query action
public void getNativeRfidSdkReaderList()
{
//Get avilable readers
NSMutableArray availableReaders = new NSMutableArray();
IntPtr availableHandle = availableReaders.Handle;
SrfidResult availableReaderResult =
apiInstance.SrfidGetAvailableReadersList(out availableHandle);
availableReaders =
ObjCRuntime.Runtime.GetNSObject(availableHandle);
if (availableReaderResult == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("Native
SrfidGetAvailableReadersList : Success" + availableReaders);
}
else if (availableReaderResult == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidGetAvailableReadersList ResponseError");
}
else if (availableReaderResult == SrfidResult.Failure || availableReaderResult == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("SrfidGetAvailableReadersList reder prob");
}
if (availableReaders != null)
{
foreach (srfidReaderInfo reader in NSArray.FromArray(availableReaders))
{
System.Diagnostics.Debug.WriteLine("Native Readers " + reader.ReaderName);
}
}
}
RFID Operation
Inventory
-
Inventory Start
RFID tag reading can be started as follows. Once started, tags in the range will be read continuously
public string RfidStartInventory(int readerID) { string statusMessage = null; srfidTagReportConfig tagReportConfiguration = this.RfidGetTagReportConfiguration(readerID); srfidReportConfig reportConfigaration = new srfidReportConfig(); reportConfigaration.SetIncFirstSeenTime(tagReportConfiguration.IncFirstSeenTime); reportConfigaration.SetIncLastSeenTime(tagReportConfiguration.IncLastSeenTime); reportConfigaration.SetIncPC(tagReportConfiguration.IncPC); reportConfigaration.SetIncRSSI(tagReportConfiguration.IncRSSI); reportConfigaration.SetIncPhase(tagReportConfiguration.IncPhase); reportConfigaration.SetIncChannelIndex(tagReportConfiguration.IncChannelIdx); reportConfigaration.SetIncTagSeenCount(tagReportConfiguration.IncTagSeenCount); srfidAccessConfig accessConfig = new srfidAccessConfig(); SrfidResult statusStartInventory = apiInstance.SrfidStartInventory(readerID, SrfidMemorybank.None,reportConfigaration, accessConfig, out statusMessage); if (statusMessage == "Inventory Started in Batch Mode") { return "Success"; } else { return statusStartInventory.ToString(); } }
- Inventory Stop
RFID tag reading cycle can be terminated as follows
public void RfidStopInventory() { string statusMessage = null; SrfidResult statusStopInventory = apiInstance.SrfidStopInventory(connectedReaderID, out statusMessage); if (statusStopInventory == SrfidResult.Success) { System.Diagnostics.Debug.WriteLine("SrfidStopInventorySuccess "); } else if (statusStopInventory == SrfidResult.ResponseError) { System.Diagnostics.Debug.WriteLine("SrfidStopInventoryResponseError"); } else if (statusStopInventory == SrfidResult.Failure ||statusStopInventory == SrfidResult.ResponseTimeout) { System.Diagnostics.Debug.WriteLine("SrfidStopInventory reder prob"); } }
- Tagdata Event
This event triggers when tag data is received
public override void SrfidEventReadNotify(int readerID, srfidTagData tagData) { System.Diagnostics.Debug.WriteLine("Native SrfidEventReadNotify MemoryBankData " + tagData.MemoryBankData); System.Diagnostics.Debug.WriteLine("Native SrfidEventReadNotify }
Locate Tag
Following two methods are used to locate tags.
- Start Locate Tag
Tag locating can be started as follows.
public void RfidStartTagLocationing( string epcID) { string statusMessage = null; SrfidResult statusStartTagLocation = apiInstance.SrfidStartTagLocationing(connectedReaderID, epcID, outstatusMessage); if (statusStartTagLocation == SrfidResult.Success) { System.Diagnostics.Debug.WriteLine("NativeSrfidStartTagLocationing : Success"); } else if (statusStartTagLocation == SrfidResult.ResponseError) { System.Diagnostics.Debug.WriteLine("SrfidStartTagLocationingResponseError"); } else if (statusStartTagLocation == SrfidResult.Failure ||statusStartTagLocation == SrfidResult.ResponseTimeout) { System.Diagnostics.Debug.WriteLine("SrfidStartTagLocationing reder prob"); } }
-
Stop Locate Tag
Stop locating tag
public void RfidStopTagLocationing() { string statusMessage = null; SrfidResult statusStopTagLocation = apiInstance.SrfidStopTagLocationing(connectedReaderID, out statusMessage); if (statusStopTagLocation == SrfidResult.Success) { System.Diagnostics.Debug.WriteLine("NativeSrfidStopTagLocationing : Success"); else if (statusStopTagLocation == SrfidResult.ResponseError) { System.Diagnostics.Debug.WriteLine("SrfidStopTagLocationingResponseError"); } else if (statusStopTagLocation == SrfidResult.Failure ||statusStopTagLocation == SrfidResult.ResponseTimeout) { System.Diagnostics.Debug.WriteLine("SrfidStopTagLocationingreder prob"); } }
- Proximity Event
This event will trigger when reception of a proximity notification during on-going tag locating operation from a connected RFID reader.
public override void SrfidEventProximityNotify(int readerID, intproximityPercent) { System.Diagnostics.Debug.WriteLine("Native SrfidEventProximityNotify :" + proximityPercent + " %"); }
Battery
The SDK also provides an ability to cause a particular active RFID reader to immediately send information about current battery status. The following example demonstrates both requesting and processing of asynchronous battery status related notifications.
Get battery status
public void GetBatteryStatus()
{
string statusMessage = "";
NSMutableArray batteryStatusValueList = new NSMutableArray();
IntPtr availableHandle = batteryStatusValueList.Handle;
SrfidResult srfid_result = SrfidResult.Failure;
//Retry for 2 times if we get any failure/timeout response
for (int i = 0; i < 2; i++)
{
srfid_result = apiInstance.SrfidGetBatteryStatus(connectedReaderID, out availableHandle,out statusMessage);
batteryStatusValueList = ObjCRuntime.Runtime.GetNSObject(availableHandle);
if ((srfid_result != SrfidResult.ResponseTimeout) && (srfid_result != SrfidResult.Failure))
{
break;
}
}
if (srfid_result == SrfidResult.Success)
{
foreach (srfidRfidBatteryStatusInformation info inbatteryStatusValueList)
{
System.Diagnostics.Debug.WriteLine("GetBatteryStatusBatteryStatusTittle : " + info.BatteryStatusTittle);
System.Diagnostics.Debug.WriteLine("GetBatteryStatusBatterStatusValue : " + info.BatterStatusValue);
logsString = logsString + "\n" + "Battery Status Title:" + info.BatteryStatusTittle + " value : " + info.BatterStatusValue;
}
}
else if (srfid_result == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("GetBatteryStatusResponseError");
}
else if (srfid_result == SrfidResult.Failure || srfid_result == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("GetBatteryStatus rederprob");
}
}
Request Battery Status with the event
By using following method, we can get the battery status with the event.
public void requestBatteryStatus()
{
apiInstance.SrfidRequestBatteryStatus(connectedReaderID);
}
// Event
public override void SrfidEventBatteryNotity(int readerID,srfidBatteryEvent batteryEvent)
{
logsString = "\n" + "SrfidEventBatteryNotity Power level :" +batteryEvent.PowerLevel + " %" + "\n"+ " Is charging : " +batteryEvent.IsCharging;
}
Trigger Mapping
Get Trigger Mapping
This “GetTriggerMapping” API will get the trigger key configuration
public void GetTriggerMapping( SrfidNewEnumKeylayoutType upper, SrfidNewEnumKeylayoutType lower)
{
upper = SrfidNewEnumKeylayoutType.NoAction; lower = SrfidNewEnumKeylayoutType.NoAction;
SrfidResult srfid_result = SrfidResult.Failure;
//Retry for 2 times if we get any failure/timeout response
for (int i = 0; i < 2; i++)
{
srfid_result = apiInstance.SrfidGetKeylayoutType(connectedReaderID, out upper, out lower);
if ((srfid_result != SrfidResult.ResponseTimeout) && (srfid_result != SrfidResult.Failure))
{
break;
}
}
if (srfid_result == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("GetTriggerMapping upperTriggerValue : " + upper);
System.Diagnostics.Debug.WriteLine("GetTriggerMapping lowerTriggerValue : " + lower);
}
else if (srfid_result == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("GetTriggerMapping ResponseError");
}
else if (srfid_result == SrfidResult.Failure || srfid_result == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("GetTriggerMapping reder prob");
}
}
Set Trigger Mapping
This “SetTriggerMapping” API will set the trigger key configuration
public void SetTriggerMapping(SrfidNewEnumKeylayoutType upperTrigger , SrfidNewEnumKeylayoutType lowerTrigger)
{
SrfidNewEnumKeylayoutType upperTriggerValue = upperTrigger;
SrfidNewEnumKeylayoutType lowerTriggerValue = lowerTrigger;
SrfidResult srfid_result = SrfidResult.Failure;
//Retry for 2 times if we get any failure/timeout response
for (int i = 0; i < 2; i++)
{
srfid_result = apiInstance.SrfidSetKeylayoutType(connectedReaderID, upperTriggerValue, lowerTriggerValue);
if ((srfid_result != SrfidResult.ResponseTimeout) && (srfid_result != SrfidResult.Failure))
{
break;
}
}
if (srfid_result == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("GetTriggerMapping SrfidResult.Success");
}
else if (srfid_result == SrfidResult.ResponseError)|
{
System.Diagnostics.Debug.WriteLine("GetTriggerMapping ResponseError");
}
else if (srfid_result == SrfidResult.Failure || srfid_result == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("GetTriggerMapping reder prob"); }
}
}
Access Operation
Tag Read
Following values should be passed as arguments to AccessOperationTagRead API and it will
return
a TagData object
tagId - string
tagAccessPassword - string
byteCount - short
offset - short
memoryBank – MemoryBank
- MEMORYBANK_EPC
- MEMORYBANK_TID
- MEMORYBANK_USER
- MEMORYBANK_RESV
- MEMORYBANK_NONE
- MEMORYBANK_ACCESS
- MEMORYBANK_KILL
public void AccessOperationTagRead( string tagId, SrfidMemorybank memoryBank, short offset, short length, int password)
{
string statusMessage = null;
SrfidResult tagReadResult = SrfidResult.Failure;
srfidTagData tagData = new srfidTagData();
IntPtr availableHandle = tagData.Handle;
//Retry for 2 times if we get any failure/timeout response
for (int i = 0; i < 2; i++)
{
tagReadResult = apiInstance.SrfidReadTag(connectedReaderID,tagId, out availableHandle, memoryBank, offset, length, password, outstatusMessage);
tagData = ObjCRuntime.Runtime.GetNSObject(availableHandle);
if ((tagReadResult != SrfidResult.ResponseTimeout) && (tagReadResult != SrfidResult.Failure))
{
break;
}
}
if (tagReadResult == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("Native SrfidReadTag Memory Bank Data :" + tagData.MemoryBankData);
}
else if (tagReadResult == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidReadTagResponseError");
}
else if (tagReadResult == SrfidResult.Failure || tagReadResult == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("SrfidReadTag rederprob");
}
}
Tag Lock
Following values should be passed as arguments to AccessOperationTagLock API and it will return a boolean value whether the lock operation is successful or not.
tagId - string
tagAccessPassword - string
memoryBank - MemoryBank
- MEMORYBANK_EPC
- MEMORYBANK_TID
- MEMORYBANK_USER
- MEMORYBANK_RESV
- MEMORYBANK_NONE
- MEMORYBANK_ACCESS
- MEMORYBANK_KILL
lock privilege
- READ_WRITE
- PERMANENT_LOCK
- PERMANENT_UNLOCK
- UNLOCK
public bool AccessOperationTagLock( string tagId, SrfidMemorybank memoryBank, SrfidAccesspermission accessPermission, int password)
{
string statusMessage = null;
bool status = false;
SrfidResult tagLockResult = SrfidResult.Failure;
srfidTagData tagData = new srfidTagData();
IntPtr availableHandle = tagData.Handle;
//Retry for 2 times if we get any failure/timeout response
for (int i = 0; i < 2; i++)
{
tagLockResult = apiInstance.SrfidLockTag(connectedReaderID,
tagId, out availableHandle, memoryBank, accessPermission, password, outstatusMessage);
tagData = ObjCRuntime.Runtime.GetNSObject(availableHandle);
if ((tagLockResult != SrfidResult.ResponseTimeout) && (tagLockResult != SrfidResult.Failure))
{
break;
}
}
if (tagLockResult == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("Native SrfidLockTag :"+ tagData.TagId);
status = true;
}
else if (tagLockResult == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidLockTagResponseError");
status = false;
}
else if (tagLockResult == SrfidResult.Failure || tagLockResult == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("SrfidLockTag rederprob");
status = false;
}
return status;
}
Tag Kill
Following values should be passed as arguments to AccessOperationTagKill API and it
will return a boolean value whether the kill operation is successful or not.
readerID - int
tagId – string
password - int
public bool AccessOperationTagKill(int readerID, string tagId, int password)
{
string statusMessage = null;
bool status = false;
srfidTagData tagData = new srfidTagData();
IntPtr availableHandle = tagData.Handle;
SrfidResult tagKillResult = apiInstance.SrfidKillTag(readerID,tagId, out availableHandle, password, out statusMessage);
tagData = ObjCRuntime.Runtime.GetNSObject(availableHandle);
if (tagKillResult == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("Native SrfidKillTag :Success" );
status = true;
}
else if (tagKillResult == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidKillTagResponseError");
status = false;
}
else if (tagKillResult == SrfidResult.Failure || tagKillResult == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("SrfidKillTag rederprob");
status = false;
}
return status;
}
Tag Write
The AccessOperationTagWrite method writes data to an RFID tag using a specified reader. It takes parameters like the tag ID, memory bank, offset, data, password, and a block write flag. It logs the outcome and returns true if successful, or false if it fails or encounters a response error.
public bool AccessOperationTagWrite(string tagId, SrfidMemorybank memoryBank, short offset, string data, int password, bool blockWrite) { var handler = ReaderResponseStatusEventHandler; string statusMessage = null; bool status = false; SrfidResult tagWriteResult = SrfidResult.Failure; srfidTagData tagData = new srfidTagData(); IntPtr availableHandle = tagData.Handle; //Retry for 2 times if we get any failure/timeref response for (int i = 0; i < 2; i++) { tagWriteResult = apiInstance.SrfidWriteTag(connectedReaderID, tagId, ref availableHandle, memoryBank, offset, data, password, blockWrite, ref statusMessage); tagData = ObjCRuntime.Runtime.GetNSObject
(availableHandle); if ((tagWriteResult != SrfidResult.ResponseTimeout) && (tagWriteResult != SrfidResult.Failure)) { break; } } if (tagWriteResult == SrfidResult.Success) { System.Diagnostics.Debug.WriteLine("Native SrfidWriteTag :" + tagData.TagId); status = true; ReaderResponseResult(tagWriteResult, "Tag Write Result"); } else if (tagWriteResult == SrfidResult.ResponseError) { status = false; System.Diagnostics.Debug.WriteLine("SrfidWriteTag ResponseError"); ReaderResponseResult(tagWriteResult, "Tag Write Result"); } else if (tagWriteResult == SrfidResult.Failure || tagWriteResult == SrfidResult.ResponseTimeout) { status = false; System.Diagnostics.Debug.WriteLine("SrfidWriteTag reder prob"); ReaderResponseResult(tagWriteResult, "Tag Write Result"); } return status; }
Access Sequence
This API is used to execute multiple access operations (Read, Write, etc) at the sametime
public void AccessSequence(string fillterData ,string fillteMask)
{
// initialize access criteria
srfidAccessCriteria accessCriteria = new srfidAccessCriteria();
//// setup tag filter 1
srfidTagFilter tagFilter1 = new srfidTagFilter();
tagFilter1.SetFilterMaskBank(SrfidMemorybank.Epc);
tagFilter1.SetFilterData(fillterData);
tagFilter1.SetFilterDoMatch(true);
tagFilter1.SetFilterMask(fillteMask);
tagFilter1.SetFilterMaskStartPos(2);
tagFilter1.SetFilterMatchLength(2);
accessCriteria.TagFilter1 = tagFilter1;
// Set access criteria pram for EPC read
srfidAccessParameters accesParamsEPCRead = new srfidAccessParameters();
accesParamsEPCRead.AccessOperationCode = SrfidAccessoperationcode.Read;
accesParamsEPCRead.MemoryBank = SrfidMemorybank.Epc;
accesParamsEPCRead.Offset = 2;
accesParamsEPCRead.Length = 0;
accesParamsEPCRead.Password = 00;
// Set access criteria pram for TID read
srfidAccessParameters accesParamsTIDRead = new srfidAccessParameters();
accesParamsTIDRead.AccessOperationCode = SrfidAccessoperationcode.Read;
accesParamsTIDRead.MemoryBank = SrfidMemorybank.Tid;
accesParamsTIDRead.Offset = 0;
accesParamsTIDRead.Length = 0;
accesParamsTIDRead.Password = 00;
NSMutableArray accessParametersArray = new NSMutableArray();
accessParametersArray.Add(accesParamsEPCRead);
accessParametersArray.Add(accesParamsTIDRead);
SrfidResult resultPerformAccessInSequence;
string status = null;
resultPerformAccessInSequence = apiInstance.SrfidPerformAccessInSequence(connectedReaderID, accessCriteria,NSArray.FromArray(accessParametersArray), out status);
if (resultPerformAccessInSequence == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine(" Native resultPerformAccessInSequence : Success");
}
else if (resultPerformAccessInSequence == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("resultPerformAccessInSequence ResponseError");
}
else if (resultPerformAccessInSequence == SrfidResult.Failure || resultPerformAccessInSequence == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("resultPerformAccessInSequence reder prob");
}
}
Barcode SDK
Setup Barcode SDK
Following code segments provide the setup procedure for the barcode SDK.
ISbtSdkApi iosScannerApi;
iosScannerApi = SbtSdkFactory.CreateSbtSdkApiInstance;
iosScannerApi.SbtSetDelegate(instance);
iosScannerApi.SbtSubsribeForEvents((int)(NotificationsBarcodeSDK.EVENT_SCAN
NER_APPEARANCE | NotificationsBarcodeSDK.EVENT_SCANNER_DISAPPEARANCE |
NotificationsBarcodeSDK.EVENT_SESSION_ESTABLISHMENT |
NotificationsBarcodeSDK.EVENT_SESSION_TERMINATION |
NotificationsBarcodeSDK.EVENT_BARCODE ));
iosScannerApi.SbtEnableAvailableScannersDetection(true);
iosScannerApi.SbtSetOperationalMode(0x01);//MFI
public enum NotificationsBarcodeSDK
{
EVENT_BARCODE = 1,
EVENT_IMAGE = 2,
EVENT_VIDEO = 4,
EVENT_SCANNER_APPEARANCE = 8,
EVENT_SCANNER_DISAPPEARANCE = 0x10,
EVENT_SESSION_ESTABLISHMENT = 0x20,
EVENT_SESSION_TERMINATION = 0x40,
EVENT_RAW_DATA = 0x80
}`
Get Barcode SDK Version
Barcode SDK version information can be obtained as follows:
iosScannerApi.SbtGetVersion;
Get Available Barcode SDK Scanner List
Code segments to get the available scanner list as follows.
public List GetAvailableScannerList()
{
NSMutableArray availableScanners = new NSMutableArray();
IntPtr availableHandle = availableScanners.Handle;
SbtResult availableScannerResult =
iosScannerApi.SbtGetAvailableScannersList(out availableHandle);
availableScanners = ObjCRuntime.Runtime.GetNSObject(availableHandle);
if (availableScannerResult == SbtResult.Success)
{
System.Diagnostics.Debug.WriteLine("Native Barcode SDKopModeStatus : Success");
}
else if (availableScannerResult == SbtResult.Failure)
{
System.Diagnostics.Debug.WriteLine("Native Barcode SDKopModeStatus : Failure");
}
scannerList.Clear();
if (availableScanners != null)
{
foreach (SbtScannerInfo scanner in NSArray.FromArray(availableScanners))
{
System.Diagnostics.Debug.WriteLine("");
scannerList.Add(scanner);
}
}
return scannerList;
}
Connect to Reader in Barcode SDK
Following method is used to connect to the connect to the scanner at scannerID.
public void ConnectScanner(int scannerID)
{
SbtResult scannerConnectedResult = iosScannerApi.SbtEstablishCommunicationSession(scannerID);
if (scannerConnectedResult == SbtResult.Success)
{
System.Diagnostics.Debug.WriteLine("Native Barcode SDK SbtEstablishCommunicationSession : Success");
}
else if (scannerConnectedResult == SbtResult.Failure)
{
System.Diagnostics.Debug.WriteLine("Native Barcode SDKSbtEstablishCommunicationSession : Failure");
}
}
Barcode Event
Initializes the Barcode Event.
public override void SbtEventBarcodeData(NSData barcodeData, intbarcodeType, int scannerID)
{
System.Diagnostics.Debug.WriteLine("Native Barcode SDK SbtEventBarcodeData barcodeType: " + barcodeType);
}
Switch Mode into RFID or Scanner for RFD8500
Changes the mode type of the RFD8500 device programmatically.
//Set device mode to RFID or Scanner
public void SwitchModeIntoRfidOrBarcode(DeviceMode deviceMode)
{
int attributeModeSwitch = 1664;
string attributeTypeModeSwitch = "B";
int rfidMode = 0;
int scannerMode = 1;
srfidAttribute attribute = new srfidAttribute();
attribute.SetAttrNum(attributeModeSwitch);
attribute.SetAttrType(attributeTypeModeSwitch);
if (deviceMode == DeviceMode.RFID)
{
attribute.SetAttrVal(rfidMode.ToString());
}
else
{
attribute.SetAttrVal(scannerMode.ToString());
}
string statusMessage = null;
SrfidResult setAttributeResult =
apiInstance.SrfidSetAttribute(connectedReaderID, attribute, outstatusMessage);
if (setAttributeResult == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("NativeSrfidSetAttribute : Success" );
}
else if (setAttributeResult == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidSetAttributeResponseError");
}
else if (setAttributeResult == SrfidResult.Failure || setAttributeResult == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("SrfidGetAvailableReadersList rederprob");
}
}
Regulatory Configuration(Region)
srfidGetSupportedRegions
Request to receive information regarding all supported regions from a particular RFID reader.
///
/// Get supported regions from the connected reader.
///
/// The Supported regions.
public NSMutableArray RfidGetRegionsList()
{
string statusMessage = null;
NSMutableArray supportRegionsList = new NSMutableArray();
IntPtr availableHandle = supportRegionsList.Handle;
SrfidResult statusSupportRegionList =
apiInstance.SrfidGetSupportedRegions(connectedReaderID, out availableHandle, out statusMessage);
supportRegionsList = ObjCRuntime.Runtime.GetNSObject(availableHandle);
if (statusSupportRegionList == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("Native statusSupportRegionList : Success");
}
else if (statusSupportRegionList == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("statusSupportRegionList ResponseError");
}
else if (statusSupportRegionList == SrfidResult.Failure || statusSupportRegionList == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("statusSupportRegionList reder prob");
}
return supportRegionsList;
}
srfidGetRegionInfo
Request to receive detailed information regarding one of supported regions from a particular RFID reader.
//
/// Get region infomation from the connected reader.
///
/// The region infomation./returns>
/// Reader identifier./param>
/// Region code./param>
/// If set to true/c> hopping
configurable./param>
public NSMutableArray RfidGetRegionInfo(string regionCode ,bool hoppingConfigurable)
{
string statusMessage = null;
NSMutableArray chanelListForRegion = new NSMutableArray();
NSMutableArray regionInfo = new NSMutableArray();
IntPtr availableHandle12 = regionInfo.Handle;
bool hoppingStatus = hoppingConfigurable;
int size = Marshal.SizeOf(hoppingStatus); //*settings* is a struct with some data
IntPtr pointerHoppingBool = Marshal.AllocHGlobal(size);
Marshal.StructureToPtr(hoppingStatus, pointerHoppingBool, true);
SrfidResult regionInfoResult = apiInstance.SrfidGetRegionInfo(connectedReaderID,
regionCode, out availableHandle12, out pointerHoppingBool, out statusMessage);
regionInfo = ObjCRuntime.Runtime.GetNSObject(availableHandle12);
if (regionInfoResult == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("Native SrfidGetRegionInfo : Success Current : ",regionInfo);
object[] enableChannels = new object[regionInfo.Count];
if (regionInfo.Count > 0)
{
int i = 0;
foreach (NSObject channel in regionInfo)
{
enableChannels[i++] = channel;
chanelListForRegion.Add(channel);
}
}
}
else if (regionInfoResult == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidGetRegionInfo ResponseError");
}
else if (regionInfoResult == SrfidResult.InvalidParams)
{
System.Diagnostics.Debug.WriteLine("SrfidGetRegionInfo Invalid Prams");
}
else if (regionInfoResult == SrfidResult.Failure || regionInfoResult == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("SrfidGetRegionInfo reder prob");
}
return chanelListForRegion;
}
srfidGetRegulatoryConfig
Request to receive regulatory parameters from a particular RFID reader.
///
/// Get the regulatory configuration of the connected reader.
///
/// Regulatory config.
/// Reader identifier./param>
public srfidRegulatoryConfig RfidGetRegulatoryConfig()
{
string statusMessage = null;
srfidRegulatoryConfig config = new srfidRegulatoryConfig();
IntPtr availableHandle = config.Handle;
SrfidResult regulatoryConfigResult =
apiInstance.SrfidGetRegulatoryConfig(connectedReaderID, out availableHandle, out statusMessage);
config = ObjCRuntime.Runtime.GetNSObject(availableHandle);
if (regulatoryConfigResult == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("Native statusSupportRegionList : Success");
}
else if (regulatoryConfigResult == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("statusSupportRegionList ResponseError");
}
else if (regulatoryConfigResult == SrfidResult.Failure || regulatoryConfigResult == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("statusSupportRegionList reder prob");
}
return config;
}
srfidSetRegulatoryConfig
Request to set regulatory parameters on a particular RFID reader.
///
/// Set the regulatory configuration of the connected reader.
///
/// Regulatory configuration/returns>
/// Regulatory config./param>
public string RfidSetRegulatoryConfig(srfidRegulatoryConfig regulatoryConfig)
{
string statusMessage = null;
SrfidResult regulatoryConfigStatus =
apiInstance.SrfidSetRegulatoryConfig(connectedReaderID, regulatoryConfig, out statusMessage);
if (regulatoryConfigStatus == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("Native statusSupportRegionList : Success Current : ");
statusMessage = "Successfully Regulatory Settings Applied!";
}
else if (regulatoryConfigStatus == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("statusSupportRegionList ResponseError");
statusMessage = "Response Error";
}
else if (regulatoryConfigStatus == SrfidResult.Failure || regulatoryConfigStatus == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("statusSupportRegionList reder prob");
statusMessage = "Reader Problem!";
}
return statusMessage;
}
WLAN
WLAN Scan Event
The SrfidEventWifiScan method processes Wi-Fi scan results from an RFID reader by adding valid wlan scan data to a list.
public override void SrfidEventWifiScan(int readerID, srfidWlanScanList wlanScanObject)
{
if (wlanScanObject.WlanSsid != null)
{
wifiScanListArray.Add(wlanScanObject);
}
var handler = WlanScanEvent;
if (handler != null)
{
handler.Invoke(readerID, wlanScanObject);
wifiScanListArray.Append(wlanScanObject);
}
}
WLAN Scan List
The GetWlanScanList method retrieves available WLAN .
public NSMutableArray GetWlanScanList()
{
string statusMessage = null;
NSMutableArray wlanScanList = new NSMutableArray();
IntPtr availableHandle = wlanScanList.Handle;
SrfidResult wlanScanListResult = apiInstance.SrfidGetWlanScanList(connectedReaderID, ref statusMessage);
wlanScanList = ObjCRuntime.Runtime.GetNSObject(availableHandle);
if (wlanScanListResult == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("Native SrfidGetWlanScanList : Success");
}
else if (wlanScanListResult == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidGetWlanScanList ResponseError");
logsString = "Response Error";
}
else if (wlanScanListResult == SrfidResult.InvalidParams)
{
System.Diagnostics.Debug.WriteLine("SrfidGetWlanScanList Invalid Prams");
logsString = "Invalid Parameters";
}
else if (wlanScanListResult == SrfidResult.Failure || wlanScanListResult == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("SrfidGetWlanScanList reder prob");
logsString = "Reader failure : Response timeout";
}
return wlanScanList;
}
WLAN Enable/ Disable
The RfidWifiEnableDisable method enables or disables the WiFi feature on an RFID device.
public void RfidWifiEnableDisable(bool state)
{
string statusMessage = null;
SrfidResult wifiState = apiInstance.SrfidWifiEnableDisable(connectedReaderID, state, ref statusMessage);
if (wifiState == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("Native SrfidWifiEnableDisable : Success");
if (state == true)
{
logsString = "WiFi feature enabled Successfully";
}
else
{
logsString = "WiFi feature disabled Successfully";
}
}
else if (wifiState == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidWifiEnableDisable ResponseError");
logsString = "Response Error";
}
else if (wifiState == SrfidResult.InvalidParams)
{
System.Diagnostics.Debug.WriteLine("SrfidWifiEnableDisable Invalid Prams");
logsString = "Invalid Parameters";
}
else if (wifiState == SrfidResult.Failure || wifiState == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("SrfidWifiEnableDisable reder prob");
logsString = "Reader failure : Response timeout";
}
}
Get WLAN Status
The GetWiFiStatus method retrieves the current WiFi status from an RFID device.
public string GetWiFiStatus()
{
string statusMessage = null;
srfidGetWifiStatusInfo wlanInfo = new srfidGetWifiStatusInfo();
IntPtr availableHandle = wlanInfo.Handle;
SrfidResult wlanScanStatus = SrfidResult.Failure;
//Retry for 2 times if we get any failure/timeref response
for (int i = 0; i < 2; i++)
{
wlanScanStatus = apiInstance.SrfidGetWifiStatus(connectedReaderID, ref availableHandle, ref statusMessage);
wlanInfo = ObjCRuntime.Runtime.GetNSObject(availableHandle);
if ((wlanScanStatus != SrfidResult.ResponseTimeout) && (wlanScanStatus != SrfidResult.Failure))
{
break;
}
}
if (wlanScanStatus == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("Native SrfidGetWifiStatus : Success");
logsString = "Wifi Status: " + wlanInfo.WifiStatus;
return wlanInfo.WifiStatus;
}
else if (wlanScanStatus == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidGetWifiStatus ResponseError");
logsString = "Response Error";
return wlanInfo.WifiStatus;
}
else if (wlanScanStatus == SrfidResult.InvalidParams)
{
System.Diagnostics.Debug.WriteLine("SrfidGetWifiStatus Invalid Prams");
logsString = "Invalid Parameters";
return wlanInfo.WifiStatus;
}
else if (wlanScanStatus == SrfidResult.Failure || wlanScanStatus == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("SrfidGetWifiStatus reder prob");
logsString = "Reader failure : Response timeout";
return wlanInfo.WifiStatus;
}
else
{
return wlanInfo.WifiStatus;
}
}
Get WLAN Profile List
The GetWlanProfileList method attempts to retrieve a list of WLAN profiles from an RFID device.
public SrfidResult GetWlanProfileList(NSMutableArray wlanProfileList)
{
string statusMessage = null;
SrfidResult srfid_result = SrfidResult.Failure;
for (int i = 0; i < 2; i++)
{
srfid_result = apiInstance.SrfidGetWlanProfileList(connectedReaderID, ref wlanProfileList, ref statusMessage);
if ((srfid_result != SrfidResult.ResponseTimeout) && (srfid_result != SrfidResult.Failure))
{
break;
}
}
if (srfid_result == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("SrfidGetWlanProfileList sucess");
}
else if (srfid_result == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidGetWlanProfileList SRFID_RESULT_RESPONSE_ERROR");
}
else if (srfid_result == SrfidResult.Failure || srfid_result == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("SrfidGetWlanProfileList readerProblem");
}
return srfid_result;
}
Save WLAN Profile
The SaveWlanProfile method saves the current WLAN profile configuration to an RFID device.
public SrfidResult SaveWlanProfile()
{
string statusMessage = null;
SrfidResult saveWlanProfile = apiInstance.SrfidWlanSaveProfile(connectedReaderID, ref statusMessage);
if (saveWlanProfile == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("Native SrfidWlanSaveProfile : Success");
}
else if (saveWlanProfile == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidWlanSaveProfile ResponseError");
logsString = "Response Error";
}
else if (saveWlanProfile == SrfidResult.InvalidParams)
{
System.Diagnostics.Debug.WriteLine("SrfidWlanSaveProfile Invalid Prams");
logsString = "Invalid Parameters";
}
else if (saveWlanProfile == SrfidResult.Failure || saveWlanProfile == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("SrfidWlanSaveProfile reder prob");
logsString = "Reader failure : Response timeout";
}
return saveWlanProfile;
}
Add WLAN Profile
The AddWlanProfile method attempts to add a WLAN profile to an RFID device using the provided configuration.
public SrfidResult AddWlanProfile(sRfidAddProfileConfig profileConfig)
{
string statusMessage = null;
SrfidResult addWlanProfile = apiInstance.SrfidAddWlanProfile(connectedReaderID, profileConfig, ref statusMessage);
if (addWlanProfile == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("Native SrfidAddWlanProfile : Success");
logsString = "Success";
}
else if (addWlanProfile == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidAddWlanProfile ResponseError");
logsString = "Response Error";
}
else if (addWlanProfile == SrfidResult.InvalidParams)
{
System.Diagnostics.Debug.WriteLine("SrfidAddWlanProfile Invalid Prams");
logsString = "Invalid Parameters";
}
else if (addWlanProfile == SrfidResult.Failure || addWlanProfile == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("SrfidAddWlanProfile reder prob");
logsString = "Reader failure : Response timeout";
}
return addWlanProfile;
}
Remove WLAN Profile
The RemoveWlanProfile method removes a WLAN profile identified by its SSID from an RFID device.
public void RemoveWlanProfile(string ssidWlan)
{
string statusMessage = null;
SrfidResult removeWlanProfile = apiInstance.SrfidRemoveWlanProfile(connectedReaderID, ssidWlan, ref statusMessage);
saved_networks_list.Remove(ssidWlan);
if (removeWlanProfile == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine(“Native SrfidRemoveWlanProfile : Success”);
}
else if (removeWlanProfile == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine(“SrfidRemoveWlanProfile ResponseError”);
}
else if (removeWlanProfile == SrfidResult.InvalidParams)
{
System.Diagnostics.Debug.WriteLine(“SrfidRemoveWlanProfile Invalid Prams”);
logsString = “Invalid Parameters”;
}
else if (removeWlanProfile == SrfidResult.Failure || removeWlanProfile == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine(“SrfidRemoveWlanProfile reder prob”);
logsString = “Reader failure : Response timeout”;
}
}
Connect WLAN Profile
The ConnectWlanProfile method attempts to connect to a WLAN profile identified by its SSID.
public void RemoveWlanProfile(string ssidWlan)
{
string statusMessage = null;
SrfidResult removeWlanProfile = apiInstance.SrfidRemoveWlanProfile(connectedReaderID, ssidWlan, ref statusMessage);
saved_networks_list.Remove(ssidWlan);
if (removeWlanProfile == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine(“Native SrfidRemoveWlanProfile : Success”);
}
else if (removeWlanProfile == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine(“SrfidRemoveWlanProfile ResponseError”);
}
else if (removeWlanProfile == SrfidResult.InvalidParams)
{
System.Diagnostics.Debug.WriteLine(“SrfidRemoveWlanProfile Invalid Prams”);
logsString = “Invalid Parameters”;
}
else if (removeWlanProfile == SrfidResult.Failure || removeWlanProfile == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine(“SrfidRemoveWlanProfile reder prob”);
logsString = “Reader failure : Response timeout”;
}
}
Get WLAN Certificates List
TThe GetWlanCertificatesList method retrieves a list of WLAN certificates from an RFID device.
public SrfidResult GetWlanCertificatesList(NSMutableArray wlanCertificatesList)
{
string statusMessage = null;
IntPtr availableHandle = wlanCertificatesList.Handle;
SrfidResult getWlanCertificatesListApiCall = apiInstance.SrfidGetWlanCertificatesList(connectedReaderID, ref availableHandle, ref statusMessage);
if (getWlanCertificatesListApiCall == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("SrfidGetWlanCertificatesList Success");
logsString = "Success";
}
else if (getWlanCertificatesListApiCall == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidGetWlanCertificatesList ResponseError");
logsString = "Response Error";
}
else if (getWlanCertificatesListApiCall == SrfidResult.Failure || getWlanCertificatesListApiCall == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("SrfidGetWlanCertificatesList Failure");
logsString = "Failure";
}
return getWlanCertificatesListApiCall;
}
Disconnect WLAN Profile
The DisconnectWlanProfile method disconnects an RFID device from the current WLAN profile.
public SrfidResult DisconnectWlanProfile()
{
string statusMessage = null;
SrfidResult disconnectWlanProfile = apiInstance.SrfidWlanDisConnectProfile(connectedReaderID, ref statusMessage);
if (disconnectWlanProfile == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("Native disconnectWlanProfile : Success");
}
else if (disconnectWlanProfile == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("disconnectWlanProfile ResponseError");
}
else if (disconnectWlanProfile == SrfidResult.InvalidParams)
{
System.Diagnostics.Debug.WriteLine("disconnectWlanProfile Invalid Prams");
logsString = "Invalid Parameters";
}
else if (disconnectWlanProfile == SrfidResult.Failure || disconnectWlanProfile == SrfidResult.ResponseTimeout)
{
System.Diagnostics.Debug.WriteLine("disconnectWlanProfile reder prob");
ogsString = "Reader failure : Response timeout";
}
return disconnectWlanProfile;
}
Endpoint Configuration
Add Endpoint Configuration
The AddEndpointConfig method will add an endpoint for the RFID reader.
//Create RfidSetEndPointConfig object
private RfidSetEndPointConfig ConfigureEndPoint()
{
RfidSetEndPointConfig config = new RfidSetEndPointConfig();
string operation;
if (activate)
{
operation = "activate";
}
else
{
if (Update)
{
operation = "update";
}
else
{
operation = "new";
}
}
config.SetOperation(new NSString(operation));
config.SetEpname(new NSString("endpoint name"));
config.SetType(new NSString("soti"));
config.SetProtocol(new NSString("MQTT"));
config.SetUrl(new NSString("url"));
config.SetPort(new NSString("PORT Number"));
config.SetKeepalive(new NSString("Keepa live time"));
config.SetTenantid(new NSString("Tenant id"));
config.SetRcdelaymin(new NSString("Reconnect delay min time"));
config.SetRcdelaymax(new NSString("Reconnect delay max time"));
config.SetHostvfy(new NSString("hostVfy"));
// Handle optional fields
config.SetUserName(new NSString("username"));
config.SetPassword(new NSString("password"));
// Set clean session options
if (cleanSession)
{
config.SetEncleanss(true);
config.SetDscleanss(false);
}
else
{
config.SetEncleanss(false);
config.SetDscleanss(true);
}
//If setType MDM
//If setType SOTI no need to do bellow steps
//if setType MDM and setProtocol MQTT
config.SetSubname(new NSString("sub name"));
config.setPub1name(new NSString("Pub1 name"));
config.setPub2name(new NSString("Pub2 name"));
//if setType MDM and setProtocol MQTT_TLS
config.setCacertname(new NSString("CA certificate name"));
config.setCertname(new NSString("Certificate name"));
config.setKeyname(new NSString("Key name"));
return config;
}
public SrfidResult AddEndpointConfig (RfidSetEndPointConfig endPointConfig)
{
SrfidResult addEPconfig = SrfidResult.Failure;
string statusMsg = null;
try
{
for (int i = 0; i < 2; i++)
{
addEPconfig = apiInstance.SrfidSetEndPointConfig(connectedReaderID, endPointConfig, ref statusMsg);
if (addEPconfig != SrfidResult.ResponseTimeout && addEPconfig != SrfidResult.Failure)
{
break;
}
}
if (addEPconfig == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("SrfidSetEndPointConfig Success");
}
else if (addEPconfig == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidSetEndPointConfig ResponseError");
}
else if (addEPconfig == SrfidResult.ResponseTimeout || addEPconfig == SrfidResult.Failure)
{
System.Diagnostics.Debug.WriteLine("SrfidSetEndPointConfig ResponseTimeout/Failure");
}
return addEPconfig;
} catch (Exception e)
{
System.Diagnostics.Debug.WriteLine("SrfidSetEndPointConfig Exception " + e);
return addEPconfig;
}
}
Get Endpoint Configuration List
The GetEndpointList method retrieves a list of endpoints from an RFID reader.
public SrfidResult GetEndpointList(NSMutableArray endpointList)
{
SrfidResult getEndpointList = SrfidResult.Failure;
string statusMsg = null;
IntPtr availableHandle = endpointList.Handle;
try
{
for (int i = 0; i < 2; i++)
{
getEndpointList = apiInstance.SrfidGetEndPointList(connectedReaderID, ref availableHandle, ref statusMsg);
endpointList = ObjCRuntime.Runtime.GetNSObject(availableHandle);
if (getEndpointList != SrfidResult.ResponseTimeout && getEndpointList != SrfidResult.Failure)
{
break;
}
}
if (getEndpointList == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("SrfidGetEndPointList Success");
}
else if (getEndpointList == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidGetEndPointList ResponseError");
}
else if (getEndpointList == SrfidResult.ResponseTimeout || getEndpointList == SrfidResult.Failure)
{
System.Diagnostics.Debug.WriteLine("SrfidGetEndPointList ResponseTimeout/Failure");
}
System.Diagnostics.Debug.WriteLine("Returning the EP List");
return getEndpointList;
} catch (Exception e)
{
System.Diagnostics.Debug.WriteLine("SrfidGetEndPointList Exception " + e);
return getEndpointList;
}
}
Save Endpoint Configuration
The SaveEndpointConfig method is responsible for saving the current endpoint configuration to an RFID reader.
public SrfidResult SaveEndpointConfig()
{
SrfidResult saveEPConfig = SrfidResult.Failure;
string statusMsg = null;
try
{
for (int i = 0; i < 2; i++)
{
saveEPConfig = apiInstance.SrfidSaveEndPointConfig(connectedReaderID, ref statusMsg);
if (saveEPConfig == SrfidResult.ResponseTimeout || saveEPConfig == SrfidResult.Failure)
{
break;
}
}
if (saveEPConfig == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("SrfidSaveEndPointConfig Success");
}
else if (saveEPConfig == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidSaveEndPointConfig ResponseError");
}
else if (saveEPConfig == SrfidResult.ResponseTimeout || saveEPConfig == SrfidResult.Failure)
{
System.Diagnostics.Debug.WriteLine("SrfidSaveEndPointConfig ResponseTimeout/Failure");
}
return saveEPConfig;
} catch (Exception e)
{
System.Diagnostics.Debug.WriteLine("SrfidSaveEndPointConfig Exception " + e);
return saveEPConfig;
}
}
Remove Endpoint Configuration
The RemoveEndpoint method is designed to delete an endpoint configuration from an RFID reader.
public SrfidResult RemoveEndpoint(NSString epName)
{
SrfidResult removeEP = SrfidResult.Failure;
string statusMsg = null;
try
{
for (int i = 0; i < 2; i++)
{
removeEP = apiInstance.SrfidRemoveEndPointConfig(connectedReaderID, epName, ref statusMsg);
if (removeEP == SrfidResult.ResponseTimeout || removeEP == SrfidResult.Failure)
{
break;
}
}
if (removeEP == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("SrfidRemoveEndPointConfig Success");
}
else if (removeEP == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidRemoveEndPointConfig ResponseError");
}
else if (removeEP == SrfidResult.ResponseTimeout || removeEP == SrfidResult.Failure)
{
System.Diagnostics.Debug.WriteLine("SrfidRemoveEndPointConfig ResponseTimeout/Failure");
}
return removeEP;
} catch (Exception e)
{
System.Diagnostics.Debug.WriteLine("SrfidRemoveEndPointConfig Exception " + e);
return removeEP;
}
}
Get Endpoint Configuration
The GetEndpointConfig method retrieves the configuration for a specific endpoint on an RFID reader.
public SrfidResult GetEndpointConfig(NSString epName, srfidGetEndPointConfig epConfig)
{
SrfidResult getEPConfig = SrfidResult.Failure;
string statusMsg = null;
IntPtr availableHandle = epConfig.Handle;
try
{
getEPConfig = apiInstance.SrfidGetEndpointConfig(connectedReaderID, epName, ref availableHandle, ref statusMsg);
epConfig = ObjCRuntime.Runtime.GetNSObject(availableHandle);
if (getEPConfig == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("SrfidGetEndpointConfig Success");
}
else if (getEPConfig == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidGetEndpointConfig ResponseError");
}
else if (getEPConfig == SrfidResult.ResponseTimeout || getEPConfig == SrfidResult.Failure)
{
System.Diagnostics.Debug.WriteLine("SrfidGetEndpointConfig ResponseTimeout/Failure");
}
return getEPConfig;
} catch (Exception e)
{
System.Diagnostics.Debug.WriteLine("SrfidGetEndpointConfig Exception " + e);
return getEPConfig;
}
}
Get Active Endpoint Configuration List
The GetActiveEndpoints method is designed to retrieve a list of active endpoints from an RFID reader.
public SrfidResult GetActiveEndpoints(srfidGetActiveEnpoints activeEPs)
{
SrfidResult getActiveEPs = SrfidResult.Failure;
string statusMsg = null;
IntPtr availableHandle = activeEPs.Handle;
try
{
for (int i = 0; i < 2; i++)
{
getActiveEPs = apiInstance.SrfidGetActiveEndPoints(connectedReaderID, ref availableHandle, ref statusMsg);
activeEPs = ObjCRuntime.Runtime.GetNSObject(availableHandle);
if (getActiveEPs == SrfidResult.ResponseTimeout || getActiveEPs == SrfidResult.Failure)
{
break;
}
}
if (getActiveEPs == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("SrfidGetActiveEndPoints Success");
}
else if (getActiveEPs == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidGetActiveEndPoints ResponseError");
}
else if (getActiveEPs == SrfidResult.ResponseTimeout || getActiveEPs == SrfidResult.Failure)
{
System.Diagnostics.Debug.WriteLine("SrfidGetActiveEndPoints ResponseTimeout/Failure");
}
return getActiveEPs;
} catch (Exception e)
{
System.Diagnostics.Debug.WriteLine("SrfidGetActiveEndPoints Exception " + e);
return getActiveEPs;
}
}
Certificate Management
Add New Certificate
The AddNewCertificate method attempts to add a new certificate to the RFID reader via a specified file.
public SrfidResult AddNewCertificate (NSString fileName, NSUrl filePath)
{
SrfidResult addNewCert = SrfidResult.Failure;
string statusMsg = null;
addNewCert = apiInstance.SrfidAddCertificate(connectedReaderID, fileName, filePath, ref statusMsg);
if (addNewCert == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("SrfidAddCertificate Success");
}
else if (addNewCert == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidAddCertificate ResponseError");
}
else if (addNewCert == SrfidResult.ResponseTimeout || addNewCert == SrfidResult.Failure)
{
System.Diagnostics.Debug.WriteLine("SrfidAddCertificate ResponseTimeout/Failure");
}
return addNewCert;
}
Save Certificate
The SaveCertificate method attempts to save a certificate to the connected RFID reader.
public SrfidResult SaveCertificate()
{
string statusMsg = null;
SrfidResult saveCertificate = SrfidResult.Failure;
for (int i = 0; i < 2; i++)
{
saveCertificate = apiInstance.SrfidSaveCertificate(connectedReaderID, ref statusMsg);
if (saveCertificate == SrfidResult.ResponseTimeout || saveCertificate == SrfidResult.Failure)
{
break;
}
}
if (saveCertificate == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("SrfidSaveCertificate Success");
}
else if (saveCertificate == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidSaveCertificate ResponseError");
}
else if (saveCertificate == SrfidResult.ResponseTimeout || saveCertificate == SrfidResult.Failure)
{
System.Diagnostics.Debug.WriteLine("SrfidSaveCertificate ResponseTimeout/Failure");
}
return saveCertificate;
}
Remove Certificate
The RemoveCertificate method is designed to remove a specified certificate from the connected RFID reader.
public SrfidResult RemoveCertificate (NSString fileName)
{
string statusMsg = null;
SrfidResult removeCertificate = SrfidResult.Failure;
for (int i = 0; i < 2; i++)
{
removeCertificate = apiInstance.SrfidRemoveCertificate(connectedReaderID, fileName, ref statusMsg);
if (removeCertificate == SrfidResult.ResponseTimeout || removeCertificate == SrfidResult.Failure)
{
break;
}
}
if (removeCertificate == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("SrfidRemoveCertificate Success");
}
else if (removeCertificate == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidRemoveCertificate ResponseError");
}
else if (removeCertificate == SrfidResult.ResponseTimeout || removeCertificate == SrfidResult.Failure)
{
System.Diagnostics.Debug.WriteLine("SrfidRemoveCertificate ResponseTimeout/Failure");
}
return removeCertificate;
}
Remove All Certificates
The RemoveAllCertificates method is designed to remove all certificates from the connected RFID reader.
public SrfidResult RemoveAllCertificates()
{
string statusMsg = null;
SrfidResult removeAllCertificate = SrfidResult.Failure;
for (int i = 0; i < 2; i++)
{
removeAllCertificate = apiInstance.SrfidRemoveAllCertificates(connectedReaderID, ref statusMsg);
if (removeAllCertificate == SrfidResult.ResponseTimeout || removeAllCertificate == SrfidResult.Failure)
{
break;
}
}
if (removeAllCertificate == SrfidResult.Success)
{
System.Diagnostics.Debug.WriteLine("SrfidRemoveCertificate Success");
}
else if (removeAllCertificate == SrfidResult.ResponseError)
{
System.Diagnostics.Debug.WriteLine("SrfidRemoveCertificate ResponseError");
}
else if (removeAllCertificate == SrfidResult.ResponseTimeout || removeAllCertificate == SrfidResult.Failure)
{
System.Diagnostics.Debug.WriteLine("SrfidRemoveCertificate ResponseTimeout/Failure");
}
return removeAllCertificate;
}