diff --git a/CS108iOSClient.xcodeproj/project.pbxproj b/CS108iOSClient.xcodeproj/project.pbxproj index 909e3a6..8581db3 100644 --- a/CS108iOSClient.xcodeproj/project.pbxproj +++ b/CS108iOSClient.xcodeproj/project.pbxproj @@ -49,6 +49,7 @@ CABA71662132631F00D15BB1 /* CSLCircularQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = CABA71602132631F00D15BB1 /* CSLCircularQueue.m */; }; CABA71672132631F00D15BB1 /* CSLBlePacket.m in Sources */ = {isa = PBXBuildFile; fileRef = CABA71642132631F00D15BB1 /* CSLBlePacket.m */; }; CABA71682132631F00D15BB1 /* CSLBleInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = CABA71652132631F00D15BB1 /* CSLBleInterface.m */; }; + CAD9B73F248F570100AE01A8 /* CSLReaderFrequency.m in Sources */ = {isa = PBXBuildFile; fileRef = CAD9B73E248F570100AE01A8 /* CSLReaderFrequency.m */; }; CADDF6AA21DDF41E00E05D75 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CADDF6A921DDF41E00E05D75 /* CoreGraphics.framework */; }; CAECD0C1214973EF003321CF /* CSLRfidDemoApp.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CAECD0C0214973EF003321CF /* CSLRfidDemoApp.storyboard */; }; CAF5CC2821626F1500C420EF /* CSLReaderBattery.m in Sources */ = {isa = PBXBuildFile; fileRef = CAF5CC2721626F1500C420EF /* CSLReaderBattery.m */; }; @@ -134,6 +135,8 @@ CABA71632132631F00D15BB1 /* CSLBleInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSLBleInterface.h; sourceTree = ""; }; CABA71642132631F00D15BB1 /* CSLBlePacket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSLBlePacket.m; sourceTree = ""; }; CABA71652132631F00D15BB1 /* CSLBleInterface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSLBleInterface.m; sourceTree = ""; }; + CAD9B73D248F570000AE01A8 /* CSLReaderFrequency.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSLReaderFrequency.h; sourceTree = ""; }; + CAD9B73E248F570100AE01A8 /* CSLReaderFrequency.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSLReaderFrequency.m; sourceTree = ""; }; CADDF6A921DDF41E00E05D75 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; CAECD0C0214973EF003321CF /* CSLRfidDemoApp.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = CSLRfidDemoApp.storyboard; sourceTree = ""; }; CAF5CC2621626F1500C420EF /* CSLReaderBattery.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSLReaderBattery.h; sourceTree = ""; }; @@ -241,6 +244,8 @@ CA78737921514DC9009B7FE6 /* model */ = { isa = PBXGroup; children = ( + CAD9B73D248F570000AE01A8 /* CSLReaderFrequency.h */, + CAD9B73E248F570100AE01A8 /* CSLReaderFrequency.m */, CA78737A21514E61009B7FE6 /* CSLRfidAppEngine.h */, CA78737B21514E61009B7FE6 /* CSLRfidAppEngine.m */, CA78737D21543B6F009B7FE6 /* CSLReaderSettings.h */, @@ -470,6 +475,7 @@ 4272751123E91EDD008485F6 /* CSLAboutVC.swift in Sources */, 42B903CF23D7C8180041713C /* CSLSettingsVC.swift in Sources */, CA4E78E6213528FC0035F075 /* CSLBleReader.m in Sources */, + CAD9B73F248F570100AE01A8 /* CSLReaderFrequency.m in Sources */, 4296980623EA5B610023BC8B /* main.swift in Sources */, 4234D14E24200F2800FA6396 /* GaugeView.swift in Sources */, CA78737F21543B6F009B7FE6 /* CSLReaderSettings.m in Sources */, @@ -621,7 +627,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = S3.0; + MARKETING_VERSION = S3.1; PRODUCT_BUNDLE_IDENTIFIER = com.csl.CS108iOSClient; PRODUCT_NAME = CS108Swift; SWIFT_OBJC_BRIDGING_HEADER = "CS108iOSClient/ViewControllers/CS108iOSClient-Bridging-Header.h"; @@ -649,7 +655,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = S3.0; + MARKETING_VERSION = S3.1; PRODUCT_BUNDLE_IDENTIFIER = com.csl.CS108iOSClient; PRODUCT_NAME = CS108Swift; SWIFT_OBJC_BRIDGING_HEADER = "CS108iOSClient/ViewControllers/CS108iOSClient-Bridging-Header.h"; diff --git a/CS108iOSClient.xcworkspace/xcuserdata/TurtleMac01.xcuserdatad/UserInterfaceState.xcuserstate b/CS108iOSClient.xcworkspace/xcuserdata/TurtleMac01.xcuserdatad/UserInterfaceState.xcuserstate index ccb9056..055c97c 100644 Binary files a/CS108iOSClient.xcworkspace/xcuserdata/TurtleMac01.xcuserdatad/UserInterfaceState.xcuserstate and b/CS108iOSClient.xcworkspace/xcuserdata/TurtleMac01.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/CS108iOSClient/CSLReader/CSLBleReader+AccessControl.m b/CS108iOSClient/CSLReader/CSLBleReader+AccessControl.m index 7c1131e..50d761e 100644 --- a/CS108iOSClient/CSLReader/CSLBleReader+AccessControl.m +++ b/CS108iOSClient/CSLReader/CSLBleReader+AccessControl.m @@ -80,7 +80,7 @@ - (BOOL) TAGMSK_DESC_SEL:(Byte)desc_idx { for (int i=0;i= 3) //command response + command begin + command end break; - [NSThread sleepForTimeInterval:0.1f]; + [NSThread sleepForTimeInterval:0.001f]; } if ([self.cmdRespQueue count] >= 3) @@ -995,7 +995,7 @@ - (BOOL) sendHostCommandRead { for (int i=0;i= 1) //command response + command begin + command end break; - [NSThread sleepForTimeInterval:0.1f]; + [NSThread sleepForTimeInterval:0.001f]; } if ([self.cmdRespQueue count] >= 1) @@ -1061,7 +1061,7 @@ - (BOOL) sendHostCommandSearch { for (int i=0;i= 1) //command response + command begin + command end break; - [NSThread sleepForTimeInterval:0.1f]; + [NSThread sleepForTimeInterval:0.001f]; } if ([self.cmdRespQueue count] >= 1) @@ -1127,7 +1127,7 @@ - (BOOL) sendHostCommandLock { for (int i=0;i= 1) //command response + command begin + command end break; - [NSThread sleepForTimeInterval:0.1f]; + [NSThread sleepForTimeInterval:0.001f]; } if ([self.cmdRespQueue count] >= 1) @@ -1202,7 +1202,7 @@ - (BOOL) setEpcMatchConfiguration:(BOOL)match_enable matchOn:(BOOL)epc_notEpc ma for (int i=0;i= 2) break; - [NSThread sleepForTimeInterval:0.1f]; + [NSThread sleepForTimeInterval:0.001f]; } if ([self.cmdRespQueue count] < 2) { @@ -1580,7 +1580,7 @@ - (BOOL) startTagMemoryWrite:(MEMORYBANK)bank dataOffset:(UInt16)offset dataCoun for (int i=0;i= 2) break; - [NSThread sleepForTimeInterval:0.1f]; + [NSThread sleepForTimeInterval:0.001f]; } if ([self.cmdRespQueue count] < 2) { @@ -1647,7 +1647,7 @@ - (BOOL) startTagSearch:(MEMORYBANK)mask_bank maskPointer:(UInt16)mask_pointer m for (int i=0;i= 1) break; - [NSThread sleepForTimeInterval:0.1f]; + [NSThread sleepForTimeInterval:0.001f]; } if ([self.cmdRespQueue count] < 1) { @@ -1775,7 +1775,7 @@ - (BOOL) TAGACC_LOCKCFG:(UInt32)lockCommandConfigBits { for (int i=0;i= 2) break; - [NSThread sleepForTimeInterval:0.1f]; + [NSThread sleepForTimeInterval:0.001f]; } if ([self.cmdRespQueue count] < 2) { diff --git a/CS108iOSClient/CSLReader/CSLBleReader.h b/CS108iOSClient/CSLReader/CSLBleReader.h index ee6f0e0..7a69eea 100644 --- a/CS108iOSClient/CSLReader/CSLBleReader.h +++ b/CS108iOSClient/CSLReader/CSLBleReader.h @@ -11,13 +11,14 @@ #import "CSLBleTag.h" #import "CSLReaderBattery.h" #import "CSLReaderBarcode.h" +#import "CSLReaderFrequency.h" -#define COMMAND_TIMEOUT_1S 10 -#define COMMAND_TIMEOUT_2S 20 -#define COMMAND_TIMEOUT_3S 30 -#define COMMAND_TIMEOUT_4S 40 -#define COMMAND_TIMEOUT_5S 50 -#define COMMAND_TIMEOUT_10S 100 +#define COMMAND_TIMEOUT_1S 1000 +#define COMMAND_TIMEOUT_2S 2000 +#define COMMAND_TIMEOUT_3S 3000 +#define COMMAND_TIMEOUT_4S 4000 +#define COMMAND_TIMEOUT_5S 5000 +#define COMMAND_TIMEOUT_10S 10000 #define COMMAND_ANTCYCLE_CONTINUOUS 0xFFFF @@ -162,10 +163,76 @@ Insertion/update of tag data is based on binary searching algorithm for better e Read OEM data that contains product-specific information such as country code, antenna version and frequency channel information @param intf CSLBleInterface that references to the current reader instance @param addr Address of the memory location - @param data Pointer to the NSData object that holds the value of the data address + @param data UInt32 that holds the value of the data address @return TRUE if the operation is successful */ -- (BOOL)readOEMData:(CSLBleInterface*)intf atAddr:(unsigned short)addr forData:(NSData*)data; +- (BOOL)readOEMData:(CSLBleInterface*)intf atAddr:(unsigned short)addr forData:(UInt32*)data; +/** +Set frequency band based on the region selected +@param frequencySelector channel number selected +@param config channel enable/disable +@param mult_div frequncy multdiv +@param pll_cc pllcc +@return TRUE if the operation is successful +*/ +- (BOOL)setFrequencyBand:(UInt32)frequencySelector bandState:(BOOL) config multdiv:(UInt32)mult_div pllcc:(UInt32) pll_cc; +/** +Set hopping frequency based on region selected +@param frequencyInfo CSLReaderFrequency object that initialized baesd ont he OEM data from the reader +@param region Code of the region being selected +@return TRUE if the operation is successful +*/ +- (BOOL) SetHoppingChannel:(CSLReaderFrequency*) frequencyInfo RegionCode:(NSString*)region; +/** +Set fixed frequency based on region and channel selected +@param frequencyInfo CSLReaderFrequency object that initialized baesd ont he OEM data from the reader +@param region Code of the region being selected +@param index Index of the selected frequency channel +@return TRUE if the operation is successful +*/ +- (BOOL) SetFixedChannel:(CSLReaderFrequency*) frequencyInfo RegionCode:(NSString*)region channelIndex:(UInt32)index; +/** +Set PLLCC based on the region selected +@param region Code of the region being selected +@return PLLCC value of the selected region +*/ +- (UInt32) GetPllcc:(NSString*) region; +/** +Write LNA configurations to the reader +@param intf CSLBleInterface that references to the current reader instance +@param rflna_high_comp The rflna_gain setting generates the following RF-LNA gains +0 = 1 dB +2 = 7 dB +3 = 13 dB +@param rflna_gain The iflna_gain setting generates the following IF-LNA gains +0 = 24 dB +1 = 18 dB +3 = 12 dB +7 = 6 dB +@param ifagc_gain The ifagc_gain setting generates the following AGC gain values +0 = -12 dB +4 = -6 dB +6 = 0 dB +7 = 6 dB +@return TRUE if the operation is successful +*/ +- (BOOL)setLNAParameters:(CSLBleInterface*)intf rflnaHighComp:(Byte)rflna_high_comp rflnaGain:(Byte)rflna_gain iflnaGain:(Byte)iflna_gain ifagcGain:(Byte)ifagc_gain; +/** +Write Impinj Extensions register +@param tag_Focus If this feature is enabled, once a tag has been singulated it will remain out of the tag population (the tag's session 1 inventoried flag remains in B state) until the inventory operation is complete. +0=disabled +1=enabled +@param fast_id If this feature is enabled and a M4 tag is in the field, then the 6-word M4 TID will be returned along with the EPC when the tag is singulated. +0=disabled +1=enabled +@param blockwrite_mode Determines the maximum number of words to write per BlockWrite transaction with the tag. +0 = Auto-detect (Default). One or two word BlockWrite will be determined automatically. +1 = Force one word BlockWrite. Unconditionally use one word BlockWrites in all cases. +2 = Force two word BlockWrite. Unconditionally use two word BlockWrites in all cases. A protocol error will occur if the tags in the field do not support this feature. +3-15 = Reserved for future use +@return TRUE if the operation is successful +*/ +- (BOOL)setImpinjExtension:(Byte)tag_Focus fastId:(Byte)fast_id blockWriteMode:(Byte)blockwrite_mode; /** Enable/disable barcode reader @param enable TRUE/FALSE for turning on/off the barcode reader module diff --git a/CS108iOSClient/CSLReader/CSLBleReader.m b/CS108iOSClient/CSLReader/CSLBleReader.m index 393d337..cd5c852 100644 --- a/CS108iOSClient/CSLReader/CSLBleReader.m +++ b/CS108iOSClient/CSLReader/CSLBleReader.m @@ -51,7 +51,7 @@ - (void) connectDevice:(CBPeripheral*) peripheral { } -- (BOOL)readOEMData:(CSLBleInterface*)intf atAddr:(unsigned short)addr forData:(NSData*)data +- (BOOL)readOEMData:(CSLBleInterface*)intf atAddr:(unsigned short)addr forData:(UInt32*)data { @synchronized(self) { if (self.connectStatus!=CONNECTED) @@ -69,6 +69,8 @@ - (BOOL)readOEMData:(CSLBleInterface*)intf atAddr:(unsigned short)addr forData:( CSLBlePacket* packet= [[CSLBlePacket alloc] init]; CSLBlePacket * recvPacket; + UInt32 OEMData=0; + NSLog(@"----------------------------------------------------------------------"); NSLog(@"Read OEM data (address: 0x%X)...", addr); NSLog(@"----------------------------------------------------------------------"); @@ -90,7 +92,7 @@ - (BOOL)readOEMData:(CSLBleInterface*)intf atAddr:(unsigned short)addr forData:( for (int i=0;i= 2) break; - [NSThread sleepForTimeInterval:0.1f]; + [NSThread sleepForTimeInterval:0.001f]; } if ([cmdRespQueue count] >= 2) @@ -144,27 +146,491 @@ - (BOOL)readOEMData:(CSLBleInterface*)intf atAddr:(unsigned short)addr forData:( [self.delegate didInterfaceChangeConnectStatus:self]; //this will call the method for connections status chagnes. return false; } + + //command-begin + recvPacket = ((CSLBlePacket *)[cmdRespQueue deqObject]); + if (([[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(4, 2)] isEqualToString:@"02"] && + [[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(8, 4)] isEqualToString:@"0080"]) || + ([[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(4, 2)] isEqualToString:@"01"] && + [[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(8, 4)] isEqualToString:@"0000"]) + ) { + NSLog(@"Receive HST_CMD 0x03 command-begin response: OK"); + } + else + { + NSLog(@"Receive HST_CMD 0x03 command-begin response: FAILED"); + connectStatus=CONNECTED; + [self.delegate didInterfaceChangeConnectStatus:self]; //this will call the method for connections status chagnes. + return false; + } + //OEM read response + if ([recvPacket.payload length] < 50) { + NSLog(@"Receive HST_CMD 0x03 response (length check): FAILED"); + connectStatus=CONNECTED; + [self.delegate didInterfaceChangeConnectStatus:self]; //this will call the method for connections status chagnes. + return false; + } + + if (([[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(36, 2)] isEqualToString:@"01"] && + [[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(40, 4)] isEqualToString:@"0730"])) { - if (memcmp([recvPacket.payload bytes], OEMHSTCMD, 2) == 0 && ((Byte *)[recvPacket.payload bytes])[2] == 0x00) - NSLog(@"Receive HST_CMD 0x03 response: OK"); + OEMData = ((Byte *)[recvPacket.payload bytes])[30] + + (((Byte *)[recvPacket.payload bytes])[31] << 8) + + (((Byte *)[recvPacket.payload bytes])[32] << 16) + + (((Byte *)[recvPacket.payload bytes])[33] << 24); + + *data = OEMData; + + + } + else + { + NSLog(@"Receive HST_CMD 0x03 command-begin response: FAILED"); + connectStatus=CONNECTED; + [self.delegate didInterfaceChangeConnectStatus:self]; //this will call the method for connections status chagnes. + return false; + } + + + //command-end + //recvPacket = ((CSLBlePacket *)[cmdRespQueue deqObject]); + if (([[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(68, 2)] isEqualToString:@"02"] || + [[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(68, 2)] isEqualToString:@"01"]) && + ([[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(72, 4)] isEqualToString:@"0180"] || + [[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(72, 4)] isEqualToString:@"0100"]) && + ((Byte *)[recvPacket.payload bytes])[46] == 0x00 && + ((Byte *)[recvPacket.payload bytes])[47] == 0x00) { + self.lastMacErrorCode=(((Byte *)[recvPacket.payload bytes])[15] << 8) + (((Byte *)[recvPacket.payload bytes])[14]); + NSLog(@"Receive HST_CMD 0x03 command-end response: OK"); + } + else + { + NSLog(@"Receive HST_CMD 0x03 command-end response: FAILED"); + self.lastMacErrorCode=(((Byte *)[recvPacket.payload bytes])[15] << 8) + (((Byte *)[recvPacket.payload bytes])[14]); + connectStatus=CONNECTED; + [self.delegate didInterfaceChangeConnectStatus:self]; //this will call the method for connections status chagnes. + return false; + } + + connectStatus=CONNECTED; + [self.delegate didInterfaceChangeConnectStatus:self]; //this will call the method for connections status chagnes. + return true; + +} + +- (BOOL)setFrequencyBand:(UInt32)frequencySelector bandState:(BOOL) config multdiv:(UInt32)mult_div pllcc:(UInt32) pll_cc { + + @synchronized(self) { + if (connectStatus!=CONNECTED) + { + NSLog(@"Reader is not connected or busy. Access failure"); + return false; + } + + connectStatus=BUSY; + } + [self.delegate didInterfaceChangeConnectStatus:self]; //this will call the method for connections status chagnes. + [self.recvQueue removeAllObjects]; + [cmdRespQueue removeAllObjects]; + + //Initialize data + CSLBlePacket* packet= [[CSLBlePacket alloc] init]; + CSLBlePacket * recvPacket; + + NSLog(@"----------------------------------------------------------------------"); + NSLog(@"Write selector address to register RFTC_FRQCH_SEL 0x0C01"); + NSLog(@"----------------------------------------------------------------------"); + + unsigned char FRQCH_SEL[] = {0x80, 0x02, 0x70, 0x01, 0x01, 0x0C, frequencySelector & 0xFF, 0x00, 0x00, 0x00}; + packet.prefix=0xA7; + packet.connection = Bluetooth; + packet.payloadLength=0x0A; + packet.deviceId=RFID; + packet.Reserve=0x82; + packet.direction=Downlink; + packet.crc1=0; + packet.crc2=0; + packet.payload=[NSData dataWithBytes:FRQCH_SEL length:sizeof(FRQCH_SEL)]; + + NSLog(@"BLE packet sending: %@", [packet getPacketInHexString]); + [self sendPackets:packet]; + + for (int i=0;i> 8, (mult_div & 0x00FF0000) >> 16, (mult_div & 0xFF000000) >> 24}; + packet.prefix=0xA7; + packet.connection = Bluetooth; + packet.payloadLength=0x0A; + packet.deviceId=RFID; + packet.Reserve=0x82; + packet.direction=Downlink; + packet.crc1=0; + packet.crc2=0; + packet.payload=[NSData dataWithBytes:PLLDIVMULT length:sizeof(PLLDIVMULT)]; + + NSLog(@"BLE packet sending: %@", [packet getPacketInHexString]); + [self sendPackets:packet]; + + for (int i=0;i> 8, (pll_cc & 0x00FF0000) >> 16, (pll_cc & 0xFF000000) >> 24}; + packet.prefix=0xA7; + packet.connection = Bluetooth; + packet.payloadLength=0x0A; + packet.deviceId=RFID; + packet.Reserve=0x82; + packet.direction=Downlink; + packet.crc1=0; + packet.crc2=0; + packet.payload=[NSData dataWithBytes:PLLCC length:sizeof(PLLCC)]; + + NSLog(@"BLE packet sending: %@", [packet getPacketInHexString]); + [self sendPackets:packet]; + + for (int i=0;i> 8, (addr & 0x00FF0000) >> 16, (addr & 0xFF000000) >> 24}; + packet.prefix=0xA7; + packet.connection = Bluetooth; + packet.payloadLength=0x0A; + packet.deviceId=RFID; + packet.Reserve=0x82; + packet.direction=Downlink; + packet.crc1=0; + packet.crc2=0; + packet.payload=[NSData dataWithBytes:MBPAddr length:sizeof(MBPAddr)]; + + NSLog(@"BLE packet sending: %@", [packet getPacketInHexString]); + [intf sendPackets:packet]; + + for (int i=0;i> 8, (data & 0x00FF0000) >> 16, (data & 0xFF000000) >> 24}; + packet.prefix=0xA7; + packet.connection = Bluetooth; + packet.payloadLength=0x0A; + packet.deviceId=RFID; + packet.Reserve=0x82; + packet.direction=Downlink; + packet.crc1=0; + packet.crc2=0; + packet.payload=[NSData dataWithBytes:MBPData length:sizeof(MBPData)]; + + NSLog(@"BLE packet sending: %@", [packet getPacketInHexString]); + [intf sendPackets:packet]; + + for (int i=0;i= 2) + break; + [NSThread sleepForTimeInterval:0.001f]; + } + + if ([cmdRespQueue count] >= 1) + recvPacket = ((CSLBlePacket *)[cmdRespQueue deqObject]); + else { - NSLog(@"Read OEM data: OK"); - data = recvPacket.payload; + NSLog(@"Command timed out."); + connectStatus=CONNECTED; + [self.delegate didInterfaceChangeConnectStatus:self]; //this will call the method for connections status chagnes. + return false; } + + + if (memcmp([recvPacket.payload bytes], TILHSTCMD, 2) == 0 && ((Byte *)[recvPacket.payload bytes])[2] == 0x00) + NSLog(@"Receive HST_CMD 0x06 response: OK"); else { - NSLog(@"Read OEM data: FAILED"); + NSLog(@"Receive HST_CMD 0x06 response: FAILED"); connectStatus=CONNECTED; [self.delegate didInterfaceChangeConnectStatus:self]; //this will call the method for connections status chagnes. return FALSE; @@ -175,6 +641,74 @@ - (BOOL)readOEMData:(CSLBleInterface*)intf atAddr:(unsigned short)addr forData:( return TRUE; } +- (BOOL)setImpinjExtension:(Byte)tag_Focus fastId:(Byte)fast_id blockWriteMode:(Byte)blockwrite_mode { + + @synchronized(self) { + if (connectStatus!=CONNECTED) + { + NSLog(@"Reader is not connected or busy. Access failure"); + return false; + } + + connectStatus=BUSY; + } + [self.delegate didInterfaceChangeConnectStatus:self]; //this will call the method for connections status chagnes. + [self.recvQueue removeAllObjects]; + [cmdRespQueue removeAllObjects]; + + //Initialize data + CSLBlePacket* packet= [[CSLBlePacket alloc] init]; + CSLBlePacket * recvPacket; + + //Set Impinj extension register + NSLog(@"----------------------------------------------------------------------"); + NSLog(@"Set Impinj extension register 0x0203"); + NSLog(@"----------------------------------------------------------------------"); + + unsigned int value=(blockwrite_mode & 0x0F) | ((tag_Focus & 0x01) << 4) | ((fast_id & 0x01) << 5); + unsigned char IMPJ_EXT[] = {0x80, 0x02, 0x70, 0x01, 0x03, 0x02, value & 0xFF, 0x00, 0x00, 0x00}; + packet.prefix=0xA7; + packet.connection = Bluetooth; + packet.payloadLength=0x0A; + packet.deviceId=RFID; + packet.Reserve=0x82; + packet.direction=Downlink; + packet.crc1=0; + packet.crc2=0; + packet.payload=[NSData dataWithBytes:IMPJ_EXT length:sizeof(IMPJ_EXT)]; + + NSLog(@"BLE packet sending: %@", [packet getPacketInHexString]); + [self sendPackets:packet]; + + for (int i=0;i 1) break; - [NSThread sleepForTimeInterval:0.1f]; + [NSThread sleepForTimeInterval:0.001f]; } if ([cmdRespQueue count] > 1) payloadData = ((CSLBlePacket *)[cmdRespQueue deqObject]).payload; @@ -365,7 +899,7 @@ - (BOOL)sendBarcodeCommandData: (NSData*)data for (int i=0;i= 2 ) { + recvPacket=((CSLBlePacket *)[cmdRespQueue deqObject]); + if (![[recvPacket getPacketPayloadInHexString] containsString:@"800200"]) { + break; + } recvPacket=((CSLBlePacket *)[cmdRespQueue deqObject]); if ([[recvPacket getPacketPayloadInHexString] containsString:@"4003BFFCBFFCBFFC"]) { isAborted=true; @@ -823,7 +1361,7 @@ - (BOOL)sendAbortCommand { } else - [NSThread sleepForTimeInterval:0.1f]; + [NSThread sleepForTimeInterval:0.001f]; } if (isAborted) { @@ -873,7 +1411,7 @@ - (BOOL)startBatteryAutoReporting { for (int i=0;i= 2) break; - [NSThread sleepForTimeInterval:0.1f]; + [NSThread sleepForTimeInterval:0.001f]; } if ([cmdRespQueue count] >= 2) { @@ -1073,7 +1611,7 @@ - (BOOL)setPower:(double) powerInDbm { for (int i=0;i= 3) //command response + command begin + command end break; - [NSThread sleepForTimeInterval:0.1f]; + [NSThread sleepForTimeInterval:0.001f]; } if ([cmdRespQueue count] >= 3) @@ -2036,7 +2574,7 @@ -(BOOL)startInventory { for (int i=0;i - + - + @@ -413,7 +413,7 @@ @@ -421,7 +421,11 @@ + + + + @@ -460,26 +464,26 @@ - + - + - + - - + + @@ -543,7 +547,7 @@ - + @@ -574,275 +578,479 @@ - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + - - - + + + + + + + + + + + + @@ -850,12 +1058,12 @@ - + - + @@ -1206,10 +1414,10 @@ - + - + @@ -1221,6 +1429,56 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -1304,8 +1562,9 @@ - @@ -1315,8 +1574,6 @@ - - @@ -1328,6 +1585,7 @@ + @@ -1371,7 +1629,7 @@ - + @@ -1545,7 +1803,7 @@ - + @@ -1739,7 +1997,7 @@ - + @@ -1849,7 +2107,7 @@ - + @@ -2191,7 +2449,7 @@ - + @@ -2590,7 +2848,7 @@ - + @@ -2659,7 +2917,7 @@ - + @@ -2671,7 +2929,7 @@ - + @@ -2681,9 +2939,9 @@ + - @@ -2710,7 +2968,7 @@ - + @@ -2943,7 +3201,7 @@ - + @@ -2970,7 +3228,7 @@ - + @@ -3786,7 +4044,7 @@ - + @@ -4381,7 +4639,7 @@ - + diff --git a/CS108iOSClient/Info.plist b/CS108iOSClient/Info.plist index 2fff722..61724a6 100644 --- a/CS108iOSClient/Info.plist +++ b/CS108iOSClient/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 210 + 293 LSRequiresIPhoneOS NSBluetoothAlwaysUsageDescription diff --git a/CS108iOSClient/ViewControllers/CSLAntennaPortVC.swift b/CS108iOSClient/ViewControllers/CSLAntennaPortVC.swift index d8e8b01..45528bd 100644 --- a/CS108iOSClient/ViewControllers/CSLAntennaPortVC.swift +++ b/CS108iOSClient/ViewControllers/CSLAntennaPortVC.swift @@ -23,8 +23,8 @@ var count = 0 for sw in swAntennaPort { - print("Switch \(count): \((CSLRfidAppEngine.shared().settings.isPortEnabled[count] as! NSNumber).boolValue ? "ON" : "OFF")") - sw.isOn = (CSLRfidAppEngine.shared().settings.isPortEnabled[count] as! NSNumber).boolValue + print("Switch \(count): \(Bool(truncating: CSLRfidAppEngine.shared().settings.isPortEnabled[count] as! NSNumber) ? "ON" : "OFF")") + sw.isOn = Bool(truncating: CSLRfidAppEngine.shared().settings.isPortEnabled[count] as! NSNumber) count += 1 } } diff --git a/CS108iOSClient/ViewControllers/CSLDeviceTV.swift b/CS108iOSClient/ViewControllers/CSLDeviceTV.swift index 8e749a5..a881ec3 100644 --- a/CS108iOSClient/ViewControllers/CSLDeviceTV.swift +++ b/CS108iOSClient/ViewControllers/CSLDeviceTV.swift @@ -135,6 +135,47 @@ import QuartzCore } CSLRfidAppEngine.shared().readerInfo.appVersion = appVersion + + var OEMData: UInt32 = 0 + + //device country code + CSLRfidAppEngine.shared().reader.readOEMData(CSLRfidAppEngine.shared().reader, atAddr: 0x00000002, forData: &OEMData) + CSLRfidAppEngine.shared().readerInfo.countryCode = OEMData + print(String(format: "OEM data address 0x%08X: 0x%08X", 0x02, OEMData)) + //special country version + CSLRfidAppEngine.shared().reader.readOEMData(CSLRfidAppEngine.shared().reader, atAddr: 0x0000008e, forData: &OEMData) + CSLRfidAppEngine.shared().readerInfo.specialCountryVerison = OEMData + print(String(format: "OEM data address 0x%08X: 0x%08X", 0x8e, OEMData)) + //freqency modification flag + CSLRfidAppEngine.shared().reader.readOEMData(CSLRfidAppEngine.shared().reader, atAddr: 0x0000008f, forData: &OEMData) + CSLRfidAppEngine.shared().readerInfo.freqModFlag = OEMData + print(String(format: "OEM data address 0x%08X: 0x%08X", 0x8f, OEMData)) + //model code + CSLRfidAppEngine.shared().reader.readOEMData(CSLRfidAppEngine.shared().reader, atAddr: 0x000000a4, forData: &OEMData) + CSLRfidAppEngine.shared().readerInfo.modelCode = OEMData + print(String(format: "OEM data address 0x%08X: 0x%08X", 0xa4, OEMData)) + //hopping/fixed frequency + CSLRfidAppEngine.shared().reader.readOEMData(CSLRfidAppEngine.shared().reader, atAddr: 0x0000009d, forData: &OEMData) + CSLRfidAppEngine.shared().readerInfo.isFxied = OEMData + print(String(format: "OEM data address 0x%08X: 0x%08X", 0x9d, OEMData)) + + CSLRfidAppEngine.shared().readerRegionFrequency = CSLReaderFrequency( + oemData: CSLRfidAppEngine.shared().readerInfo.countryCode, + specialCountryVerison: CSLRfidAppEngine.shared().readerInfo.specialCountryVerison, + freqModFlag: CSLRfidAppEngine.shared().readerInfo.freqModFlag, + modelCode: CSLRfidAppEngine.shared().readerInfo.modelCode, + isFixed: CSLRfidAppEngine.shared().readerInfo.isFxied) + + if CSLRfidAppEngine.shared().readerRegionFrequency.tableOfFrequencies[CSLRfidAppEngine.shared().settings.region!] == nil { + //the region being stored is not valid, reset to default region and frequency channel + CSLRfidAppEngine.shared().settings.region = CSLRfidAppEngine.shared().readerRegionFrequency.regionList[0] as? String + CSLRfidAppEngine.shared().settings.channel = "0" + CSLRfidAppEngine.shared().saveSettingsToUserDefaults() + } + + + + let fw = CSLRfidAppEngine.shared().readerInfo.btFirmwareVersion as String if fw.count >= 5 { if (fw.prefix(1) == "3") { diff --git a/CS108iOSClient/ViewControllers/CSLInventoryVC.swift b/CS108iOSClient/ViewControllers/CSLInventoryVC.swift index 9eb2bbb..90e2836 100644 --- a/CS108iOSClient/ViewControllers/CSLInventoryVC.swift +++ b/CS108iOSClient/ViewControllers/CSLInventoryVC.swift @@ -20,6 +20,8 @@ import AudioToolbox @IBOutlet weak var lbMode: UILabel! @IBOutlet weak var uivSendTagData: UIView! @IBOutlet weak var actInventorySpinner: UIActivityIndicatorView! + @IBOutlet weak var lbElapsedTime: UILabel! + var tagRangingStartTime: Date? = nil private var scrRefreshTimer: Timer? @@ -102,6 +104,11 @@ import AudioToolbox lbUniqueTagRate.text = String(format: "%ld", Int(CSLRfidAppEngine.shared().reader.uniqueTagCount)) CSLRfidAppEngine.shared().reader.rangingTagCount = 0 CSLRfidAppEngine.shared().reader.uniqueTagCount = 0 + + //incrememt elapse time + lbElapsedTime.text = "\(Int(lbElapsedTime.text!)! + 1)" + + } else if CSLRfidAppEngine.shared().isBarcodeMode { //update table tblTagList.reloadData() @@ -134,6 +141,8 @@ import AudioToolbox //clear UI lbTagRate.text = "0" lbTagCount.text = "0" + lbElapsedTime.text = "0" + lbUniqueTagRate.text = "0" CSLRfidAppEngine.shared().reader.filteredBuffer.removeAllObjects() tblTagList.dataSource = self @@ -283,10 +292,50 @@ import AudioToolbox //clear UI lbTagRate.text = "0" lbTagCount.text = "0" + lbElapsedTime.text = "0" CSLRfidAppEngine.shared().reader.filteredBuffer.removeAllObjects() tblTagList.reloadData() } + @IBAction func btnSaveData(_ sender: Any) { + + var fileContent = "TIMESTAMP,EPC,DATA1,DATA2,RSSI\n" + + for tag in CSLRfidAppEngine.shared().reader.filteredBuffer { + + //tag read timestamp + let dateFormatter = DateFormatter() + dateFormatter.dateFormat = "dd/MM/YY HH:mm:ss" + let date = (tag as! CSLBleTag).timestamp + var stringFromDate: String? = nil + if let date = date { + stringFromDate = dateFormatter.string(from: date) + } + + + fileContent = fileContent + ("\(stringFromDate ?? ""),\((tag as! CSLBleTag).epc ?? ""),\((tag as! CSLBleTag).data1 ?? ""),\((tag as! CSLBleTag).data2 ?? ""),\("\((tag as! CSLBleTag).rssi)")\n") + } + + let objectsToShare = [fileContent] + + let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil) + + let excludeActivities: [AnyHashable]? = [ + UIActivity.ActivityType.assignToContact, + UIActivity.ActivityType.saveToCameraRoll, + UIActivity.ActivityType.addToReadingList, + UIActivity.ActivityType.postToFlickr, + UIActivity.ActivityType.postToVimeo + ] + + activityVC.excludedActivityTypes = excludeActivities as? [UIActivity.ActivityType] + + present(activityVC, animated: true) + + } + + + @IBAction func btnSendTagData(_ sender: Any) { //check MQTT settings. Connect to broker and send tag data //var allTagPublishedSuccess = true diff --git a/CS108iOSClient/ViewControllers/CSLSettingsVC.swift b/CS108iOSClient/ViewControllers/CSLSettingsVC.swift index 767553d..1c49e2c 100644 --- a/CS108iOSClient/ViewControllers/CSLSettingsVC.swift +++ b/CS108iOSClient/ViewControllers/CSLSettingsVC.swift @@ -20,6 +20,15 @@ @IBOutlet weak var swSound: UISwitch! @IBOutlet weak var btnPowerLevel: UIButton! @IBOutlet weak var btnAntennaSettings: UIButton! + @IBOutlet weak var btnRfLna: UIButton! + @IBOutlet weak var btnIfLna: UIButton! + @IBOutlet weak var btnAgcGain: UIButton! + @IBOutlet weak var swLnaHighComp: UISwitch! + @IBOutlet weak var swTagFocus: UISwitch! + @IBOutlet weak var btnRegion: UIButton! + @IBOutlet weak var btnFrequencyChannel: UIButton! + @IBOutlet weak var btnFrequencyOrder: UIButton! + override func viewDidLoad() { @@ -58,6 +67,30 @@ btnAntennaSettings.layer.borderColor = UIColor.lightGray.cgColor btnAntennaSettings.layer.cornerRadius = 5.0 + btnRfLna.layer.borderWidth = 1.0 + btnRfLna.layer.borderColor = UIColor.lightGray.cgColor + btnRfLna.layer.cornerRadius = 5.0 + + btnIfLna.layer.borderWidth = 1.0 + btnIfLna.layer.borderColor = UIColor.lightGray.cgColor + btnIfLna.layer.cornerRadius = 5.0 + + btnAgcGain.layer.borderWidth = 1.0 + btnAgcGain.layer.borderColor = UIColor.lightGray.cgColor + btnAgcGain.layer.cornerRadius = 5.0 + + btnRegion.layer.borderWidth = 1.0 + btnRegion.layer.borderColor = UIColor.lightGray.cgColor + btnRegion.layer.cornerRadius = 5.0 + + btnFrequencyChannel.layer.borderWidth = 1.0 + btnFrequencyChannel.layer.borderColor = UIColor.lightGray.cgColor + btnFrequencyChannel.layer.cornerRadius = 5.0 + + btnFrequencyOrder.layer.borderWidth = 1.0 + btnFrequencyOrder.layer.borderColor = UIColor.lightGray.cgColor + btnFrequencyOrder.layer.cornerRadius = 5.0 + txtQValue.delegate = self txtTagPopulation.delegate = self txtPower.delegate = self @@ -67,6 +100,28 @@ } else { btnAntennaSettings.isHidden = true } + + //pre-populate the region and frequency info + let channel = Int(CSLRfidAppEngine.shared().settings.channel)! + let region = CSLRfidAppEngine.shared().settings.region! + btnRegion.setTitle(CSLRfidAppEngine.shared().settings.region, for: .normal) + btnFrequencyChannel.setTitle( + (CSLRfidAppEngine.shared().readerRegionFrequency.tableOfFrequencies[region] as! NSArray)[channel] as? String, + for: .normal) + if CSLRfidAppEngine.shared().readerRegionFrequency.isFixed != 0 { + btnFrequencyOrder.setTitle("Fixed", for: .normal) + btnFrequencyChannel.isEnabled = true + } else { + btnFrequencyOrder.setTitle("Hopping", for: .normal) + btnFrequencyChannel.isEnabled = false + } + + if CSLRfidAppEngine.shared().readerRegionFrequency.freqModFlag != 0 { + btnRegion.isEnabled = false + } else { + btnRegion.isEnabled = true + } + } @@ -125,6 +180,54 @@ break } + if CSLRfidAppEngine.shared().settings.tagFocus != 0 { + swTagFocus.isOn = true + } else { + swTagFocus.isOn = false + } + if CSLRfidAppEngine.shared().settings.rfLnaHighComp != 0 { + swLnaHighComp.isOn = true + } else { + swLnaHighComp.isOn = false + } + + switch CSLRfidAppEngine.shared().settings.rfLna { + case 0: + btnRfLna.setTitle("1 dB", for: .normal) + case 2: + btnRfLna.setTitle("7 dB", for: .normal) + case 3: + btnRfLna.setTitle("13 dB", for: .normal) + default: + break + } + switch CSLRfidAppEngine.shared().settings.ifLna { + case 0: + btnIfLna.setTitle("24 dB", for: .normal) + case 1: + btnIfLna.setTitle("18 dB", for: .normal) + case 3: + btnIfLna.setTitle("12 dB", for: .normal) + case 7: + btnIfLna.setTitle("6 dB", for: .normal) + default: + break + } + switch CSLRfidAppEngine.shared().settings.ifAgc { + case 0: + btnAgcGain.setTitle("-12 dB", for: .normal) + case 4: + btnAgcGain.setTitle("-6 dB", for: .normal) + case 6: + btnAgcGain.setTitle("0 dB", for: .normal) + case 7: + btnAgcGain.setTitle("6 dB", for: .normal) + default: + break + } + + + } override func didReceiveMemoryWarning() { @@ -324,6 +427,65 @@ } CSLRfidAppEngine.shared().settings.enableSound = swSound.isOn + if swTagFocus.isOn { + CSLRfidAppEngine.shared().settings.tagFocus = 1 + } else { + CSLRfidAppEngine.shared().settings.tagFocus = 0 + } + + if swLnaHighComp.isOn { + CSLRfidAppEngine.shared().settings.rfLnaHighComp = 1 + } else { + CSLRfidAppEngine.shared().settings.rfLnaHighComp = 0 + } + + if btnRfLna.titleLabel?.text?.compare("1 dB") == .orderedSame { + CSLRfidAppEngine.shared().settings.rfLna = 0 + } + if btnRfLna.titleLabel?.text?.compare("7 dB") == .orderedSame { + CSLRfidAppEngine.shared().settings.rfLna = 2 + } + if btnRfLna.titleLabel?.text?.compare("13 dB") == .orderedSame { + CSLRfidAppEngine.shared().settings.rfLna = 3 + } + + if btnIfLna.titleLabel?.text?.compare("24 dB") == .orderedSame { + CSLRfidAppEngine.shared().settings.ifLna = 0 + } + if btnIfLna.titleLabel?.text?.compare("18 dB") == .orderedSame { + CSLRfidAppEngine.shared().settings.ifLna = 1 + } + if btnIfLna.titleLabel?.text?.compare("12 dB") == .orderedSame { + CSLRfidAppEngine.shared().settings.ifLna = 3 + } + if btnIfLna.titleLabel?.text?.compare("6 dB") == .orderedSame { + CSLRfidAppEngine.shared().settings.ifLna = 7 + } + + if btnAgcGain.titleLabel?.text?.compare("-12 dB") == .orderedSame { + CSLRfidAppEngine.shared().settings.ifAgc = 0 + } + if btnAgcGain.titleLabel?.text?.compare("-6 dB") == .orderedSame { + CSLRfidAppEngine.shared().settings.ifAgc = 4 + } + if btnAgcGain.titleLabel?.text?.compare("0 dB") == .orderedSame { + CSLRfidAppEngine.shared().settings.ifAgc = 6 + } + if btnAgcGain.titleLabel?.text?.compare("6 dB") == .orderedSame { + CSLRfidAppEngine.shared().settings.ifAgc = 7 + } + + let channel = btnFrequencyChannel.titleLabel?.text + let region = btnRegion.titleLabel?.text + + CSLRfidAppEngine.shared().settings.region = region + for i in 0..<((CSLRfidAppEngine.shared().readerRegionFrequency.tableOfFrequencies[region!] as? NSArray)?.count ?? 0) { + if (((CSLRfidAppEngine.shared().readerRegionFrequency.tableOfFrequencies[region!] as! NSArray)[i] as? String) == channel) { + CSLRfidAppEngine.shared().settings.channel = "\(i)" + } + } + + CSLRfidAppEngine.shared().saveSettingsToUserDefaults() let alert = UIAlertController(title: "Settings", message: "Settings saved.", preferredStyle: .alert) @@ -334,6 +496,155 @@ } + @IBAction func swTagFocusChanged(_ sender: Any) { + if swTagFocus.isOn { + btnSession.setTitle("S1", for: .normal) + btnSession.isEnabled = false + + btnTarget.setTitle("A", for: .normal) + btnTarget.isEnabled = false + } else { + btnSession.isEnabled = true + btnTarget.isEnabled = true + } + } + + @IBAction func btnFrequencyOrderPressed(_ sender: Any) { + //do nothing + } + + @IBAction func btnFrequencyChannelPressed(_ sender: Any) { + let alert = UIAlertController( + title: "Channel", + message: "Please select", + preferredStyle: .actionSheet) + + for channel in (CSLRfidAppEngine.shared().readerRegionFrequency.tableOfFrequencies[btnRegion.titleLabel?.text ?? ""] as! NSArray) { + guard let channel = channel as? String else { + continue + } + let listItem = UIAlertAction(title: channel, style: .default, handler: { action in + self.btnFrequencyChannel.setTitle(channel, for: .normal) + }) + alert.addAction(listItem) + } + let cancel = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) // cancel + alert.addAction(cancel) + + present(alert, animated: true) + } + + @IBAction func btnRegionPressed(_ sender: Any) { + let alert = UIAlertController( + title: "Region", + message: "Please select", + preferredStyle: .actionSheet) + + for region in CSLRfidAppEngine.shared().readerRegionFrequency.regionList { + let listItem = UIAlertAction(title: (region as! String), style: .default, handler: { action in + self.btnRegion.setTitle((region as! String), for: .normal) + self.btnFrequencyChannel.setTitle( + (CSLRfidAppEngine.shared().readerRegionFrequency.tableOfFrequencies[region] as? NSArray)![0] as? String, + for: .normal) + }) + alert.addAction(listItem) + } + let cancel = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) // cancel + alert.addAction(cancel) + + present(alert, animated: true) + } + + @IBAction func btnAgcGainPressed(_ sender: Any) { + let alert = UIAlertController( + title: "IF-AGC", + message: "Please select", + preferredStyle: .actionSheet) + let dBm12 = UIAlertAction(title: "-12 dB", style: .default, handler: { action in + self.btnAgcGain.setTitle("-12 dB", for: .normal) + }) // -12 dB + let dBm6 = UIAlertAction(title: "-6 dB", style: .default, handler: { action in + self.btnAgcGain.setTitle("-6 dB", for: .normal) + }) // -6 dB + let dB0 = UIAlertAction(title: "0 dB", style: .default, handler: { action in + self.btnAgcGain.setTitle("0 dB", for: .normal) + }) // 0 dB + let dB6 = UIAlertAction(title: "6 dB", style: .default, handler: { action in + self.btnAgcGain.setTitle("6 dB", for: .normal) + }) // 6 dB + + let cancel = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) // cancel + + alert.addAction(dBm12) + alert.addAction(dBm6) + alert.addAction(dB0) + alert.addAction(dB6) + + alert.addAction(cancel) + + present(alert, animated: true) + + } + + @IBAction func btnIfLnaPressed(_ sender: Any) { + let alert = UIAlertController( + title: "IF-LNA", + message: "Please select", + preferredStyle: .actionSheet) + let dB24 = UIAlertAction(title: "24 dB", style: .default, handler: { action in + self.btnIfLna.setTitle("24 dB", for: .normal) + }) // 24 dB + let dB18 = UIAlertAction(title: "18 dB", style: .default, handler: { action in + self.btnIfLna.setTitle("18 dB", for: .normal) + }) // 18 dB + let dB12 = UIAlertAction(title: "12 dB", style: .default, handler: { action in + self.btnIfLna.setTitle("12 dB", for: .normal) + }) // 12 dB + let dB6 = UIAlertAction(title: "6 dB", style: .default, handler: { action in + self.btnIfLna.setTitle("6 dB", for: .normal) + }) // 6 dB + + let cancel = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) // cancel + + alert.addAction(dB24) + alert.addAction(dB18) + alert.addAction(dB12) + alert.addAction(dB6) + + alert.addAction(cancel) + + present(alert, animated: true) + + } + + @IBAction func btnRfLnaPressed(_ sender: Any) { + let alert = UIAlertController( + title: "RF-LNA", + message: "Please select", + preferredStyle: .actionSheet) + let dB1 = UIAlertAction(title: "1 dB", style: .default, handler: { action in + self.btnRfLna.setTitle("1 dB", for: .normal) + }) // 1 dB + let dB7 = UIAlertAction(title: "7 dB", style: .default, handler: { action in + self.btnRfLna.setTitle("7 dB", for: .normal) + }) // 7 dB + let dB13 = UIAlertAction(title: "13 dB", style: .default, handler: { action in + self.btnRfLna.setTitle("13 dB", for: .normal) + }) // 13 dB + + let cancel = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) // cancel + + alert.addAction(dB1) + alert.addAction(dB7) + alert.addAction(dB13) + + alert.addAction(cancel) + + present(alert, animated: true) + + } + + @IBAction func btnPowerLevelPressed(_ sender: Any) { var powerLevelVC: CSLPowerLevelVC? diff --git a/CS108iOSClient/ViewControllers/CSLTabVC.swift b/CS108iOSClient/ViewControllers/CSLTabVC.swift index 171f0dd..144cb78 100644 --- a/CS108iOSClient/ViewControllers/CSLTabVC.swift +++ b/CS108iOSClient/ViewControllers/CSLTabVC.swift @@ -99,7 +99,12 @@ import UIKit } else { //iterate through all the power level for i in 0..<16 { - let dwell = Int(CSLRfidAppEngine.shared().settings.dwellTime[i] as! String) + var dwell = Int(CSLRfidAppEngine.shared().settings.dwellTime[i] as! String) + //enforcing dwell time != 0 when tag focus is enabled + if CSLRfidAppEngine.shared().settings.tagFocus != 0 { + dwell = 2000 + } + let power = Int(CSLRfidAppEngine.shared().settings.powerLevel[i] as! String) CSLRfidAppEngine.shared().reader.selectAntennaPort(UInt(i)) print("Power level \(i): \((i >= CSLRfidAppEngine.shared().settings.numberOfPowerLevel) ? "OFF" : "ON")") @@ -112,9 +117,13 @@ import UIKit } else { //iterate through all the power level for i in 0..<4 { - let dwell = Int(CSLRfidAppEngine.shared().settings.dwellTime[i] as! String) + var dwell = Int(CSLRfidAppEngine.shared().settings.dwellTime[i] as! String) + //enforcing dwell time != 0 when tag focus is enabled + if CSLRfidAppEngine.shared().settings.tagFocus != 0 { + dwell = 2000 + } let power = Int(CSLRfidAppEngine.shared().settings.powerLevel[i] as! String) - let portEnabled = (CSLRfidAppEngine.shared().settings.isPortEnabled[i] as! NSNumber).boolValue + let portEnabled = Bool(truncating: CSLRfidAppEngine.shared().settings.isPortEnabled[i] as! NSNumber) CSLRfidAppEngine.shared().reader.selectAntennaPort(UInt(i)) print("Antenna \(i): \(portEnabled ? "ON" : "OFF")") CSLRfidAppEngine.shared().reader.setAntennaConfig(portEnabled, inventoryMode: 0, inventoryAlgo: 0, startQ: 0, profileMode: 0, profile: 0, frequencyMode: 0, frequencyChannel: 0, isEASEnabled: false) @@ -145,7 +154,7 @@ import UIKit //enable power output on selected port for i in 0..<4 { CSLRfidAppEngine.shared().reader.selectAntennaPort(UInt(i)) - print("Antenna \(i): \((CSLRfidAppEngine.shared().settings.isPortEnabled[i] as! NSNumber).boolValue ? "ON" : "OFF")") + print("Antenna \(i): \(Bool(truncating: CSLRfidAppEngine.shared().settings.isPortEnabled[i] as! NSNumber) ? "ON" : "OFF")") CSLRfidAppEngine.shared().reader.setAntennaConfig(CSLRfidAppEngine.shared().settings.tagAccessPort == i ? true : false, inventoryMode: 0, inventoryAlgo: 0, startQ: 0, profileMode: 0, profile: 0, frequencyMode: 0, frequencyChannel: 0, isEASEnabled: false) CSLRfidAppEngine.shared().reader.setPower(Double(CSLRfidAppEngine.shared().settings.power / 10)) CSLRfidAppEngine.shared().reader.setAntennaDwell(2000) @@ -174,8 +183,8 @@ import UIKit //enable power output on selected port for i in 0..<4 { CSLRfidAppEngine.shared().reader.selectAntennaPort(UInt(i)) - print("Antenna \(i): \((CSLRfidAppEngine.shared().settings.isPortEnabled[i] as! NSNumber).boolValue ? "ON" : "OFF")") - CSLRfidAppEngine.shared().reader.setAntennaConfig((CSLRfidAppEngine.shared().settings.isPortEnabled[i] as! NSNumber).boolValue, inventoryMode: 0, inventoryAlgo: 0, startQ: 0, profileMode: 0, profile: 0, frequencyMode: 0, frequencyChannel: 0, isEASEnabled: false) + print("Antenna \(i): \(Bool(truncating: CSLRfidAppEngine.shared().settings.isPortEnabled[i] as! NSNumber) ? "ON" : "OFF")") + CSLRfidAppEngine.shared().reader.setAntennaConfig(Bool(truncating: CSLRfidAppEngine.shared().settings.isPortEnabled[i] as! NSNumber), inventoryMode: 0, inventoryAlgo: 0, startQ: 0, profileMode: 0, profile: 0, frequencyMode: 0, frequencyChannel: 0, isEASEnabled: false) CSLRfidAppEngine.shared().reader.setPower(Double(CSLRfidAppEngine.shared().settings.power / 10)) CSLRfidAppEngine.shared().reader.setAntennaDwell(2000) CSLRfidAppEngine.shared().reader.setAntennaInventoryCount(0) @@ -196,20 +205,59 @@ import UIKit } else { tagRead = 0 } + + var tagDelay: UInt8 + if CSLRfidAppEngine.shared().settings.tagFocus == 0 && tagRead != 0 { + tagDelay = 30 + } + else { + tagDelay = 0 + } + CSLRfidAppEngine.shared().reader.setQueryConfigurations((CSLRfidAppEngine.shared().settings.target == TARGET.ToggleAB ? TARGET.A : CSLRfidAppEngine.shared().settings.target), querySession: CSLRfidAppEngine.shared().settings.session, querySelect: QUERYSELECT.ALL) CSLRfidAppEngine.shared().reader.selectAlgorithmParameter(CSLRfidAppEngine.shared().settings.algorithm) CSLRfidAppEngine.shared().reader.setInventoryAlgorithmParameters0(UInt8(CSLRfidAppEngine.shared().settings.qValue), maximumQ: 15, minimumQ: 0, thresholdMultiplier: 4) CSLRfidAppEngine.shared().reader.setInventoryAlgorithmParameters1(0) CSLRfidAppEngine.shared().reader.setInventoryAlgorithmParameters2((CSLRfidAppEngine.shared().settings.target == TARGET.ToggleAB ? true : false), runTillZero: false) - CSLRfidAppEngine.shared().reader.setInventoryConfigurations(CSLRfidAppEngine.shared().settings.algorithm, matchRepeats: 0, tagSelect: 0, disableInventory: 0, tagRead: tagRead, crcErrorRead: (tagRead != 0 ? 0 : 1), qtMode: 0, tagDelay: (tagRead != 0 ? 30 : 0), inventoryMode: (tagRead != 0 ? 0 : 1)) + CSLRfidAppEngine.shared().reader.setInventoryConfigurations(CSLRfidAppEngine.shared().settings.algorithm, matchRepeats: 0, tagSelect: 0, disableInventory: 0, tagRead: tagRead, crcErrorRead: (tagRead != 0 ? 0 : 1), qtMode: 0, tagDelay: tagDelay, inventoryMode: (tagRead != 0 ? 0 : 1)) CSLRfidAppEngine.shared().reader.setLinkProfile(CSLRfidAppEngine.shared().settings.linkProfile) + //frequency configurations + if CSLRfidAppEngine.shared().readerRegionFrequency.isFixed != 0 { + CSLRfidAppEngine.shared().reader.setFixedChannel( + CSLRfidAppEngine.shared().readerRegionFrequency, + regionCode: CSLRfidAppEngine.shared().settings.region, + channelIndex: UInt32(CSLRfidAppEngine.shared().settings.channel)!) + } else { + CSLRfidAppEngine.shared().reader.setHoppingChannel( + CSLRfidAppEngine.shared().readerRegionFrequency, + regionCode: CSLRfidAppEngine.shared().settings.region) + } + + + // if multibank read is enabled if tagRead != 0 { CSLRfidAppEngine.shared().reader.tagacc_BANK(CSLRfidAppEngine.shared().settings.multibank1, acc_bank2: CSLRfidAppEngine.shared().settings.multibank2) CSLRfidAppEngine.shared().reader.tagacc_PTR(UInt32(CSLRfidAppEngine.shared().settings.multibank2Offset) << 16 + UInt32(CSLRfidAppEngine.shared().settings.multibank1Offset)) CSLRfidAppEngine.shared().reader.tagacc_CNT(CSLRfidAppEngine.shared().settings.multibank1Length, secondBank: (tagRead == 2 ? CSLRfidAppEngine.shared().settings.multibank2Length : 0)) } + + print("Tag focus value: \(CSLRfidAppEngine.shared().settings.tagFocus)") + //Impinj Extension + CSLRfidAppEngine.shared().reader.setImpinjExtension( + CSLRfidAppEngine.shared().settings.tagFocus, + fastId: 0, + blockWriteMode: 0) + //LNA settings + CSLRfidAppEngine.shared().reader.setLNAParameters( + CSLRfidAppEngine.shared().reader, + rflnaHighComp: CSLRfidAppEngine.shared().settings.rfLnaHighComp, + rflnaGain: CSLRfidAppEngine.shared().settings.rfLna, + iflnaGain: CSLRfidAppEngine.shared().settings.ifLna, + ifagcGain: CSLRfidAppEngine.shared().settings.ifAgc) + + } } diff --git a/CS108iOSClient/ViewControllers/CSLTagAccessVC.swift b/CS108iOSClient/ViewControllers/CSLTagAccessVC.swift index a63dd65..efe510d 100644 --- a/CS108iOSClient/ViewControllers/CSLTagAccessVC.swift +++ b/CS108iOSClient/ViewControllers/CSLTagAccessVC.swift @@ -274,8 +274,8 @@ //get access password var accPwd: UInt32 = 0 - let scanner = Scanner(string: txtAccessPwd.text!) - scanner.scanHexInt32(&accPwd) + accPwd = UInt32(txtAccessPwd.text ?? "00000000")! + //read PC+EPC if TID is not needed. Otherwise, read PC+EPC+TID all in one shot if swEPC.isOn || swPC.isOn || swTidUid.isOn { @@ -444,8 +444,7 @@ //get access password var accPwd: UInt32 = 0 - let scanner = Scanner(string: txtAccessPwd.text!) - scanner.scanHexInt32(&accPwd) + accPwd = UInt32(txtAccessPwd.text ?? "00000000")! //write PC if it is enabled if swPC.isOn { diff --git a/CS108iOSClient/ViewControllers/CSLTagLockVC.swift b/CS108iOSClient/ViewControllers/CSLTagLockVC.swift index 02210ef..91d18bf 100644 --- a/CS108iOSClient/ViewControllers/CSLTagLockVC.swift +++ b/CS108iOSClient/ViewControllers/CSLTagLockVC.swift @@ -99,8 +99,7 @@ //get access password var accPwd: UInt32 = 0 - let scanner = Scanner(string: txtAccessPwd.text ?? "0") - scanner.scanHexInt32(UnsafeMutablePointer(mutating: &accPwd)) + accPwd = UInt32(txtAccessPwd.text ?? "0", radix: 16)! //compose the 20bit security lockCommandConfigBits = 0 diff --git a/CS108iOSClient/ViewControllers/CSLTemperatureDetailsVC.swift b/CS108iOSClient/ViewControllers/CSLTemperatureDetailsVC.swift index c37f435..7fff850 100644 --- a/CS108iOSClient/ViewControllers/CSLTemperatureDetailsVC.swift +++ b/CS108iOSClient/ViewControllers/CSLTemperatureDetailsVC.swift @@ -50,9 +50,9 @@ if let shared = (CSLRfidAppEngine.shared().cslBleTagSelected)?.epc { lastGoodRead = CSLRfidAppEngine.shared().temperatureSettings.lastGoodReadBuffer[shared] as? CSLBleTag } - let epc = lastGoodRead?.epc - let data1 = lastGoodRead?.data1 - let data2 = lastGoodRead?.data2 + let epc = String(lastGoodRead?.epc ?? "") + let data1 = String(lastGoodRead?.data1 ?? "") + let data2 = String(lastGoodRead?.data2 ?? "") //tag read timestamp let dateFormatter = DateFormatter() @@ -63,7 +63,7 @@ stringFromDate = dateFormatter.string(from: date) } - let temperatureValue = CSLRfidAppEngine.shared().temperatureSettings.getTemperatureValueAveraging(epc!).doubleValue + let temperatureValue = CSLRfidAppEngine.shared().temperatureSettings.getTemperatureValueAveraging(epc).doubleValue if CSLRfidAppEngine.shared().temperatureSettings.reading == SENSORREADING.TEMPERATURE { if temperatureValue > MIN_TEMP_VALUE && temperatureValue < MAX_TEMP_VALUE { if CSLRfidAppEngine.shared().temperatureSettings.unit == TEMPERATUREUNIT.CELCIUS { @@ -124,7 +124,7 @@ } else { //S2 chip with lower moisture resolution if CSLRfidAppEngine.shared().temperatureSettings.moistureAlertCondition == ALERTCONDITION.GREATER { - let temp = (31 - temperatureValue) / (31); + let temp = (31.0 - temperatureValue) / (31.0); if (temp * 100.00) > Double(CSLRfidAppEngine.shared().temperatureSettings.moistureAlertValue) { btnTagStatus.backgroundColor = UIColorFromRGB(0xd63031) btnTagStatus.setTitle("High", for: .normal) @@ -133,7 +133,7 @@ btnTagStatus.setTitle("Normal", for: .normal) } } else { - let temp = (31 - temperatureValue) / (31); + let temp = (31.0 - temperatureValue) / (31.0); if (temp * 100.00) < Double(CSLRfidAppEngine.shared().temperatureSettings.moistureAlertValue) { btnTagStatus.backgroundColor = UIColorFromRGB(0x74b9ff) btnTagStatus.setTitle("Low", for: .normal) @@ -150,29 +150,50 @@ } if CSLRfidAppEngine.shared().temperatureSettings.sensorType == SENSORTYPE.XERXES { - if (data1?.count ?? 0) >= 16 { - lbCalibration.text = (data1 as NSString?)?.substring(to: 15) + if data1.count >= 16 { + //lbCalibration.text = (data1 as NSString?)?.substring(to: 15) + lbCalibration.text=String(data1[data1.startIndex..= 20 { - lbSensorCode.text = (data2 as NSString?)?.substring(with: NSRange(location: 8, length: 4)) - lbOCRSSI.text = (data2 as NSString?)?.substring(with: NSRange(location: 12, length: 4)) - lbTemperatureCode.text = (data2 as NSString?)?.substring(with: NSRange(location: 16, length: 4)) + if data2.count >= 20 { + //lbSensorCode.text = (data2 as NSString?)?.substring(with: NSRange(location: 8, length: 4)) + //lbOCRSSI.text = (data2 as NSString?)?.substring(with: NSRange(location: 12, length: 4)) + //lbTemperatureCode.text = (data2 as NSString?)?.substring(with: NSRange(location: 16, length: 4)) + let range1 = data2.index(data2.startIndex, offsetBy: 8)..= 16 { - lbCalibration.text = (data2 as NSString?)?.substring(to: 15) + if data2.count >= 16 { + //lbCalibration.text = (data2 as NSString?)?.substring(to: 15) + let range = data2.startIndex..= 12 { - lbSensorCode.text = (data1 as NSString?)?.substring(with: NSRange(location: 0, length: 4)) - lbOCRSSI.text = (data1 as NSString?)?.substring(with: NSRange(location: 4, length: 4)) - lbTemperatureCode.text = (data1 as NSString?)?.substring(with: NSRange(location: 8, length: 4)) + if data1.count >= 12 { + //lbSensorCode.text = (data1 as NSString?)?.substring(with: NSRange(location: 0, length: 4)) + //lbOCRSSI.text = (data1 as NSString?)?.substring(with: NSRange(location: 4, length: 4)) + //lbTemperatureCode.text = (data1 as NSString?)?.substring(with: NSRange(location: 8, length: 4)) + let range1 = data1.startIndex..= 4 && (data2?.count ?? 0) >= 4 { + if data1.count >= 4 && data2.count >= 4 { lbCalibration.text = "-" - lbSensorCode.text = (data1 as NSString?)?.substring(with: NSRange(location: 0, length: 4)) - lbOCRSSI.text = (data2 as NSString?)?.substring(with: NSRange(location: 0, length: 4)) + //lbSensorCode.text = (data1 as NSString?)?.substring(with: NSRange(location: 0, length: 4)) + //lbOCRSSI.text = (data2 as NSString?)?.substring(with: NSRange(location: 0, length: 4)) lbTemperatureCode.text = "-" + let range1 = data1.startIndex..(mutating: &ocrssi)) + ocrssi = UInt32((data2 as NSString?)?.substring(with: NSRange(location: 12, length: 4)) ?? "0", radix: 16)! ocrssi &= 0x0000001f } else { if CSLRfidAppEngine.shared().temperatureSettings.sensorType == SENSORTYPE.MAGNUSS3 { - scanner = Scanner(string: (data1 as NSString?)?.substring(with: NSRange(location: 4, length: 4)) ?? "") + ocrssi = UInt32((data1 as NSString?)?.substring(with: NSRange(location: 4, length: 4)) ?? "0", radix: 16)! } else { - scanner = Scanner(string: (data2 as NSString?)?.substring(with: NSRange(location: 0, length: 4)) ?? "") + ocrssi = UInt32((data2 as NSString?)?.substring(with: NSRange(location: 0, length: 4)) ?? "0", radix: 16)! } - scanner?.scanHexInt32(UnsafeMutablePointer(mutating: &ocrssi)) ocrssi &= 0x0000001f } diff --git a/CS108iOSClient/ViewControllers/CSLTemperatureTabVC.swift b/CS108iOSClient/ViewControllers/CSLTemperatureTabVC.swift index 876c55c..5751423 100644 --- a/CS108iOSClient/ViewControllers/CSLTemperatureTabVC.swift +++ b/CS108iOSClient/ViewControllers/CSLTemperatureTabVC.swift @@ -150,7 +150,7 @@ for i in 0..<4 { let dwell = Int(CSLRfidAppEngine.shared().settings.dwellTime[i] as! String) let power = Int(CSLRfidAppEngine.shared().settings.powerLevel[i] as! String) - let portEnabled = (CSLRfidAppEngine.shared().settings.isPortEnabled[i] as! NSNumber).boolValue + let portEnabled = Bool(truncating: CSLRfidAppEngine.shared().settings.isPortEnabled[i] as! NSNumber) CSLRfidAppEngine.shared().reader.selectAntennaPort(UInt(i)) print("Antenna \(i): \(portEnabled ? "ON" : "OFF")") CSLRfidAppEngine.shared().reader.setAntennaConfig(portEnabled, inventoryMode: 0, inventoryAlgo: 0, startQ: 0, profileMode: 0, profile: 0, frequencyMode: 0, frequencyChannel: 0, isEASEnabled: false) @@ -218,13 +218,13 @@ CSLRfidAppEngine.shared().reader.selectAlgorithmParameter(QUERYALGORITHM.DYNAMICQ) CSLRfidAppEngine.shared().reader.setInventoryAlgorithmParameters0(UInt8(CSLRfidAppEngine.shared().settings.qValue), maximumQ: 15, minimumQ: 0, thresholdMultiplier: 4) //0x0903 CSLRfidAppEngine.shared().reader.setInventoryAlgorithmParameters1(5) - CSLRfidAppEngine.shared().reader.setInventoryAlgorithmParameters2((CSLRfidAppEngine.shared().settings.target == TARGET.ToggleAB ? true : false), runTillZero: false) //x0905 + CSLRfidAppEngine.shared().reader.setInventoryAlgorithmParameters2(true /*hardcoding toggle A/B*/, runTillZero: false) //x0905 CSLRfidAppEngine.shared().reader.setInventoryConfigurations(QUERYALGORITHM.DYNAMICQ, matchRepeats: 0, tagSelect: 0, disableInventory: 0, tagRead: 0, crcErrorRead: 0, qtMode: 0, tagDelay: 0, inventoryMode: 0) //0x0901 CSLRfidAppEngine.shared().reader.selectAlgorithmParameter(QUERYALGORITHM.FIXEDQ) CSLRfidAppEngine.shared().reader.setInventoryAlgorithmParameters0(UInt8(CSLRfidAppEngine.shared().settings.qValue), maximumQ: 0, minimumQ: 0, thresholdMultiplier: 0) //0x0903 CSLRfidAppEngine.shared().reader.setInventoryAlgorithmParameters1(5) - CSLRfidAppEngine.shared().reader.setInventoryAlgorithmParameters2((CSLRfidAppEngine.shared().settings.target == TARGET.ToggleAB ? true : false), runTillZero: false) //x0905 + CSLRfidAppEngine.shared().reader.setInventoryAlgorithmParameters2(true /*hardcoding toggle A/B*/, runTillZero: false) //x0905 CSLRfidAppEngine.shared().reader.setInventoryConfigurations(QUERYALGORITHM.FIXEDQ, matchRepeats: 0, tagSelect: 0, disableInventory: 0, tagRead: 0, crcErrorRead: 0, qtMode: 0, tagDelay: 0, inventoryMode: 0) //0x0901 CSLRfidAppEngine.shared().reader.setQueryConfigurations(TARGET.A, querySession: SESSION.S1, querySelect: QUERYSELECT.SL) @@ -261,6 +261,18 @@ CSLRfidAppEngine.shared().reader.setInventoryCycleDelay(0) CSLRfidAppEngine.shared().reader.setInventoryConfigurations(CSLRfidAppEngine.shared().settings.algorithm, matchRepeats: 0, tagSelect: 0, disableInventory: 0, tagRead: tagRead, crcErrorRead: 1, qtMode: 0, tagDelay: (tagRead != 0 ? 30 : 0), inventoryMode: (tagRead != 0 ? 0 : 1)) + //frequency configurations + if CSLRfidAppEngine.shared().readerRegionFrequency.isFixed != 0 { + CSLRfidAppEngine.shared().reader.setFixedChannel( + CSLRfidAppEngine.shared().readerRegionFrequency, + regionCode: CSLRfidAppEngine.shared().settings.region, + channelIndex: UInt32(CSLRfidAppEngine.shared().settings.channel)!) + } else { + CSLRfidAppEngine.shared().reader.setHoppingChannel( + CSLRfidAppEngine.shared().readerRegionFrequency, + regionCode: CSLRfidAppEngine.shared().settings.region) + } + // if multibank read is enabled if tagRead != 0 { CSLRfidAppEngine.shared().reader.tagacc_BANK(CSLRfidAppEngine.shared().settings.multibank1, acc_bank2: CSLRfidAppEngine.shared().settings.multibank2) diff --git a/CS108iOSClient/ViewControllers/CSLTemperatureTagListCell.swift b/CS108iOSClient/ViewControllers/CSLTemperatureTagListCell.swift index 9058f67..af8a28f 100644 --- a/CS108iOSClient/ViewControllers/CSLTemperatureTagListCell.swift +++ b/CS108iOSClient/ViewControllers/CSLTemperatureTagListCell.swift @@ -31,7 +31,6 @@ } class func calculateCalibratedTemperatureValue(_ tempCodeInHexString: String?, calibration calibrationInHexString: String?) -> Double { - var scanner: Scanner? var tmp: UInt32 = 0 var temperatureCode: UInt32 = 0 var code1: UInt32 = 0 @@ -45,26 +44,22 @@ var temperatureValue = 0.0 //temperature code - scanner = Scanner(string: tempCodeInHexString ?? "") - scanner?.scanHexInt32(UnsafeMutablePointer(mutating: &temperatureCode)) + temperatureCode = UInt32(tempCodeInHexString ?? "0", radix: 16)! temperatureCode &= 0x00000fff //least significant bits //Calibration - CODE1 - scanner = Scanner(string: (calibrationInHexString as NSString?)?.substring(with: NSRange(location: 4, length: 4)) ?? "") - scanner?.scanHexInt32(UnsafeMutablePointer(mutating: &tmp)) + tmp = UInt32((calibrationInHexString as NSString?)?.substring(with: NSRange(location: 4, length: 4)) ?? "0", radix: 16)! temp1_1 = (tmp << 7) & 0x00000780 //capture the partial TEMP1 from the 0x9 address code1 = (tmp >> 4) & 0x00000fff //least significant bits //Calibration - TEMP1 - scanner = Scanner(string: (calibrationInHexString as NSString?)?.substring(with: NSRange(location: 8, length: 4)) ?? "") - scanner?.scanHexInt32(UnsafeMutablePointer(mutating: &tmp)) + tmp = UInt32((calibrationInHexString as NSString?)?.substring(with: NSRange(location: 8, length: 4)) ?? "0", radix: 16)! code2_1 = (tmp << 3) & 0x00000ff8 //capture the partial CODE2 from the 0xA address temp1_2 = (tmp >> 9) & 0x0000007f //least significant bits temp1 = temp1_1 + temp1_2 //Calibration - CODE2 - scanner = Scanner(string: (calibrationInHexString as NSString?)?.substring(with: NSRange(location: 12, length: 4)) ?? "") - scanner?.scanHexInt32(UnsafeMutablePointer(mutating: &tmp)) + tmp = UInt32((calibrationInHexString as NSString?)?.substring(with: NSRange(location: 12, length: 4)) ?? "0", radix: 16)! code2_2 = (tmp >> 13) & 0x00000007 //least significant bits code2 = code2_1 + code2_2 diff --git a/CS108iOSClient/ViewControllers/CSLTemperatureTagSettingsVC.swift b/CS108iOSClient/ViewControllers/CSLTemperatureTagSettingsVC.swift index 85bf628..64e69bc 100644 --- a/CS108iOSClient/ViewControllers/CSLTemperatureTagSettingsVC.swift +++ b/CS108iOSClient/ViewControllers/CSLTemperatureTagSettingsVC.swift @@ -113,7 +113,7 @@ class CSLTemperatureTagSettingsVC: UIViewController, UITextFieldDelegate { @IBAction func btnSavePressed(_ sender: Any) { //store the UI input to the settings object on appEng CSLRfidAppEngine.shared().temperatureSettings.isTemperatureAlertEnabled = swEnableTemperatureAlert.isOn - if scTemperatureUnit.selectedSegmentIndex == (TEMPERATUREUNIT.CELCIUS.rawValue.boolValue ? 1 : 0) { + if scTemperatureUnit.selectedSegmentIndex == TEMPERATUREUNIT.CELCIUS.rawValue { CSLRfidAppEngine.shared().temperatureSettings.temperatureAlertUpperLimit = Double(txtHighTemperatureThreshold.text!)! CSLRfidAppEngine.shared().temperatureSettings.temperatureAlertLowerLimit = Double(txtLowTemperatureThreshold.text!)! } else { @@ -123,7 +123,7 @@ class CSLTemperatureTagSettingsVC: UIViewController, UITextFieldDelegate { CSLRfidAppEngine.shared().temperatureSettings.rssiUpperLimit = Int32(Int(txtOcrssiMax.text!)!) CSLRfidAppEngine.shared().temperatureSettings.rssiLowerLimit = Int32(txtOcrssiMin.text!)! CSLRfidAppEngine.shared().temperatureSettings.numberOfRollingAvergage = Int32(txtNumberOfTemperatureAveraging.text!)! - CSLRfidAppEngine.shared().temperatureSettings.unit = TEMPERATUREUNIT(rawValue: scTemperatureUnit.selectedSegmentIndex == 0 ? false : true)! + CSLRfidAppEngine.shared().temperatureSettings.unit = TEMPERATUREUNIT(rawValue: UInt8(scTemperatureUnit.selectedSegmentIndex))! if btnSensorType.currentTitle?.contains("Xerxes") ?? false { CSLRfidAppEngine.shared().temperatureSettings.sensorType = SENSORTYPE.XERXES } else { @@ -141,9 +141,9 @@ class CSLTemperatureTagSettingsVC: UIViewController, UITextFieldDelegate { CSLRfidAppEngine.shared().temperatureSettings.powerLevel = POWERLEVEL.SYSTEMSETTING } - CSLRfidAppEngine.shared().temperatureSettings.tagIdFormat = (swDisplayTagInAscii.isOn ? TAGIDFORMAT(rawValue: true) : TAGIDFORMAT(rawValue: false))! + CSLRfidAppEngine.shared().temperatureSettings.tagIdFormat = (swDisplayTagInAscii.isOn ? TAGIDFORMAT.ASCII : TAGIDFORMAT.HEX) CSLRfidAppEngine.shared().temperatureSettings.moistureAlertCondition = btnMoistureCompare.currentTitle?.contains(">") ?? false ? ALERTCONDITION.GREATER : ALERTCONDITION.LESSTHAN - CSLRfidAppEngine.shared().temperatureSettings.moistureAlertValue = Int32(Int(txtMoistureValue.text!)!) + CSLRfidAppEngine.shared().temperatureSettings.moistureAlertValue = Int32(txtMoistureValue.text!)! CSLRfidAppEngine.shared().saveTemperatureTagSettingsToUserDefaults() //refresh configurations and clear previous readings on sensor read table view @@ -169,83 +169,97 @@ class CSLTemperatureTagSettingsVC: UIViewController, UITextFieldDelegate { } @IBAction func txtLowTemperatureThresholdChanged(_ sender: Any) { - let scan = Scanner(string: txtLowTemperatureThreshold.text!) - var val: Double = 0.0 + let val = Double(txtLowTemperatureThreshold.text!) var lowLimit: Double var highLimit: Double - if scTemperatureUnit.selectedSegmentIndex == (TEMPERATUREUNIT.CELCIUS.rawValue.boolValue ? 1 : 0) { + if scTemperatureUnit.selectedSegmentIndex == Int(TEMPERATUREUNIT.CELCIUS.rawValue) { lowLimit = MIN_TEMP_VALUE highLimit = MAX_TEMP_VALUE } else { lowLimit = CSLTemperatureTagSettings.convertCelcius(toFahrenheit: MIN_TEMP_VALUE) highLimit = CSLTemperatureTagSettings.convertCelcius(toFahrenheit: MAX_TEMP_VALUE) } - if scan.scanDouble(UnsafeMutablePointer(mutating: &val)) && scan.isAtEnd && Double(txtLowTemperatureThreshold.text!)! >= lowLimit && Double(txtLowTemperatureThreshold.text!)! <= highLimit { - print("Low temperature threshold entered: OK") - txtLowTemperatureThreshold.text = String(format: "%3.1f", val) - } else { - //invalid input. reset to stored configurations - if CSLRfidAppEngine.shared().temperatureSettings.unit == TEMPERATUREUNIT.CELCIUS { - txtLowTemperatureThreshold.text = String(format: "%3.1f", CSLRfidAppEngine.shared().temperatureSettings.temperatureAlertLowerLimit) - } else { - txtLowTemperatureThreshold.text = String(format: "%3.1f", CSLTemperatureTagSettings.convertCelcius(toFahrenheit: CSLRfidAppEngine.shared().temperatureSettings.temperatureAlertLowerLimit)) + if val != nil { + if Double(txtLowTemperatureThreshold.text!)! >= lowLimit && Double(txtLowTemperatureThreshold.text!)! <= highLimit { + print("Low temperature threshold entered: OK") + txtLowTemperatureThreshold.text = String(format: "%3.1f", val!) + return } } + + //invalid input. reset to stored configurations + if CSLRfidAppEngine.shared().temperatureSettings.unit == TEMPERATUREUNIT.CELCIUS { + txtLowTemperatureThreshold.text = String(format: "%3.1f", CSLRfidAppEngine.shared().temperatureSettings.temperatureAlertLowerLimit) + } else { + txtLowTemperatureThreshold.text = String(format: "%3.1f", CSLTemperatureTagSettings.convertCelcius(toFahrenheit: CSLRfidAppEngine.shared().temperatureSettings.temperatureAlertLowerLimit)) + } + } @IBAction func txtHighTemperatureThresholdChanged(_ sender: Any) { - let scan = Scanner(string: txtHighTemperatureThreshold.text!) - var val: Double = 0.0 + let val = Double(txtHighTemperatureThreshold.text!) var lowLimit: Double var highLimit: Double - if scTemperatureUnit.selectedSegmentIndex == (TEMPERATUREUNIT.CELCIUS.rawValue.boolValue ? 1 : 0) { + if scTemperatureUnit.selectedSegmentIndex == Int(TEMPERATUREUNIT.CELCIUS.rawValue) { lowLimit = MIN_TEMP_VALUE highLimit = MAX_TEMP_VALUE } else { lowLimit = CSLTemperatureTagSettings.convertCelcius(toFahrenheit: MIN_TEMP_VALUE) highLimit = CSLTemperatureTagSettings.convertCelcius(toFahrenheit: MAX_TEMP_VALUE) } - if scan.scanDouble(UnsafeMutablePointer(mutating: &val)) && scan.isAtEnd && Double(txtHighTemperatureThreshold.text!)! >= lowLimit && Double(txtHighTemperatureThreshold.text!)! <= highLimit { - print("High temperature threshold entered: OK") - txtHighTemperatureThreshold.text = String(format: "%3.1f", val) - } else { - //invalid input. reset to stored configurations - if CSLRfidAppEngine.shared().temperatureSettings.unit == TEMPERATUREUNIT.CELCIUS { - txtHighTemperatureThreshold.text = String(format: "%3.1f", CSLRfidAppEngine.shared().temperatureSettings.temperatureAlertUpperLimit) - } else { - txtHighTemperatureThreshold.text = String(format: "%3.1f", CSLTemperatureTagSettings.convertCelcius(toFahrenheit: CSLRfidAppEngine.shared().temperatureSettings.temperatureAlertUpperLimit)) + if val != nil { + if Double(txtHighTemperatureThreshold.text!)! >= lowLimit && Double(txtHighTemperatureThreshold.text!)! <= highLimit { + print("High temperature threshold entered: OK") + txtHighTemperatureThreshold.text = String(format: "%3.1f", val!) + return } + } + //invalid input. reset to stored configurations + if CSLRfidAppEngine.shared().temperatureSettings.unit == TEMPERATUREUNIT.CELCIUS { + txtHighTemperatureThreshold.text = String(format: "%3.1f", CSLRfidAppEngine.shared().temperatureSettings.temperatureAlertUpperLimit) + } else { + txtHighTemperatureThreshold.text = String(format: "%3.1f", CSLTemperatureTagSettings.convertCelcius(toFahrenheit: CSLRfidAppEngine.shared().temperatureSettings.temperatureAlertUpperLimit)) + } + } @IBAction func txtOcrssiMinChanged(_ sender: Any) { - let scan = Scanner(string: txtOcrssiMin.text!) - var val: Int32 = 0 - if scan.scanInt32(UnsafeMutablePointer(mutating: &val)) && scan.isAtEnd && Int32(txtOcrssiMin.text!)! >= 0 && Int32(txtOcrssiMin.text!)! <= 31 { - print("On-chip RSSI low value entered: OK") - } else { - txtOcrssiMin.text = "\(CSLRfidAppEngine.shared().temperatureSettings.rssiLowerLimit)" + let val = Int32(txtOcrssiMin.text!) + if val != nil + { + if Int32(txtOcrssiMin.text!)! >= 0 && Int32(txtOcrssiMin.text!)! <= 31 { + print("On-chip RSSI low value entered: OK") + return + } } + txtOcrssiMin.text = "\(CSLRfidAppEngine.shared().temperatureSettings.rssiLowerLimit)" + } @IBAction func txtOcrssiMaxChanged(_ sender: Any) { - let scan = Scanner(string: txtOcrssiMax.text!) - var val: Int32 = 0 - if scan.scanInt32(UnsafeMutablePointer(mutating: &val)) && scan.isAtEnd && Int32(txtOcrssiMax.text!)! >= 0 && Int32(txtOcrssiMax.text!)! <= 31 { - print("On-chip RSSI high value entered: OK") - } else { - txtOcrssiMax.text = "\(CSLRfidAppEngine.shared().temperatureSettings.rssiUpperLimit)" + let val = Int32(txtOcrssiMax.text!) + if val != nil + { + if Int32(txtOcrssiMax.text!)! >= 0 && Int32(txtOcrssiMax.text!)! <= 31 { + print("On-chip RSSI high value entered: OK") + return + } } + txtOcrssiMax.text = "\(CSLRfidAppEngine.shared().temperatureSettings.rssiUpperLimit)" + } @IBAction func txtNumberOfTemperatureAveragingChanged(_ sender: Any) { - let scan = Scanner(string: txtNumberOfTemperatureAveraging.text!) - var val: Int32 = 0 - if scan.scanInt32(UnsafeMutablePointer(mutating: &val)) && scan.isAtEnd && Int32(txtNumberOfTemperatureAveraging.text!)! >= 0 && Int32(txtNumberOfTemperatureAveraging.text!)! <= 10 { - print("Temperature averaging value entered: OK") - } else { - txtNumberOfTemperatureAveraging.text = "\(CSLRfidAppEngine.shared().temperatureSettings.numberOfRollingAvergage)" + let val = Int32(txtNumberOfTemperatureAveraging.text!) + if val != nil { + if Int32(txtNumberOfTemperatureAveraging.text!)! >= 0 && Int32(txtNumberOfTemperatureAveraging.text!)! <= 10 { + print("Temperature averaging value entered: OK") + return + } } + txtNumberOfTemperatureAveraging.text = "\(CSLRfidAppEngine.shared().temperatureSettings.numberOfRollingAvergage)" + } @IBAction func btnSensorTypePressed(_ sender: Any) { @@ -296,11 +310,12 @@ class CSLTemperatureTagSettingsVC: UIViewController, UITextFieldDelegate { } @IBAction func btnMoistureValueChanged(_ sender: Any) { - let scan = Scanner(string: txtMoistureValue.text!) - var val: Int32 = 0 - if scan.scanInt32(UnsafeMutablePointer(mutating: &val)) && scan.isAtEnd && Int32(txtMoistureValue.text!)! >= 0 && Int32(txtMoistureValue.text!)! <= 100 { - print("Moisture alert value entered: OK") - } else { + let val = Int32(txtMoistureValue.text!) + if val != nil { + if Int32(txtMoistureValue.text!)! >= 0 && Int32(txtMoistureValue.text!)! <= 100 { + print("Moisture alert value entered: OK") + return + } txtMoistureValue.text = "\(CSLRfidAppEngine.shared().temperatureSettings.moistureAlertValue)" } } @@ -352,7 +367,9 @@ class CSLTemperatureTagSettingsVC: UIViewController, UITextFieldDelegate { } @IBAction func segmentChangeViewValueChanged(_ SControl: UISegmentedControl?) { - if scTemperatureUnit.selectedSegmentIndex == (TEMPERATUREUNIT.CELCIUS.rawValue.boolValue ? 1 : 0) { + let unit = Int(TEMPERATUREUNIT.CELCIUS.rawValue) + + if scTemperatureUnit.selectedSegmentIndex == unit { txtLowTemperatureThreshold.text = String(format: "%3.1f", CSLTemperatureTagSettings.convertFahrenheit(toCelcius: Double(txtLowTemperatureThreshold.text!)!)) txtHighTemperatureThreshold.text = String(format: "%3.1f", CSLTemperatureTagSettings.convertFahrenheit(toCelcius: Double(txtHighTemperatureThreshold.text!)!)) } else { diff --git a/CS108iOSClient/ViewControllers/CSLTemperatureUploadVC.swift b/CS108iOSClient/ViewControllers/CSLTemperatureUploadVC.swift index e611699..12501e5 100644 --- a/CS108iOSClient/ViewControllers/CSLTemperatureUploadVC.swift +++ b/CS108iOSClient/ViewControllers/CSLTemperatureUploadVC.swift @@ -54,7 +54,7 @@ if CSLRfidAppEngine.shared().mqttSettings.mqttStatus == .connected || CSLRfidAppEngine.shared().mqttSettings.mqttStatus == .error { break } - Thread.sleep(forTimeInterval: 0.1) + Thread.sleep(forTimeInterval: 0.001) } actMQTTConnectIndicator.stopAnimating() if CSLRfidAppEngine.shared().mqttSettings.mqttStatus == .connected { @@ -211,7 +211,7 @@ break } //Thread.sleep(forTimeInterval: 0.1) - (RunLoop.current.run(mode: .default, before: Date(timeIntervalSinceNow: 0.1))) + (RunLoop.current.run(mode: .default, before: Date(timeIntervalSinceNow: 0.001))) } diff --git a/CS108iOSClient/model/CSLReaderBattery.m b/CS108iOSClient/model/CSLReaderBattery.m index ec50e46..571cbae 100644 --- a/CS108iOSClient/model/CSLReaderBattery.m +++ b/CS108iOSClient/model/CSLReaderBattery.m @@ -10,9 +10,10 @@ @implementation CSLReaderBattery -static double _voltageFirstOffset; -static double _voltagestep; +//static double _voltageFirstOffset; +//static double _voltagestep; static NSArray* _voltageTable; +static NSArray* _capacityTable; static NSMutableArray* _voltageSlope; static BATTERYMODE _currentInventoryMode; static double _pcbVersion; @@ -35,6 +36,7 @@ - (void) setPcbVersion:(double)pcbVersion { _pcbVersion=pcbVersion; } +/* - (void) setBatteryMode: (BATTERYMODE) bm { int cnt; @@ -77,7 +79,37 @@ - (void) setBatteryMode: (BATTERYMODE) bm { } } } +*/ +- (void) setBatteryMode: (BATTERYMODE) bm { + + int cnt; + _currentInventoryMode = bm; + + if (bm == INVENTORY) + { + _voltageTable=[NSArray arrayWithObjects:@3.921f, @3.890f, @3.863f, @3.826f, @3.795f, @3.768f, @3.742f, @3.721f, @3.700f, @3.679f, @3.652f, @3.642f, @3.621f, @3.605f, @3.589f, @3.573f, @3.563f, @3.557f, @3.552f, @3.536f, @3.526f, @3.520f, @3.499f, @3.478f, @3.457f, @3.415f, @3.241f, @2.612f, nil]; + _capacityTable=[NSArray arrayWithObjects:@100.0f, @99.0f, @98.0f, @97.0f, @96.0f, @94.0f, @92.0f, @89.0f, @85.0f, @80.0f, @75.0f, @70.0f, @65.0f, @60.0f, @55.0f, @50.0f, @45.0f, @40.0f, @35.0f, @30.0f, @24.0f, @20.0f, @16.0f, @13.0f, @9.0f, @6.0f, @2.0f, @0.0f, nil]; + + _voltageSlope=[[NSMutableArray alloc] init]; + for (cnt = 0; cnt < [_voltageTable count] - 2; cnt++) { + [_voltageSlope addObject:@(([[_capacityTable objectAtIndex:cnt] doubleValue] - [[_capacityTable objectAtIndex:cnt + 1] doubleValue]) / ([[_voltageTable objectAtIndex:cnt] doubleValue] - [[_voltageTable objectAtIndex:cnt + 1] doubleValue]))]; + } + } + else //idle + { + _voltageTable=[NSArray arrayWithObjects:@4.048f, @4.032f, @4.011f, @3.995f, @3.974f, @3.964f, @3.948f, @3.932f, @3.911f, @3.895f, @3.879f, @3.863f, @3.853f, @3.842f, @3.826f, @3.811f, @3.800f, @3.784f, @3.774f, @3.758f, @3.747f, @3.737f, @3.726f, @3.721f, @3.710f, @3.705f, @3.695f, @3.689f, @3.684f, @3.679f, @3.673f, @3.668f, @3.663f, @3.658f, @3.658f, @3.652f, @3.647f, @3.642f, @3.636f, @3.631f, @3.626f, @3.615f, @3.605f, @3.594f, @3.578f, @3.573f, @3.563f, @3.552f, @3.504f, @3.394f, @3.124f, @2.517f, nil]; + _capacityTable=[NSArray arrayWithObjects:@100.0f, @99.0f, @98.0f, @97.0f, @95.0f, @93.0f, @90.0f, @87.0f, @84.0f, @81.0f, @78.0f, @75.0f, @73.0f, @71.0f, @69.0f, @68.0f, @66.0f, @64.0f, @62.0f, @60.0f, @58.0f, @56.0f, @54.0f, @52.0f, @50.0f, @48.0f, @47.0f, @45.0f, @43.0f, @41.0f, @39.0f, @37.0f, @35.0f, @33.0f, @31.0f, @29.0f, @27.0f, @26.0f, @24.0f, @22.0f, @20.0f, @18.0f, @16.0f, @14.0f, @12.0f, @10.0f, @8.0f, @6.0f, @5.0f, @3.0f, @1.0f, @0.0f, nil]; + + _voltageSlope=[[NSMutableArray alloc] init]; + for (cnt = 0; cnt < [_voltageTable count] - 2; cnt++) { + [_voltageSlope addObject:@(([[_capacityTable objectAtIndex:cnt] doubleValue] - [[_capacityTable objectAtIndex:cnt + 1] doubleValue]) / ([[_voltageTable objectAtIndex:cnt] doubleValue] - [[_voltageTable objectAtIndex:cnt + 1] doubleValue]))]; + } + } + +} + +/* - (int) getBatteryPercentageByVoltage: (double) voltage { int cnt; @@ -110,4 +142,33 @@ - (int) getBatteryPercentageByVoltage: (double) voltage { return -1; } + */ + +- (int) getBatteryPercentageByVoltage: (double) voltage { + + int cnt; + + if (voltage > [[_voltageTable objectAtIndex:0] doubleValue]) + return 100; + + if (voltage <= [[_voltageTable objectAtIndex:[_voltageTable count]-1] doubleValue]) + return 0; + + for (cnt = (int)([_voltageTable count] - 2); cnt >= 0; cnt--) { + if (voltage > [[_voltageTable objectAtIndex:cnt] doubleValue]) + continue; + + if (voltage == [[_voltageTable objectAtIndex:cnt] doubleValue]) + return [[_capacityTable objectAtIndex:cnt] intValue]; + + double percent = 0; + + percent = (voltage - [[_voltageTable objectAtIndex:cnt+1] doubleValue]) * [[_voltageSlope objectAtIndex:cnt] doubleValue] + [[_capacityTable objectAtIndex:cnt+1] doubleValue]; + + return percent; + } + + return 0; +} + @end diff --git a/CS108iOSClient/model/CSLReaderFrequency.h b/CS108iOSClient/model/CSLReaderFrequency.h new file mode 100644 index 0000000..ef7a1b6 --- /dev/null +++ b/CS108iOSClient/model/CSLReaderFrequency.h @@ -0,0 +1,38 @@ +// +// CSLReaderFrequency.h +// CS108iOSClient +// +// Created by Lam Ka Shun on 2020-05-15. +// Copyright © 2020 Convergence Systems Limited. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface CSLReaderFrequency : NSObject + +///Device country code (OEM address 0x02) +@property (assign, readonly) UInt32 CountryCode; +///Special Country version (OEM address 0x8E) +@property (assign, readonly) UInt32 SpecialCountryVerison; +///frequency modification flag (OEM address 0x8F) +@property (assign, readonly) UInt32 FreqModFlag; +///Device model code (OEM address 0xA4) +@property (assign, readonly) UInt32 ModelCode; +///Hopping/Fixed frequency (OEM address 0x9D) +@property (assign, readonly) UInt32 isFixed; +///List of Regions based on the OEM data +@property NSMutableArray* RegionList; +///Provide a key with the region code and get an array of frequencies +@property NSMutableDictionary* TableOfFrequencies; +///Provide a key with the region code and get an array of frequency values +@property NSMutableDictionary* FrequencyValues; +///Provide a key with the region code and get an array of frequency index +@property NSMutableDictionary* FrequencyIndex; + +-(id)initWithOEMData:(UInt32)countryCode specialCountryVerison:(UInt32)special_country FreqModFlag:(UInt32)freq_mod_flag ModelCode:(UInt32)model_code isFixed:(UInt32)is_fixed; + +@end + +NS_ASSUME_NONNULL_END diff --git a/CS108iOSClient/model/CSLReaderFrequency.m b/CS108iOSClient/model/CSLReaderFrequency.m new file mode 100644 index 0000000..dac7d56 --- /dev/null +++ b/CS108iOSClient/model/CSLReaderFrequency.m @@ -0,0 +1,950 @@ +// +// CSLReaderFrequency.m +// CS108iOSClient +// +// Created by Lam Ka Shun on 2020-05-15. +// Copyright © 2020 Convergence Systems Limited. All rights reserved. +// + +#import "CSLReaderFrequency.h" + +@implementation CSLReaderFrequency +{ + NSArray* FCCTableOfFreq; + NSArray* AUTableOfFreq; + NSArray* CNTableOfFreq; + NSArray* ETSITableOfFreq; + NSArray* INTableOfFreq; + NSArray* HKTableOfFreq; + NSArray* JPTableOfFreq; + NSArray* KRTableOfFreq; + NSArray* MYTableOfFreq; + NSArray* TWTableOfFreq; + NSArray* ZATableOfFreq; + NSArray* BR1TableOfFreq; + NSArray* BR2TableOfFreq; + NSArray* BR3TableOfFreq; + NSArray* BR4TableOfFreq; + NSArray* BR5TableOfFreq; + NSArray* IDTableOfFreq; + NSArray* JETableOfFreq; + NSArray* PHTableOfFreq; + NSArray* ETSIUPPERBANDTableOfFreq; + NSArray* NZTableOfFreq; + NSArray* UH1TableOfFreq; + NSArray* UH2TableOfFreq; + NSArray* LHTableOfFreq; + NSArray* LH1TableOfFreq; + NSArray* LH2TableOfFreq; + NSArray* VNTableOfFreq; + + NSArray* FCCFreqValues; + NSArray* AUFreqValues; + NSArray* CNFreqValues; + NSArray* ETSIFreqValues; + NSArray* INFreqValues; + NSArray* HKFreqValues; + NSArray* JPFreqValues; + NSArray* KRFreqValues; + NSArray* MYFreqValues; + NSArray* TWFreqValues; + NSArray* ZAFreqValues; + NSArray* BR1FreqValues; + NSArray* BR2FreqValues; + NSArray* BR3FreqValues; + NSArray* BR4FreqValues; + NSArray* BR5FreqValues; + NSArray* IDFreqValues; + NSArray* JEFreqValues; + NSArray* PHFreqValues; + NSArray* ETSIUPPERBANDFreqValues; + NSArray* NZFreqValues; + NSArray* UH1FreqValues; + NSArray* UH2FreqValues; + NSArray* LHFreqValues; + NSArray* LH1FreqValues; + NSArray* LH2FreqValues; + NSArray* VNFreqValues; + + NSArray* FCCFreqIndex; + NSArray* AUFreqIndex; + NSArray* CNFreqIndex; + NSArray* ETSIFreqIndex; + NSArray* INFreqIndex; + NSArray* HKFreqIndex; + NSArray* JPFreqIndex; + NSArray* KRFreqIndex; + NSArray* MYFreqIndex; + NSArray* TWFreqIndex; + NSArray* ZAFreqIndex; + NSArray* BR1FreqIndex; + NSArray* BR2FreqIndex; + NSArray* BR3FreqIndex; + NSArray* BR4FreqIndex; + NSArray* BR5FreqIndex; + NSArray* IDFreqIndex; + NSArray* JEFreqIndex; + NSArray* PHFreqIndex; + NSArray* ETSIUPPERBANDFreqIndex; + NSArray* NZFreqIndex; + NSArray* UH1FreqIndex; + NSArray* UH2FreqIndex; + NSArray* LHFreqIndex; + NSArray* LH1FreqIndex; + NSArray* LH2FreqIndex; + NSArray* VNFreqIndex; + +} + +-(id)init { + + //set default values to CS108 FCC fixed + self = [self initWithOEMData:2 specialCountryVerison:0 FreqModFlag:0xAA ModelCode:0x0B isFixed:0x00]; + return self; +} + +-(id)initWithOEMData:(UInt32)countryCode specialCountryVerison:(UInt32)special_country FreqModFlag:(UInt32)freq_mod_flag ModelCode:(UInt32)model_code isFixed:(UInt32)is_fixed { + if (self = [super init]) { + //set default values + _CountryCode=countryCode; + _SpecialCountryVerison=special_country; + _FreqModFlag=freq_mod_flag; + _ModelCode=model_code; + _isFixed=is_fixed; + [self generateTableOfFreq]; + } + return self; +} + +-(void)generateRegionList { + + self.RegionList = [[NSMutableArray alloc] init]; + + switch (self.CountryCode) + { + //-1 CE for Europe for India + case 1: + [self.RegionList addObject:@"ETSI"]; + [self.RegionList addObject:@"IN"]; + [self.RegionList addObject:@"G800"]; + break; + case 2: + //-2 RW (rest-of-the-world) + if (self.FreqModFlag == 0x00) + { + [self.RegionList addObject:@"FCC"]; //FCC USA &Canada + [self.RegionList addObject:@"AR"]; //Argentina + [self.RegionList addObject:@"BR1"]; //Brazil 1 + [self.RegionList addObject:@"BR2"]; //Brazil 2 + [self.RegionList addObject:@"BR3"]; //Brazil 3 + [self.RegionList addObject:@"BR4"]; //Brazil 4 + [self.RegionList addObject:@"BR5"]; //Brazil 5 + [self.RegionList addObject:@"CL"]; //Chile + [self.RegionList addObject:@"CO"]; //Columbia + [self.RegionList addObject:@"CR"]; //Costa Rica + [self.RegionList addObject:@"DO"]; //Dominican Republic + [self.RegionList addObject:@"HK"]; //Hong Kong + [self.RegionList addObject:@"ID"]; //Indonesia + [self.RegionList addObject:@"JE"]; //Jersey 915-917 MHz + [self.RegionList addObject:@"KR"]; //Korea + [self.RegionList addObject:@"MY"]; //Malaysia + [self.RegionList addObject:@"PA"]; //Panama + [self.RegionList addObject:@"PE"]; //Peru + [self.RegionList addObject:@"PH"]; //Philippnes + [self.RegionList addObject:@"SG"]; //Singapore + [self.RegionList addObject:@"TH"]; //Thailand + [self.RegionList addObject:@"UY"]; //Uruguay + [self.RegionList addObject:@"VN"]; //Vietnam + [self.RegionList addObject:@"ZA"]; //South Africa + [self.RegionList addObject:@"LH1"]; + [self.RegionList addObject:@"LH2"]; + [self.RegionList addObject:@"UH1"]; + [self.RegionList addObject:@"UH2"]; + + } + else + { // HK USA AU ZA + switch (self.SpecialCountryVerison) + { + default: // and case 0x2a555341 + [self.RegionList addObject:@"FCC"]; + break; + case 0x4f464341: + [self.RegionList addObject:@"HK"]; + break; + case 0x2a2a4153: + [self.RegionList addObject:@"AU"]; + break; + case 0x2a2a4e5a: + [self.RegionList addObject:@"NZ"]; + break; + } + } + break; + case 4: //Taiwan NCC + [self.RegionList addObject:@"TW"]; + [self.RegionList addObject:@"AU"]; + [self.RegionList addObject:@"CN"]; + [self.RegionList addObject:@"HK"]; + [self.RegionList addObject:@"ID"]; + [self.RegionList addObject:@"MY"]; + [self.RegionList addObject:@"SG"]; + break; + case 6: + [self.RegionList addObject:@"KR"]; + break; + case 7: + [self.RegionList addObject:@"CN"]; + [self.RegionList addObject:@"HK"]; + [self.RegionList addObject:@"AU"]; + [self.RegionList addObject:@"ID"]; + [self.RegionList addObject:@"MY"]; + [self.RegionList addObject:@"SG"]; + [self.RegionList addObject:@"TH"]; + break; + case 8: + [self.RegionList addObject:@"JP"]; + break; + case 9: + [self.RegionList addObject:@"ETSIUPPERBAND"]; + break; + } + +} + +- (void)generateTableOfFreq { + + + FCCTableOfFreq = @[@"902.75", @"903.25", @"903.75", @"904.25", @"904.75", @"905.25", @"905.75", @"906.25", @"906.75", @"907.25", + @"907.75", @"908.25", @"908.75", @"909.25", @"909.75", @"910.25", @"910.75", @"911.25", @"911.75", @"912.25", + @"912.75", @"913.25", @"913.75", @"914.25", @"914.75", @"915.25", @"915.75", @"916.25", @"916.75", @"917.25", + @"917.75", @"918.25", @"918.75", @"919.25", @"919.75", @"920.25", @"920.75", @"921.25", @"921.75", @"922.25", + @"922.75", @"923.25", @"923.75", @"924.25", @"924.75", @"925.25", @"925.75", @"926.25", @"926.75", @"927.25"]; + + AUTableOfFreq = @[@"920.75", @"921.25", @"921.75", @"922.25", @"922.75", @"923.25", @"923.75", @"924.25", @"924.75", @"925.25"]; + + CNTableOfFreq = @[@"920.625", @"920.875", @"921.125", @"921.375", @"921.625", @"921.875", @"922.125", @"922.375", + @"922.625", @"922.875", @"923.125", @"923.375", @"923.625", @"923.875", @"924.125", @"924.375"]; + + ETSITableOfFreq = @[@"865.70", @"866.30", @"866.90", @"867.50"]; + + INTableOfFreq = @[@"865.70", @"866.30", @"866.90"]; + + HKTableOfFreq = @[@"920.75", @"921.25", @"921.75", @"922.25", @"922.75", @"923.25", @"923.75", @"924.25"]; + + JPTableOfFreq = @[@"916.80", @"918.00", @"919.20", @"920.40"]; + + KRTableOfFreq = @[@"917.30", @"917.90", @"918.50", @"919.10", @"919.70", @"920.30"]; + + MYTableOfFreq = @[@"919.75", @"920.25", @"920.75", @"921.25", @"921.75", @"922.25"]; + + TWTableOfFreq = @[@"922.25", @"922.75", @"923.25", @"923.75", @"924.25", @"924.75", @"925.25", @"925.75", @"926.25", @"926.75", @"927.25", @"927.75"]; + + ZATableOfFreq = @[@"915.7", @"915.9", @"916.1", @"916.3", @"916.5", @"916.7", @"916.9", @"917.1", @"917.3", @"917.5", @"917.7", @"917.9", @"918.1", @"918.3", @"918.5", @"918.7"]; + + + BR1TableOfFreq = @[@"915.75", @"916.25", @"916.75", @"917.25", @"917.75", @"918.25", @"918.75", @"919.25", @"919.75", @"920.25", + @"920.75", @"921.25", @"921.75", @"922.25", @"922.75", @"923.25", @"923.75", @"924.25", @"924.75", @"925.25", + @"925.75", @"926.25", @"926.75", @"927.25"]; + + BR2TableOfFreq = @[@"902.75", @"903.25", @"903.75", @"904.25", @"904.75", @"905.25", @"905.75", @"906.25", @"906.75", + @"915.75", @"916.25", @"916.75", @"917.25", @"917.75", @"918.25", @"918.75", @"919.25", @"919.75", @"920.25", + @"920.75", @"921.25", @"921.75", @"922.25", @"922.75", @"923.25", @"923.75", @"924.25", @"924.75", @"925.25", + @"925.75", @"926.25", @"926.75", @"927.25"]; + + BR3TableOfFreq = @[@"902.75", @"903.25", @"903.75", @"904.25", @"904.75", @"905.25", @"905.75", @"906.25", @"906.75"]; + + BR4TableOfFreq = @[@"902.75", @"903.25", @"903.75", @"904.25"]; + + BR5TableOfFreq = @[@"917.75", @"918.25", @"918.75", @"919.25", @"919.75", @"920.25", @"920.75", + @"921.25", @"921.75", @"922.25", @"922.75", @"923.25", @"923.75", @"924.25"]; + + IDTableOfFreq = @[@"923.25", @"923.75", @"924.25", @"924.75"]; + + JETableOfFreq = @[@"915.25", @"915.5", @"915.75", @"916.0", @"916.25", @"916.5", @"916.75"]; + + PHTableOfFreq = @[@"918.125", @"918.375", @"918.625", @"918.875", @"919.125", @"919.375", @"919.625", @"919.875"]; + + ETSIUPPERBANDTableOfFreq = @[@"916.3", @"917.5", @"918.7"]; + + NZTableOfFreq = @[@"922.25", @"922.75", @"923.25", @"923.75", @"924.25", @"924.75", @"925.25", @"925.75", @"926.25", @"926.75", @"927.25"]; + + UH1TableOfFreq = @[@"915.25", @"915.75", @"916.25", @"916.75", @"917.25", @"917.75", @"918.25", @"918.75", @"919.25", @"919.75"]; + + UH2TableOfFreq = @[@"920.25", @"920.75", @"921.25", @"921.75", @"922.25", + @"922.75", @"923.25", @"923.75", @"924.25", @"924.75", + @"925.25", @"925.75", @"926.25", @"926.75", @"927.25"]; + LHTableOfFreq = @[@"902.75", @"903.25", @"903.75", @"904.25", @"904.75", @"905.25", @"905.75", @"906.25", @"906.75", @"907.25", + @"907.75", @"908.25", @"908.75", @"909.25", @"909.75", @"910.25", @"910.75", @"911.25", @"911.75", @"912.25", + @"912.75", @"913.25", @"913.75", @"914.25", @"914.75", @"915.25"]; + LH1TableOfFreq = @[@"902.75", @"903.25", @"903.75", @"904.25", @"904.75", @"905.25", @"905.75", @"906.25", @"906.75", @"907.25", + @"907.75", @"908.25", @"908.75", @"909.25"]; + LH2TableOfFreq = @[@"909.75", @"910.25", @"910.75", @"911.25", @"911.75", @"912.25", @"912.75", @"913.25", @"913.75", @"914.25", @"914.75"]; + + VNTableOfFreq = @[@"922.75", @"923.25", @"923.75", @"924.25", @"924.75", @"925.25", @"925.75", @"926.25", @"926.75", @"927.25"]; + + FCCFreqValues = [NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E1F], /*903.75 MHz 2 */ + [NSNumber numberWithUnsignedInt:0x00180E41], /*912.25 MHz 19 */ + [NSNumber numberWithUnsignedInt:0x00180E2F], /*907.75 MHz 10 */ + [NSNumber numberWithUnsignedInt:0x00180E39], /*910.25 MHz 15 */ + [NSNumber numberWithUnsignedInt:0x00180E6B], /*922.75 MHz 40 */ + [NSNumber numberWithUnsignedInt:0x00180E6D], /*923.25 MHz 41 */ + [NSNumber numberWithUnsignedInt:0x00180E6F], /*923.75 MHz 42 */ + [NSNumber numberWithUnsignedInt:0x00180E4D], /*915.25 MHz 25 */ + [NSNumber numberWithUnsignedInt:0x00180E35], /*909.25 MHz 13 */ + [NSNumber numberWithUnsignedInt:0x00180E43], /*912.75 MHz 20 */ + [NSNumber numberWithUnsignedInt:0x00180E3B], /*910.75 MHz 16 */ + [NSNumber numberWithUnsignedInt:0x00180E47], /*913.75 MHz 22 */ + [NSNumber numberWithUnsignedInt:0x00180E37], /*909.75 MHz 14 */ + [NSNumber numberWithUnsignedInt:0x00180E25], /*905.25 MHz 5 */ + [NSNumber numberWithUnsignedInt:0x00180E3F], /*911.75 MHz 18 */ + [NSNumber numberWithUnsignedInt:0x00180E1B], /*902.75 MHz 0 */ + [NSNumber numberWithUnsignedInt:0x00180E49], /*914.25 MHz 23 */ + [NSNumber numberWithUnsignedInt:0x00180E59], /*918.25 MHz 31 */ + [NSNumber numberWithUnsignedInt:0x00180E79], /*926.25 MHz 47 */ + [NSNumber numberWithUnsignedInt:0x00180E77], /*925.75 MHz 46 */ + [NSNumber numberWithUnsignedInt:0x00180E63], /*920.75 MHz 36 */ + [NSNumber numberWithUnsignedInt:0x00180E61], /*920.25 MHz 35 */ + [NSNumber numberWithUnsignedInt:0x00180E2D], /*907.25 MHz 9 */ + [NSNumber numberWithUnsignedInt:0x00180E4B], /*914.75 MHz 24 */ + [NSNumber numberWithUnsignedInt:0x00180E5F], /*919.75 MHz 34 */ + [NSNumber numberWithUnsignedInt:0x00180E69], /*922.25 MHz 39 */ + [NSNumber numberWithUnsignedInt:0x00180E1D], /*903.25 MHz 1 */ + [NSNumber numberWithUnsignedInt:0x00180E29], /*906.25 MHz 7 */ + [NSNumber numberWithUnsignedInt:0x00180E27], /*905.75 MHz 6 */ + [NSNumber numberWithUnsignedInt:0x00180E7B], /*926.75 MHz 48 */ + [NSNumber numberWithUnsignedInt:0x00180E71], /*924.25 MHz 43 */ + [NSNumber numberWithUnsignedInt:0x00180E23], /*904.75 MHz 4 */ + [NSNumber numberWithUnsignedInt:0x00180E75], /*925.25 MHz 45 */ + [NSNumber numberWithUnsignedInt:0x00180E73], /*924.75 MHz 44 */ + [NSNumber numberWithUnsignedInt:0x00180E5D], /*919.25 MHz 33 */ + [NSNumber numberWithUnsignedInt:0x00180E53], /*916.75 MHz 28 */ + [NSNumber numberWithUnsignedInt:0x00180E3D], /*911.25 MHz 17 */ + [NSNumber numberWithUnsignedInt:0x00180E65], /*921.25 MHz 37 */ + [NSNumber numberWithUnsignedInt:0x00180E31], /*908.25 MHz 11 */ + [NSNumber numberWithUnsignedInt:0x00180E33], /*908.75 MHz 12 */ + [NSNumber numberWithUnsignedInt:0x00180E45], /*913.25 MHz 21 */ + [NSNumber numberWithUnsignedInt:0x00180E51], /*916.25 MHz 27 */ + [NSNumber numberWithUnsignedInt:0x00180E21], /*904.25 MHz 3 */ + [NSNumber numberWithUnsignedInt:0x00180E2B], /*906.75 MHz 8 */ + [NSNumber numberWithUnsignedInt:0x00180E57], /*917.75 MHz 30 */ + [NSNumber numberWithUnsignedInt:0x00180E67], /*921.75 MHz 38 */ + [NSNumber numberWithUnsignedInt:0x00180E55], /*917.25 MHz 29 */ + [NSNumber numberWithUnsignedInt:0x00180E7D], /*927.25 MHz 49 */ + [NSNumber numberWithUnsignedInt:0x00180E5B], /*918.75 MHz 32 */ + [NSNumber numberWithUnsignedInt:0x00180E4F], /*915.75 MHz 26 */ + nil]; + + AUFreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E63], /* 920.75MHz */ + [NSNumber numberWithUnsignedInt:0x00180E69], /* 922.25MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6F], /* 923.75MHz */ + [NSNumber numberWithUnsignedInt:0x00180E73], /* 924.75MHz */ + [NSNumber numberWithUnsignedInt:0x00180E65], /* 921.25MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6B], /* 922.75MHz */ + [NSNumber numberWithUnsignedInt:0x00180E71], /* 924.25MHz */ + [NSNumber numberWithUnsignedInt:0x00180E75], /* 925.25MHz */ + [NSNumber numberWithUnsignedInt:0x00180E67], /* 921.75MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6D], /* 923.25MHz */ + nil]; + CNFreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00301CD3], /*922.375MHz */ + [NSNumber numberWithUnsignedInt:0x00301CD1], /*922.125MHz */ + [NSNumber numberWithUnsignedInt:0x00301CCD], /*921.625MHz */ + [NSNumber numberWithUnsignedInt:0x00301CC5], /*920.625MHz */ + [NSNumber numberWithUnsignedInt:0x00301CD9], /*923.125MHz */ + [NSNumber numberWithUnsignedInt:0x00301CE1], /*924.125MHz */ + [NSNumber numberWithUnsignedInt:0x00301CCB], /*921.375MHz */ + [NSNumber numberWithUnsignedInt:0x00301CC7], /*920.875MHz */ + [NSNumber numberWithUnsignedInt:0x00301CD7], /*922.875MHz */ + [NSNumber numberWithUnsignedInt:0x00301CD5], /*922.625MHz */ + [NSNumber numberWithUnsignedInt:0x00301CC9], /*921.125MHz */ + [NSNumber numberWithUnsignedInt:0x00301CDF], /*923.875MHz */ + [NSNumber numberWithUnsignedInt:0x00301CDD], /*923.625MHz */ + [NSNumber numberWithUnsignedInt:0x00301CDB], /*923.375MHz */ + [NSNumber numberWithUnsignedInt:0x00301CCF], /*921.875MHz */ + [NSNumber numberWithUnsignedInt:0x00301CE3], /*924.375MHz */ + nil]; + + ETSIFreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x003C21D1], /*865.700MHz */ + [NSNumber numberWithUnsignedInt:0x003C21D7], /*866.300MHz */ + [NSNumber numberWithUnsignedInt:0x003C21DD], /*866.900MHz */ + [NSNumber numberWithUnsignedInt:0x003C21E3], /*867.500MHz */ + nil]; + INFreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x003C21D1], /*865.700MHz */ + [NSNumber numberWithUnsignedInt:0x003C21D7], /*866.300MHz */ + [NSNumber numberWithUnsignedInt:0x003C21DD], /*866.900MHz */ + nil]; + + HKFreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E63], /*920.75MHz */ + [NSNumber numberWithUnsignedInt:0x00180E69], /*922.25MHz */ + [NSNumber numberWithUnsignedInt:0x00180E71], /*924.25MHz */ + [NSNumber numberWithUnsignedInt:0x00180E65], /*921.25MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6B], /*922.75MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6D], /*923.25MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6F], /*923.75MHz */ + [NSNumber numberWithUnsignedInt:0x00180E67], /*921.75MHz */ + nil]; + + JPFreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x003C23D0], /*916.800MHz Channel 1*/ + [NSNumber numberWithUnsignedInt:0x003C23DC], /*918.000MHz Channel 2*/ + [NSNumber numberWithUnsignedInt:0x003C23E8], /*919.200MHz Channel 3*/ + [NSNumber numberWithUnsignedInt:0x003C23F4], /*920.400MHz Channel 4*/ + nil]; + + KRFreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x003C23E7], /*919.1 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23D5], /*917.3 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23F3], /*920.3 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23DB], /*917.9 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23ED], /*919.7 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23E1], /*918.5 MHz */ + nil]; + + MYFreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E5F], /*919.75MHz */ + [NSNumber numberWithUnsignedInt:0x00180E65], /*921.25MHz */ + [NSNumber numberWithUnsignedInt:0x00180E61], /*920.25MHz */ + [NSNumber numberWithUnsignedInt:0x00180E67], /*921.75MHz */ + [NSNumber numberWithUnsignedInt:0x00180E63], /*920.75MHz */ + [NSNumber numberWithUnsignedInt:0x00180E69], /*922.25MHz */ + nil]; + + + TWFreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E7D], /*927.25MHz 10*/ + [NSNumber numberWithUnsignedInt:0x00180E73], /*924.75MHz 5*/ + [NSNumber numberWithUnsignedInt:0x00180E6B], /*922.75MHz 1*/ + [NSNumber numberWithUnsignedInt:0x00180E75], /*925.25MHz 6*/ + [NSNumber numberWithUnsignedInt:0x00180E7F], /*927.75MHz 11*/ + [NSNumber numberWithUnsignedInt:0x00180E71], /*924.25MHz 4*/ + [NSNumber numberWithUnsignedInt:0x00180E79], /*926.25MHz 8*/ + [NSNumber numberWithUnsignedInt:0x00180E6D], /*923.25MHz 2*/ + [NSNumber numberWithUnsignedInt:0x00180E7B], /*926.75MHz 9*/ + [NSNumber numberWithUnsignedInt:0x00180E69], /*922.25MHz 0*/ + [NSNumber numberWithUnsignedInt:0x00180E77], /*925.75MHz 7*/ + [NSNumber numberWithUnsignedInt:0x00180E6F], /*923.75MHz 3*/ + nil]; + + ZAFreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x003C23C5], /*915.7 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23C7], /*915.9 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23C9], /*916.1 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23CB], /*916.3 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23CD], /*916.5 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23CF], /*916.7 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23D1], /*916.9 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23D3], /*917.1 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23D5], /*917.3 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23D7], /*917.5 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23D9], /*917.7 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23DB], /*917.9 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23DD], /*918.1 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23DF], /*918.3 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23E1], /*918.5 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23E3], /*918.7 MHz */ + nil]; + + BR1FreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E4F], /*915.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E7B], /*926.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E79], /*926.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E7D], /*927.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E61], /*920.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E5D], /*919.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E5B], /*918.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E57], /*917.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E75], /*925.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E67], /*921.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E69], /*922.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E55], /*917.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E59], /*918.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E51], /*916.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E73], /*924.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E5F], /*919.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E53], /*916.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6F], /*923.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E77], /*925.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E71], /*924.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E65], /*921.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E63], /*920.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6B], /*922.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6D], /*923.25 MHz */ + nil]; + + BR2FreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E4F], /*915.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E1D], /*903.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E7B], /*926.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E79], /*926.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E21], /*904.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E7D], /*927.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E61], /*920.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E5D], /*919.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E5B], /*918.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E57], /*917.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E25], /*905.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E23], /*904.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E75], /*925.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E67], /*921.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E2B], /*906.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E69], /*922.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E1F], /*903.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E27], /*905.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E29], /*906.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E55], /*917.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E59], /*918.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E51], /*916.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E73], /*924.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E5F], /*919.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E53], /*916.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6F], /*923.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E77], /*925.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E71], /*924.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E65], /*921.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E63], /*920.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6B], /*922.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E1B], /*902.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6D], /*923.25 MHz */ + nil]; + + BR3FreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E1D], /*903.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E21], /*904.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E25], /*905.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E23], /*904.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E2B], /*906.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E1F], /*903.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E27], /*905.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E29], /*906.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E1B], /*902.75 MHz */ + nil]; + + BR4FreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E1D], /*903.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E21], /*904.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E1F], /*903.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E1B], /*902.75 MHz */ + nil]; + + BR5FreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E61], /*920.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E5D], /*919.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E5B], /*918.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E57], /*917.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E67], /*921.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E69], /*922.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E59], /*918.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E5F], /*919.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6F], /*923.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E71], /*924.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E65], /*921.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E63], /*920.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6B], /*922.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6D], /*923.25 MHz */ + nil]; + + IDFreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E6D], /*923.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6F], /*923.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E71], /*924.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E73], /*924.75 MHz */ + nil]; + + JEFreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E4D], /*915.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E51], /*916.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E4E], /*915.5 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E52], /*916.5 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E4F], /*915.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E53], /*916.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E50], /*916.0 MHz */ + nil]; + + PHFreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00301CB1], /*918.125MHz Channel 0*/ + [NSNumber numberWithUnsignedInt:0x00301CBB], /*919.375MHz Channel 5*/ + [NSNumber numberWithUnsignedInt:0x00301CB7], /*918.875MHz Channel 3*/ + [NSNumber numberWithUnsignedInt:0x00301CBF], /*919.875MHz Channel 7*/ + [NSNumber numberWithUnsignedInt:0x00301CB3], /*918.375MHz Channel 1*/ + [NSNumber numberWithUnsignedInt:0x00301CBD], /*919.625MHz Channel 6*/ + [NSNumber numberWithUnsignedInt:0x00301CB5], /*918.625MHz Channel 2*/ + [NSNumber numberWithUnsignedInt:0x00301CB9], /*919.125MHz Channel 4*/ + nil]; + + ETSIUPPERBANDFreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x003C23CB], /*916.3 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23D7], /*917.5 MHz */ + [NSNumber numberWithUnsignedInt:0x003C23E3], /*918.7 MHz */ + nil]; + + NZFreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E71], /*924.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E77], /*925.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E69], /*922.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E7B], /*926.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6D], /*923.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E7D], /*927.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E75], /*925.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6B], /*922.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E79], /*926.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6F], /*923.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E73], /*924.75 MHz */ + nil]; + + + + UH1FreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E4F], /*915.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E4D], /*915.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E5D], /*919.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E5B], /*918.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E57], /*917.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E55], /*917.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E59], /*918.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E51], /*916.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E5F], /*919.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E53], /*916.75 MHz */ + nil]; + + UH2FreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E7B], /*926.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E79], /*926.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E7D], /*927.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E61], /*920.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E75], /*925.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E67], /*921.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E69], /*922.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E73], /*924.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6F], /*923.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E77], /*925.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E71], /*924.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E65], /*921.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E63], /*920.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6B], /*922.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E6D], /*923.25 MHz */ + nil]; + + + LHFreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E1B], /*902.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E35], /*909.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E1D], /*903.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E37], /*909.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E1F], /*903.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E39], /*910.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E21], /*904.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E3B], /*910.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E23], /*904.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E3D], /*911.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E25], /*905.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E3F], /*911.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E27], /*905.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E41], /*912.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E29], /*906.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E43], /*912.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E2B], /*906.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E45], /*913.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E2D], /*907.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E47], /*913.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E2F], /*907.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E49], /*914.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E31], /*908.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E4B], /*914.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E33], /*908.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E4D], /*915.25 MHz */ + nil]; + + LH1FreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E1B], /*902.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E35], /*909.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E1D], /*903.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E1F], /*903.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E21], /*904.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E23], /*904.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E25], /*905.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E27], /*905.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E29], /*906.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E2B], /*906.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E2D], /*907.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E2F], /*907.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E31], /*908.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E33], /*908.75 MHz */ + nil]; + + LH2FreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E37], /*909.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E39], /*910.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E3B], /*910.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E3D], /*911.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E3F], /*911.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E41], /*912.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E43], /*912.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E45], /*913.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E47], /*913.75 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E49], /*914.25 MHz */ + [NSNumber numberWithUnsignedInt:0x00180E4B], /*914.75 MHz */ + nil]; + + VNFreqValues=[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x00180E77], /*925.75 MHz 6 */ + [NSNumber numberWithUnsignedInt:0x00180E6B], /*922.75 MHz 0 */ + [NSNumber numberWithUnsignedInt:0x00180E7D], /*927.25 MHz 9 */ + [NSNumber numberWithUnsignedInt:0x00180E75], /*925.25 MHz 5 */ + [NSNumber numberWithUnsignedInt:0x00180E6D], /*923.25 MHz 1 */ + [NSNumber numberWithUnsignedInt:0x00180E7B], /*926.75 MHz 8 */ + [NSNumber numberWithUnsignedInt:0x00180E73], /*924.75 MHz 4 */ + [NSNumber numberWithUnsignedInt:0x00180E6F], /*923.75 MHz 2 */ + [NSNumber numberWithUnsignedInt:0x00180E79], /*926.25 MHz 7 */ + [NSNumber numberWithUnsignedInt:0x00180E71], /*924.25 MHz 3 */ + nil]; + + FCCFreqIndex = @[@2, @19, @10, @15, @40, + @41, @42, @25, @13, @20, + @16, @22, @14, @5, @18, + @0, @23, @31, @47, @46, + @36, @35, @9, @24, @34, + @39, @1, @7, @6, @48, + @43, @4, @45, @44, @33, + @28, @17, @37, @11, @12, + @21, @27, @3, @8, @30, + @38, @29, @49, @32, @26]; + + AUFreqIndex = @[@0, @3, @6, @8, @1, + @4, @7, @9, @2, @5]; + + + CNFreqIndex = @[@7, @6, @4, @0, + @10, @14, @3, @1, + @9, @8, @2, @13, + @12, @11, @5, @15,]; + + + ETSIFreqIndex = @[@0, @1, @2, @3]; + + INFreqIndex = @[@0, @1, @2,]; + + HKFreqIndex = @[@0, @3, @7, @1, + @3, @5, @6, @2]; + + JPFreqIndex = @[@0, @1, @2, @3]; + + KRFreqIndex = @[@3, @0, @5, @1, @4, @2]; + + MYFreqIndex = @[@0, @3, @1, @4, @2, @5]; + + TWFreqIndex = @[@10, @5, @1, @6, + @11, @4, @8, @2, + @9, @0, @7, @3]; + + ZAFreqIndex = @[@4, @7, @0, @9, @2, @10, @6, @1, @8, @3, @5]; + + BR1FreqIndex = @[@0, @22, @21, @23, + @9, @7, @6, @4, + @19, @12, @13, @3, + @5, @1, @18, @8, + @2, @16, @20, @17, + @11, @10, @14, @15,]; + + BR2FreqIndex = @[@9, @1, @31, + @30, @3, @32, + @18, @16, @15, + @13, @5, @4, + @28, @21, @8, + @22, @2, @6, + @7, @12, @14, + @10, @27, @17, + @11, @25, @29, + @26, @20, @19, + @23, @0, @24]; + + BR3FreqIndex = @[@1, @3, @5, @4, @8, @2, @6, @7, @0]; + BR4FreqIndex = @[@1, @3, @2, @0]; + BR5FreqIndex = @[@5, @3, @2, @0, @8, @9, @1, @4, @12, @13, @7, @6, @10, @11]; + IDFreqIndex = @[@0, @1, @2, @3]; + JEFreqIndex = @[@0, @4, @1, @5, @2, @6, @3]; + PHFreqIndex = @[@0, @5, @3, @7, @1, @6, @2, @4]; + ETSIUPPERBANDFreqIndex = @[@0, @1, @2]; + NZFreqIndex = @[@4, @7, @0, @9, @2, @10, @6, @1, @8, @3, @5]; + UH1FreqIndex = @[@1, @0, @8, @7, @5, @4, @6, @2, @9, @3]; + UH2FreqIndex = @[@13, @12, @14, @0, @10, @3, @4, @9, @7, @11, @8, @2, @1, @5, @6]; + LHFreqIndex = @[@0, @13, @1, @14, @2, @15, @3, @16, @4, @17, @5, @18, @6, @19, @7, @20, @8, @21, @9, @22, @10, @23, @11, @24, @12, @25]; + LH1FreqIndex = @[@0, @13, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12]; + LH2FreqIndex = @[@0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10]; + VNFreqIndex = @[@6, @0, @9, @5, @1, @8, @4, @2, @7, @3]; + + + + self.TableOfFrequencies = [[NSMutableDictionary alloc] init]; + self.FrequencyValues = [[NSMutableDictionary alloc] init]; + self.FrequencyIndex = [[NSMutableDictionary alloc] init]; + [self generateRegionList]; + + for (NSString* region in self.RegionList) { + if ([region isEqualToString:@"ETSI"] || + [region isEqualToString:@"G800"]) { + [self.TableOfFrequencies setValue:ETSITableOfFreq forKey:@"ETSI"]; + [self.FrequencyValues setValue:ETSIFreqValues forKey:@"ETSI"]; + [self.FrequencyIndex setValue:ETSIFreqIndex forKey:@"ETSI"]; + [self.TableOfFrequencies setValue:ETSITableOfFreq forKey:@"G800"]; + [self.FrequencyValues setValue:ETSIFreqValues forKey:@"G800"]; + [self.FrequencyIndex setValue:ETSIFreqIndex forKey:@"G800"]; + } + else if ([region isEqualToString:@"IN"]) { + [self.TableOfFrequencies setValue:INTableOfFreq forKey:@"IN"]; + [self.FrequencyValues setValue:INFreqValues forKey:@"IN"]; + [self.FrequencyIndex setValue:INFreqIndex forKey:@"IN"]; + } + else if ([region isEqualToString:@"AR"] || + [region isEqualToString:@"CL"] || + [region isEqualToString:@"CO"] || + [region isEqualToString:@"CR"] || + [region isEqualToString:@"DO"] || + [region isEqualToString:@"PA"] || + [region isEqualToString:@"UY"] || + [region isEqualToString:@"FCC"]) { + [self.TableOfFrequencies setValue:FCCTableOfFreq forKey:@"FCC"]; + [self.FrequencyValues setValue:FCCFreqValues forKey:@"FCC"]; + [self.FrequencyIndex setValue:FCCFreqIndex forKey:@"FCC"]; + + [self.TableOfFrequencies setValue:FCCTableOfFreq forKey:@"AR"]; + [self.FrequencyValues setValue:FCCFreqValues forKey:@"AR"]; + [self.FrequencyIndex setValue:FCCFreqIndex forKey:@"AR"]; + + [self.TableOfFrequencies setValue:FCCTableOfFreq forKey:@"CO"]; + [self.FrequencyValues setValue:FCCFreqValues forKey:@"CO"]; + [self.FrequencyIndex setValue:FCCFreqIndex forKey:@"CO"]; + + [self.TableOfFrequencies setValue:FCCTableOfFreq forKey:@"CR"]; + [self.FrequencyValues setValue:FCCFreqValues forKey:@"CR"]; + [self.FrequencyIndex setValue:FCCFreqIndex forKey:@"CR"]; + + [self.TableOfFrequencies setValue:FCCTableOfFreq forKey:@"DO"]; + [self.FrequencyValues setValue:FCCFreqValues forKey:@"DO"]; + [self.FrequencyIndex setValue:FCCFreqIndex forKey:@"DO"]; + + [self.TableOfFrequencies setValue:FCCTableOfFreq forKey:@"PA"]; + [self.FrequencyValues setValue:FCCFreqValues forKey:@"PA"]; + [self.FrequencyIndex setValue:FCCFreqIndex forKey:@"PA"]; + + [self.TableOfFrequencies setValue:FCCTableOfFreq forKey:@"UY"]; + [self.FrequencyValues setValue:FCCFreqValues forKey:@"UY"]; + [self.FrequencyIndex setValue:FCCFreqIndex forKey:@"UY"]; + + [self.TableOfFrequencies setValue:FCCTableOfFreq forKey:@"CL"]; + [self.FrequencyValues setValue:FCCFreqValues forKey:@"CL"]; + [self.FrequencyIndex setValue:FCCFreqIndex forKey:@"CL"]; + } + else if ([region isEqualToString:@"BR1"]) { + [self.TableOfFrequencies setValue:BR1TableOfFreq forKey:@"BR1"]; + [self.FrequencyValues setValue:BR1FreqValues forKey:@"BR1"]; + [self.FrequencyIndex setValue:BR1FreqIndex forKey:@"BR1"]; + } + else if ([region isEqualToString:@"BR2"] || + [region isEqualToString:@"PE"]) { + [self.TableOfFrequencies setValue:BR2TableOfFreq forKey:@"BR2"]; + [self.FrequencyValues setValue:BR2FreqValues forKey:@"BR2"]; + [self.FrequencyIndex setValue:BR2FreqIndex forKey:@"BR2"]; + } + else if ([region isEqualToString:@"BR3"]) { + [self.TableOfFrequencies setValue:BR3TableOfFreq forKey:@"BR3"]; + [self.FrequencyValues setValue:BR3FreqValues forKey:@"BR3"]; + [self.FrequencyIndex setValue:BR3FreqIndex forKey:@"BR3"]; + } + else if ([region isEqualToString:@"BR4"]) { + [self.TableOfFrequencies setValue:BR4TableOfFreq forKey:@"BR4"]; + [self.FrequencyValues setValue:BR4FreqValues forKey:@"BR4"]; + [self.FrequencyIndex setValue:BR4FreqIndex forKey:@"BR4"]; + } + else if ([region isEqualToString:@"BR5"]) { + [self.TableOfFrequencies setValue:BR5TableOfFreq forKey:@"BR5"]; + [self.FrequencyValues setValue:BR5FreqValues forKey:@"BR5"]; + [self.FrequencyIndex setValue:BR5FreqIndex forKey:@"BR5"]; + } + else if ([region isEqualToString:@"HK"] || + [region isEqualToString:@"SG"] || + [region isEqualToString:@"TH"]) { + [self.TableOfFrequencies setValue:HKTableOfFreq forKey:@"HK"]; + [self.FrequencyValues setValue:HKFreqValues forKey:@"HK"]; + [self.FrequencyIndex setValue:HKFreqIndex forKey:@"HK"]; + [self.TableOfFrequencies setValue:HKTableOfFreq forKey:@"SG"]; + [self.FrequencyValues setValue:HKFreqValues forKey:@"SG"]; + [self.FrequencyIndex setValue:HKFreqIndex forKey:@"SG"]; + [self.TableOfFrequencies setValue:HKTableOfFreq forKey:@"TH"]; + [self.FrequencyValues setValue:HKFreqValues forKey:@"TH"]; + [self.FrequencyIndex setValue:HKFreqIndex forKey:@"TH"]; + } + else if ([region isEqualToString:@"JE"]) { + [self.TableOfFrequencies setValue:JETableOfFreq forKey:@"JE"]; + [self.FrequencyValues setValue:JEFreqValues forKey:@"JE"]; + [self.FrequencyIndex setValue:JEFreqIndex forKey:@"JE"]; + } + else if ([region isEqualToString:@"KR"]) { + [self.TableOfFrequencies setValue:KRTableOfFreq forKey:@"KR"]; + [self.FrequencyValues setValue:KRFreqValues forKey:@"KR"]; + [self.FrequencyIndex setValue:KRFreqIndex forKey:@"KR"]; + } + else if ([region isEqualToString:@"MY"]) { + [self.TableOfFrequencies setValue:MYTableOfFreq forKey:@"MY"]; + [self.FrequencyValues setValue:MYFreqValues forKey:@"MY"]; + [self.FrequencyIndex setValue:MYFreqIndex forKey:@"MY"]; + } + else if ([region isEqualToString:@"PH"]) { + [self.TableOfFrequencies setValue:PHTableOfFreq forKey:@"PH"]; + [self.FrequencyValues setValue:PHFreqValues forKey:@"PH"]; + [self.FrequencyIndex setValue:PHFreqIndex forKey:@"PH"]; + } + else if ([region isEqualToString:@"VN"]) { + [self.TableOfFrequencies setValue:VNTableOfFreq forKey:@"VN"]; + [self.FrequencyValues setValue:VNFreqValues forKey:@"VN"]; + [self.FrequencyIndex setValue:VNFreqIndex forKey:@"VN"]; + } + else if ([region isEqualToString:@"ZA"]) { + [self.TableOfFrequencies setValue:ZATableOfFreq forKey:@"ZA"]; + [self.FrequencyValues setValue:ZAFreqValues forKey:@"ZA"]; + [self.FrequencyIndex setValue:ZAFreqIndex forKey:@"ZA"]; + } + else if ([region isEqualToString:@"LH1"]) { + [self.TableOfFrequencies setValue:LH1TableOfFreq forKey:@"LH1"]; + [self.FrequencyValues setValue:LH1FreqValues forKey:@"LH1"]; + [self.FrequencyIndex setValue:LH1FreqIndex forKey:@"LH1"]; + } + else if ([region isEqualToString:@"LH2"]) { + [self.TableOfFrequencies setValue:LH2TableOfFreq forKey:@"LH2"]; + [self.FrequencyValues setValue:LH2FreqValues forKey:@"LH2"]; + [self.FrequencyIndex setValue:LH2FreqIndex forKey:@"LH2"]; + } + else if ([region isEqualToString:@"UH1"]) { + [self.TableOfFrequencies setValue:UH1TableOfFreq forKey:@"UH1"]; + [self.FrequencyValues setValue:UH1FreqValues forKey:@"UH1"]; + [self.FrequencyIndex setValue:UH1FreqIndex forKey:@"UH1"]; + } + else if ([region isEqualToString:@"UH2"]) { + [self.TableOfFrequencies setValue:UH2TableOfFreq forKey:@"UH2"]; + [self.FrequencyValues setValue:UH2FreqValues forKey:@"UH2"]; + [self.FrequencyIndex setValue:UH2FreqIndex forKey:@"UH2"]; + } + else if ([region isEqualToString:@"LH"]) { + [self.TableOfFrequencies setValue:LHTableOfFreq forKey:@"LH"]; + [self.FrequencyValues setValue:LHFreqValues forKey:@"LH"]; + [self.FrequencyIndex setValue:LHFreqIndex forKey:@"LH"]; + } + else if ([region isEqualToString:@"AU"]) { + [self.TableOfFrequencies setValue:AUTableOfFreq forKey:@"AU"]; + [self.FrequencyValues setValue:AUFreqValues forKey:@"AU"]; + [self.FrequencyIndex setValue:AUFreqIndex forKey:@"AU"]; + } + else if ([region isEqualToString:@"NZ"]) { + [self.TableOfFrequencies setValue:NZTableOfFreq forKey:@"NZ"]; + [self.FrequencyValues setValue:NZFreqValues forKey:@"NZ"]; + [self.FrequencyIndex setValue:NZFreqIndex forKey:@"NZ"]; + } + else if ([region isEqualToString:@"CN"]) { + [self.TableOfFrequencies setValue:CNTableOfFreq forKey:@"CN"]; + [self.FrequencyValues setValue:CNFreqValues forKey:@"CN"]; + [self.FrequencyIndex setValue:CNFreqIndex forKey:@"CN"]; + } + else if ([region isEqualToString:@"ID"]) { + [self.TableOfFrequencies setValue:IDTableOfFreq forKey:@"ID"]; + [self.FrequencyValues setValue:IDFreqValues forKey:@"ID"]; + [self.FrequencyIndex setValue:IDFreqIndex forKey:@"ID"]; + } + else if ([region isEqualToString:@"TW"]) { + [self.TableOfFrequencies setValue:TWTableOfFreq forKey:@"TW"]; + [self.FrequencyValues setValue:TWFreqValues forKey:@"TW"]; + [self.FrequencyIndex setValue:TWFreqIndex forKey:@"TW"]; + } + else if ([region isEqualToString:@"JP"]) { + [self.TableOfFrequencies setValue:JPTableOfFreq forKey:@"JP"]; + [self.FrequencyValues setValue:JPFreqValues forKey:@"JP"]; + [self.FrequencyIndex setValue:JPFreqIndex forKey:@"JP"]; + } + else if ([region isEqualToString:@"ETSIUPPERBAND"]) { + [self.TableOfFrequencies setValue:ETSIUPPERBANDTableOfFreq forKey:@"ETSIUPPERBAND"]; + [self.FrequencyValues setValue:ETSIUPPERBANDFreqValues forKey:@"ETSIUPPERBAND"]; + [self.FrequencyIndex setValue:ETSIUPPERBANDFreqIndex forKey:@"ETSIUPPERBAND"]; + } + + } + +} + +@end diff --git a/CS108iOSClient/model/CSLReaderInfo.h b/CS108iOSClient/model/CSLReaderInfo.h index c7b35bf..4543ead 100644 --- a/CS108iOSClient/model/CSLReaderInfo.h +++ b/CS108iOSClient/model/CSLReaderInfo.h @@ -24,4 +24,14 @@ @property NSString* pcbBoardVersion; ///Reader current battery level percentage @property (assign) int batteryPercentage; +///OEM data: Country Code +@property (assign) UInt32 countryCode; +///OEM data: Special Country Verison +@property (assign) UInt32 specialCountryVerison; +///OEM data: Frequency Modication Flag +@property (assign) UInt32 freqModFlag; +///OEM data: Model Code +@property (assign) UInt32 modelCode; +///OEM data: Hopping/Fixed Frequency +@property (assign) UInt32 isFxied; @end diff --git a/CS108iOSClient/model/CSLReaderInfo.m b/CS108iOSClient/model/CSLReaderInfo.m index f6064d2..32ed113 100644 --- a/CS108iOSClient/model/CSLReaderInfo.m +++ b/CS108iOSClient/model/CSLReaderInfo.m @@ -17,6 +17,10 @@ @implementation CSLReaderInfo @synthesize pcbBoardVersion; @synthesize appVersion; @synthesize batteryPercentage; +@synthesize countryCode; +@synthesize specialCountryVerison; +@synthesize freqModFlag; +@synthesize modelCode; -(id)init { if (self = [super init]) { @@ -28,6 +32,10 @@ -(id)init { deviceSerialNumber = [[NSString alloc] init]; pcbBoardVersion = [[NSString alloc] init]; batteryPercentage=-1; + countryCode=2; //default device: CS108-2 FCC + specialCountryVerison=0; + freqModFlag=0xAA; + modelCode=0x0B; } return self; } diff --git a/CS108iOSClient/model/CSLReaderSettings.h b/CS108iOSClient/model/CSLReaderSettings.h index 58f51fd..f010ce9 100644 --- a/CS108iOSClient/model/CSLReaderSettings.h +++ b/CS108iOSClient/model/CSLReaderSettings.h @@ -34,6 +34,20 @@ @property (assign) LINKPROFILE linkProfile; ///Define whether sound alert is enabled/disabled @property (assign) BOOL enableSound; +///Impinj Extension - Tag Focus +@property (assign) Byte tagFocus; +///LNA Settings: RF-LNA High Compression Mode +@property (assign) Byte rfLnaHighComp; +///LNA Settings: RF-LNA +@property (assign) Byte rfLna; +///LNA Settings: IF-LNA +@property (assign) Byte ifLna; +///LNA Settings: IF-LNA AGC +@property (assign) Byte ifAgc; +///Frequency Settings: Region +@property NSString* region; +///Frequency Settings: Channel +@property NSString* channel; ///Enable/disable multibank bank 1 @property (assign) BOOL isMultibank1Enabled; ///Define multibank bank1 diff --git a/CS108iOSClient/model/CSLReaderSettings.m b/CS108iOSClient/model/CSLReaderSettings.m index ca72b5d..cec3a6f 100644 --- a/CS108iOSClient/model/CSLReaderSettings.m +++ b/CS108iOSClient/model/CSLReaderSettings.m @@ -19,6 +19,8 @@ @implementation CSLReaderSettings @synthesize QValue; @synthesize isQOverride; @synthesize enableSound; +@synthesize region; +@synthesize channel; -(id)init { if (self = [super init]) { @@ -33,6 +35,11 @@ -(id)init { self.algorithm = DYNAMICQ; self.linkProfile=RANGE_DRM; self.enableSound=true; + self.tagFocus=0; //tag focus disable by default + self.rfLnaHighComp = 1; + self.rfLna=0; //1 dB + self.ifLna=0; //24 dB + self.ifAgc=4; //-6 dB self.isMultibank1Enabled=false; self.multibank1=TID; self.multibank1Offset=0; @@ -42,6 +49,8 @@ -(id)init { self.multibank2Offset=0; self.multibank2Length=2; self.numberOfPowerLevel=0; + self.region=@""; + self.channel=@""; self.powerLevel = [NSMutableArray array]; //300, 290, 280.... for (int n = 0; n < 16; n++) diff --git a/CS108iOSClient/model/CSLRfidAppEngine.h b/CS108iOSClient/model/CSLRfidAppEngine.h index c4a2cc7..a718b85 100644 --- a/CS108iOSClient/model/CSLRfidAppEngine.h +++ b/CS108iOSClient/model/CSLRfidAppEngine.h @@ -16,6 +16,7 @@ #import "CSLReaderInfo.h" #import "CSLMQTTSettings.h" #import "CSLTemperatureTagSettings.h" +#import "CSLReaderFrequency.h" #import #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] @@ -43,6 +44,8 @@ @property CSLMQTTSettings* MQTTSettings; ///Reader settings for temperature tags @property CSLTemperatureTagSettings* temperatureSettings; +///Class that generates the supported regions and frequency list of the device hardware +@property CSLReaderFrequency* readerRegionFrequency; ///Initialize the app engine ///@return Reference to the singleton class CSLRfidAppEngine diff --git a/CS108iOSClient/model/CSLRfidAppEngine.m b/CS108iOSClient/model/CSLRfidAppEngine.m index 1adad29..5dd33d3 100644 --- a/CS108iOSClient/model/CSLRfidAppEngine.m +++ b/CS108iOSClient/model/CSLRfidAppEngine.m @@ -79,6 +79,7 @@ -(id)init temperatureSettings = [[CSLTemperatureTagSettings alloc] init]; [self reloadTemperatureTagSettingsFromUserDefaults]; readerInfo = [[CSLReaderInfo alloc] init]; + self.readerRegionFrequency = [[CSLReaderFrequency alloc] init]; } return self; @@ -134,6 +135,20 @@ -(void)reloadSettingsFromUserDefaults { settings.dwellTime = (NSMutableArray*)[defaults arrayForKey:@"dwellTime"]; if([defaults objectForKey:@"isPortEnabled"]) settings.isPortEnabled = (NSMutableArray*)[defaults arrayForKey:@"isPortEnabled"]; + if([defaults objectForKey:@"tagFocus"]) + settings.tagFocus = (Byte)[defaults integerForKey:@"tagFocus"]; + if([defaults objectForKey:@"rfLnaHighComp"]) + settings.rfLnaHighComp = (Byte)[defaults integerForKey:@"rfLnaHighComp"]; + if([defaults objectForKey:@"rfLna"]) + settings.rfLna = (Byte)[defaults integerForKey:@"rfLna"]; + if([defaults objectForKey:@"ifLna"]) + settings.ifLna = (Byte)[defaults integerForKey:@"ifLna"]; + if([defaults objectForKey:@"ifAgc"]) + settings.ifAgc = (Byte)[defaults integerForKey:@"ifAgc"]; + if([defaults objectForKey:@"region"]) + settings.region = (NSString*)[defaults stringForKey:@"region"]; + if([defaults objectForKey:@"channel"]) + settings.channel = (NSString*)[defaults stringForKey:@"channel"]; } -(void)saveSettingsToUserDefaults { @@ -160,6 +175,14 @@ -(void)saveSettingsToUserDefaults { [defaults setObject:settings.powerLevel forKey:@"powerLevel"]; [defaults setObject:settings.dwellTime forKey:@"dwellTime"]; [defaults setObject:settings.isPortEnabled forKey:@"isPortEnabled"]; + [defaults setInteger:settings.tagFocus forKey:@"tagFocus"]; + [defaults setInteger:settings.rfLnaHighComp forKey:@"rfLnaHighComp"]; + [defaults setInteger:settings.rfLna forKey:@"rfLna"]; + [defaults setInteger:settings.ifLna forKey:@"ifLna"]; + [defaults setInteger:settings.ifAgc forKey:@"ifAgc"]; + [defaults setObject:settings.region forKey:@"region"]; + [defaults setObject:settings.channel forKey:@"channel"]; + [defaults synchronize]; } diff --git a/CS108iOSClient/model/CSLTemperatureTagSettings.h b/CS108iOSClient/model/CSLTemperatureTagSettings.h index 0987d2d..318a3dd 100644 --- a/CS108iOSClient/model/CSLTemperatureTagSettings.h +++ b/CS108iOSClient/model/CSLTemperatureTagSettings.h @@ -27,24 +27,24 @@ typedef NS_ENUM(UInt32, SENSORTYPE) }; ///Temperature Unit -typedef NS_ENUM(BOOL, TEMPERATUREUNIT) +typedef NS_ENUM(Byte, TEMPERATUREUNIT) { CELCIUS = 0, FAHRENHEIT = 1 }; ///Sensor Reading -typedef NS_ENUM(BOOL, SENSORREADING) +typedef NS_ENUM(Byte, SENSORREADING) { TEMPERATURE = 0, - MOISTURE= 1 + MOISTURE = 1 }; ///Sensor Reading -typedef NS_ENUM(BOOL, TAGIDFORMAT) +typedef NS_ENUM(Byte, TAGIDFORMAT) { HEX = 0, - ASCII=1 + ASCII = 1 }; ///Sensor Reading Power Level @@ -57,10 +57,10 @@ typedef NS_ENUM(Byte, POWERLEVEL) }; ///Sensor Reading -typedef NS_ENUM(BOOL, ALERTCONDITION) +typedef NS_ENUM(Byte, ALERTCONDITION) { GREATER = 0, - LESSTHAN=1 + LESSTHAN = 1 }; @interface CSLTemperatureTagSettings : NSObject