Skip to content

Commit 5eaf503

Browse files
authored
Merge pull request #36 from cslrfid/release-3.0
Release 3.0
2 parents e8608f2 + b6d72a3 commit 5eaf503

File tree

9 files changed

+74
-15
lines changed

9 files changed

+74
-15
lines changed

CS108iOSClient.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@
659659
"$(inherited)",
660660
"@executable_path/Frameworks",
661661
);
662-
MARKETING_VERSION = 2.9;
662+
MARKETING_VERSION = 3.0;
663663
PRODUCT_BUNDLE_IDENTIFIER = com.csl.CS108iOSClient;
664664
PRODUCT_NAME = "$(TARGET_NAME)";
665665
TARGETED_DEVICE_FAMILY = "1,2";
@@ -682,7 +682,7 @@
682682
"$(inherited)",
683683
"@executable_path/Frameworks",
684684
);
685-
MARKETING_VERSION = 2.9;
685+
MARKETING_VERSION = 3.0;
686686
PRODUCT_BUNDLE_IDENTIFIER = com.csl.CS108iOSClient;
687687
PRODUCT_NAME = "$(TARGET_NAME)";
688688
TARGETED_DEVICE_FAMILY = "1,2";

CS108iOSClient/CSLReader/CSLBleReader+AccessControl.m

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,8 +1488,10 @@ - (BOOL) startTagMemoryRead:(MEMORYBANK)bank dataOffset:(UInt16)offset dataCount
14881488
[[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(8, 4)] isEqualToString:@"0080"]) ||
14891489
([[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(4, 2)] isEqualToString:@"01"] &&
14901490
[[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(8, 4)] isEqualToString:@"0000"])
1491-
)
1491+
) {
1492+
self.lastMacErrorCode=0x0000;
14921493
NSLog(@"Receive read command-begin response: OK");
1494+
}
14931495
else
14941496
{
14951497
NSLog(@"Receive read command-begin response: FAILED");
@@ -1594,8 +1596,10 @@ - (BOOL) startTagMemoryWrite:(MEMORYBANK)bank dataOffset:(UInt16)offset dataCoun
15941596
[[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(8, 4)] isEqualToString:@"0080"]) ||
15951597
([[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(4, 2)] isEqualToString:@"01"] &&
15961598
[[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(8, 4)] isEqualToString:@"0000"])
1597-
)
1599+
) {
1600+
self.lastMacErrorCode=0x0000;
15981601
NSLog(@"Receive read command-begin response: OK");
1602+
}
15991603
else
16001604
{
16011605
NSLog(@"Receive read command-begin response: FAILED");
@@ -1659,8 +1663,10 @@ - (BOOL) startTagSearch:(MEMORYBANK)mask_bank maskPointer:(UInt16)mask_pointer m
16591663
[[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(8, 4)] isEqualToString:@"0080"]) ||
16601664
([[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(4, 2)] isEqualToString:@"01"] &&
16611665
[[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(8, 4)] isEqualToString:@"0000"])
1662-
)
1666+
) {
1667+
self.lastMacErrorCode=0x0000;
16631668
NSLog(@"Receive search command-begin response: OK");
1669+
}
16641670
else
16651671
{
16661672
NSLog(@"Receive search command-begin response: FAILED");
@@ -1829,8 +1835,10 @@ - (BOOL) startTagMemoryLock:(UInt32)lockCommandConfigBits ACCPWD:(UInt32)passwor
18291835
[[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(8, 4)] isEqualToString:@"0080"]) ||
18301836
([[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(4, 2)] isEqualToString:@"01"] &&
18311837
[[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(8, 4)] isEqualToString:@"0000"])
1832-
)
1838+
) {
1839+
self.lastMacErrorCode=0x0000;
18331840
NSLog(@"Receive read command-begin response: OK");
1841+
}
18341842
else
18351843
{
18361844
NSLog(@"Receive read command-begin response: FAILED");

CS108iOSClient/CSLReader/CSLBleReader.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ Insertion/update of tag data is based on binary searching algorithm for better e
128128
///Delegate instance that follows the CSLBleReaderDelegate protocol
129129
@property (nonatomic, weak) id <CSLBleReaderDelegate> readerDelegate;
130130

131+
///This error will be cleared every time when a host command is being initiated and set after and command-end response
132+
@property unsigned short lastMacErrorCode;
133+
131134
/**
132135
Static method that converts hexdcecimal string to binary data
133136

CS108iOSClient/CSLReader/CSLBleReader.m

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,8 +1957,10 @@ - (BOOL)setLinkProfile:(LINKPROFILE) profile
19571957
recvPacket = ((CSLBlePacket *)[cmdRespQueue deqObject]);
19581958
if (([[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(4, 2)] isEqualToString:@"02"] && [[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(8, 4)] isEqualToString:@"0080"]) ||
19591959
([[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(4, 2)] isEqualToString:@"01"] && [[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(8, 4)] isEqualToString:@"0000"])
1960-
)
1960+
) {
1961+
self.lastMacErrorCode=0x0000;
19611962
NSLog(@"Receive HST_CMD 0x19 command-begin response: OK");
1963+
}
19621964
else
19631965
{
19641966
NSLog(@"Receive HST_CMD 0x19 command-begin response: FAILED");
@@ -1972,11 +1974,14 @@ - (BOOL)setLinkProfile:(LINKPROFILE) profile
19721974
if (([[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(4, 2)] isEqualToString:@"02"] || [[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(4, 2)] isEqualToString:@"01"]) &&
19731975
([[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(8, 4)] isEqualToString:@"0180"] || [[recvPacket.getPacketPayloadInHexString substringWithRange:NSMakeRange(8, 4)] isEqualToString:@"0100"]) &&
19741976
((Byte *)[recvPacket.payload bytes])[14] == 0x00 &&
1975-
((Byte *)[recvPacket.payload bytes])[15] == 0x00)
1977+
((Byte *)[recvPacket.payload bytes])[15] == 0x00) {
1978+
self.lastMacErrorCode=(((Byte *)[recvPacket.payload bytes])[15] << 8) + (((Byte *)[recvPacket.payload bytes])[14]);
19761979
NSLog(@"Receive HST_CMD 0x19 command-end response: OK");
1980+
}
19771981
else
19781982
{
19791983
NSLog(@"Receive HST_CMD 0x19 command-end response: FAILED");
1984+
self.lastMacErrorCode=(((Byte *)[recvPacket.payload bytes])[15] << 8) + (((Byte *)[recvPacket.payload bytes])[14]);
19801985
connectStatus=CONNECTED;
19811986
[self.delegate didInterfaceChangeConnectStatus:self]; //this will call the method for connections status chagnes.
19821987
return FALSE;
@@ -2222,6 +2227,7 @@ - (void)decodePacketsInBufferAsync;
22222227
([[rfidPacketBufferInHexString substringWithRange:NSMakeRange(4, 2)] isEqualToString:@"01"] && [[rfidPacketBufferInHexString substringWithRange:NSMakeRange(8, 4)] isEqualToString:@"0000"])
22232228
) {
22242229
NSLog(@"[decodePacketsInBufferAsync] Command-begin response recieved: %@", rfidPacketBufferInHexString);
2230+
self.lastMacErrorCode=0x0000;
22252231
//return packet directly to the API for decoding
22262232
[cmdRespQueue enqObject:packet];
22272233
[rfidPacketBuffer setLength:0];
@@ -2238,6 +2244,7 @@ - (void)decodePacketsInBufferAsync;
22382244
) {
22392245
NSLog(@"[decodePacketsInBufferAsync] Command-end response recieved: %@", rfidPacketBufferInHexString);
22402246
//return packet directly to the API for decoding
2247+
self.lastMacErrorCode=(((Byte *)[rfidPacketBuffer bytes])[15] << 8) + (((Byte *)[rfidPacketBuffer bytes])[14]);
22412248
[cmdRespQueue enqObject:packet];
22422249
[rfidPacketBuffer setLength:0];
22432250
connectStatus=CONNECTED;
@@ -2436,6 +2443,7 @@ - (void)decodePacketsInBufferAsync;
24362443
([[rfidPacketBufferInHexString substringWithRange:NSMakeRange(ptr * 2, 2)] isEqualToString:@"01"] && [[rfidPacketBufferInHexString substringWithRange:NSMakeRange((ptr+2) * 2, 4)] isEqualToString:@"0100"])
24372444
) {
24382445

2446+
self.lastMacErrorCode=(((Byte *)[rfidPacketBuffer bytes])[ptr+13] << 8) + (((Byte *)[rfidPacketBuffer bytes])[ptr+12]);
24392447
//partial command-end packet received
24402448
//remove decoded data from rfid buffer and leave the partial packet on the buffer with 8100 appended to the beginning
24412449

@@ -2554,6 +2562,18 @@ - (void)decodePacketsInBufferAsync;
25542562
[self.delegate didInterfaceChangeConnectStatus:self]; //this will call the method for connections status chagnes.
25552563
break;
25562564
}
2565+
//for the case where command-end appended to the packet as the radio stopped unexpectedly
2566+
else if ([[rfidPacketBufferInHexString substringWithRange:NSMakeRange(ptr * 2, ([rfidPacketBuffer length] - ptr) * 2)] containsString:@"0101010002000000"]) {
2567+
NSLog(@"[decodePacketsInBufferAsync] Unexpected command-end received. All operations ended");
2568+
//get mac error code
2569+
int startOfCmdEnd=(int)[[rfidPacketBufferInHexString substringWithRange:NSMakeRange(ptr * 2, ([rfidPacketBuffer length] - ptr) * 2)] rangeOfString:@"0101010002000000"].location / 2;
2570+
self.lastMacErrorCode=(((Byte *)[rfidPacketBuffer bytes])[ptr+startOfCmdEnd+13] << 8) + (((Byte *)[rfidPacketBuffer bytes])[ptr+startOfCmdEnd+12]);
2571+
[cmdRespQueue enqObject:packet];
2572+
[rfidPacketBuffer setLength:0];
2573+
connectStatus=CONNECTED;
2574+
[self.delegate didInterfaceChangeConnectStatus:self]; //this will call the method for connections status chagnes.
2575+
break;
2576+
}
25572577
//check if we are getting the beginning of another 8100 packet but with no 8100 event code. If so, add the event code back with the header response
25582578
else if (![[rfidPacketBufferInHexString substringWithRange:NSMakeRange(ptr * 2, ([rfidPacketBuffer length] - ptr) * 2)] containsString:@"8100"] && [[rfidPacketBufferInHexString substringWithRange:NSMakeRange((ptr * 2), 2)] isEqualToString:@"03"] && [[rfidPacketBufferInHexString substringWithRange:NSMakeRange((ptr * 2)+4, 4)] isEqualToString:@"0580"]) {
25592579

@@ -2677,6 +2697,18 @@ - (void)decodePacketsInBufferAsync;
26772697
[self.delegate didInterfaceChangeConnectStatus:self]; //this will call the method for connections status chagnes.
26782698
break;
26792699
}
2700+
//for the case where command-end appended to the packet as the radio stopped unexpectedly
2701+
else if ([[rfidPacketBufferInHexString substringWithRange:NSMakeRange(ptr * 2, ([rfidPacketBuffer length] - ptr) * 2)] containsString:@"0101010002000000"]) {
2702+
NSLog(@"[decodePacketsInBufferAsync] Unexpected command-end received. All operations ended");
2703+
//get mac error code
2704+
int startOfCmdEnd=(int)[[rfidPacketBufferInHexString substringWithRange:NSMakeRange(ptr * 2, ([rfidPacketBuffer length] - ptr) * 2)] rangeOfString:@"0101010002000000"].location / 2;
2705+
self.lastMacErrorCode=(((Byte *)[rfidPacketBuffer bytes])[ptr+startOfCmdEnd+13] << 8) + (((Byte *)[rfidPacketBuffer bytes])[ptr+startOfCmdEnd+12]);
2706+
[cmdRespQueue enqObject:packet];
2707+
[rfidPacketBuffer setLength:0];
2708+
connectStatus=CONNECTED;
2709+
[self.delegate didInterfaceChangeConnectStatus:self]; //this will call the method for connections status chagnes.
2710+
break;
2711+
}
26802712
//check if we are getting the beginning of another 8100 packet but with no 8100 event code. If so, add the event code back with the header response
26812713
else if (![[rfidPacketBufferInHexString substringWithRange:NSMakeRange(ptr * 2, ([rfidPacketBuffer length] - ptr) * 2)] containsString:@"8100"] && [[rfidPacketBufferInHexString substringWithRange:NSMakeRange((ptr * 2), 2)] isEqualToString:@"04"] && [[rfidPacketBufferInHexString substringWithRange:NSMakeRange((ptr * 2)+4, 4)] isEqualToString:@"0580"]) {
26822714

CS108iOSClient/CSLRfidDemoApp.storyboard

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="uy9-1K-dab">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="uy9-1K-dab">
33
<device id="retina4_0" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15509"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
77
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
88
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
99
</dependencies>
@@ -2658,10 +2658,12 @@
26582658
<constraint firstAttribute="bottom" secondItem="hJV-Ao-sxN" secondAttribute="bottom" id="yoZ-AT-Y0i"/>
26592659
</constraints>
26602660
</view>
2661-
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wjw-Xx-9N2">
2662-
<rect key="frame" x="81" y="410" width="158" height="30"/>
2663-
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2661+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wjw-Xx-9N2">
2662+
<rect key="frame" x="85" y="404" width="150" height="33"/>
26642663
<color key="backgroundColor" red="0.63921568627450975" green="0.63921568627450975" blue="0.63921568627450975" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2664+
<constraints>
2665+
<constraint firstAttribute="width" constant="150" id="equ-qw-vrU"/>
2666+
</constraints>
26652667
<fontDescription key="fontDescription" name="Lato-Regular" family="Lato" pointSize="17"/>
26662668
<color key="tintColor" red="0.93725490570000003" green="0.93725490570000003" blue="0.95686274770000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
26672669
<state key="normal" title="Save to File"/>
@@ -2672,6 +2674,7 @@
26722674
</subviews>
26732675
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
26742676
<constraints>
2677+
<constraint firstItem="wjw-Xx-9N2" firstAttribute="centerX" secondItem="LvH-Ge-MiT" secondAttribute="centerX" id="7ao-oF-ShI"/>
26752678
<constraint firstItem="tYY-tp-tY8" firstAttribute="leading" secondItem="r7x-TT-Fdx" secondAttribute="leading" constant="20" id="8Qt-JU-qrA"/>
26762679
<constraint firstItem="izk-vN-mQS" firstAttribute="top" secondItem="pkm-Tr-lhN" secondAttribute="bottom" constant="15" id="8Yt-6O-qcn"/>
26772680
<constraint firstItem="SiA-vG-TOw" firstAttribute="top" secondItem="izk-vN-mQS" secondAttribute="bottom" constant="8" symbolic="YES" id="AL8-Fh-h4H"/>
@@ -2681,6 +2684,7 @@
26812684
<constraint firstItem="pkm-Tr-lhN" firstAttribute="top" secondItem="dSd-N2-8Sh" secondAttribute="bottom" constant="20" id="Gc3-ZG-AJc"/>
26822685
<constraint firstItem="r7x-TT-Fdx" firstAttribute="trailing" secondItem="SiA-vG-TOw" secondAttribute="trailing" constant="20" id="PRa-aT-Ew6"/>
26832686
<constraint firstItem="tYY-tp-tY8" firstAttribute="top" secondItem="SiA-vG-TOw" secondAttribute="bottom" constant="8" id="TEv-BR-xvx"/>
2687+
<constraint firstItem="wjw-Xx-9N2" firstAttribute="top" secondItem="tYY-tp-tY8" secondAttribute="bottom" constant="30" id="Xjj-Dy-HNe"/>
26842688
<constraint firstItem="izk-vN-mQS" firstAttribute="centerX" secondItem="pkm-Tr-lhN" secondAttribute="centerX" id="eXe-2y-tAQ"/>
26852689
<constraint firstItem="SiA-vG-TOw" firstAttribute="leading" secondItem="r7x-TT-Fdx" secondAttribute="leading" constant="20" id="fMy-as-M0X"/>
26862690
<constraint firstItem="dSd-N2-8Sh" firstAttribute="top" secondItem="3DD-BR-tCD" secondAttribute="bottom" constant="28" id="kxn-xE-q34"/>

CS108iOSClient/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleShortVersionString</key>
2020
<string>$(MARKETING_VERSION)</string>
2121
<key>CFBundleVersion</key>
22-
<string>2690</string>
22+
<string>2710</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>NSBluetoothAlwaysUsageDescription</key>

CS108iOSClient/ViewControllers/CSLInventoryVC.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ - (void)refreshTagListing {
126126
else
127127
self.lbStatus.text=[NSString stringWithFormat:@"Battery: %d%%", [CSLRfidAppEngine sharedAppEngine].readerInfo.batteryPercentage];
128128
}
129+
130+
if ([CSLRfidAppEngine sharedAppEngine].reader.lastMacErrorCode != 0x0000)
131+
{
132+
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"RFID Error"
133+
message:[NSString stringWithFormat:@"Error Code: 0x%04X", [CSLRfidAppEngine sharedAppEngine].reader.lastMacErrorCode]
134+
preferredStyle:UIAlertControllerStyleAlert];
135+
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
136+
[alert addAction:ok];
137+
[self presentViewController:alert animated:YES completion:nil];
138+
[CSLRfidAppEngine sharedAppEngine].reader.lastMacErrorCode=0x0000;
139+
}
129140
}
130141
}
131142

CS108iOSClient/ViewControllers/CSLTemperatureUploadVC.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ - (IBAction)btnMQTTUpload:(id)sender {
216216
for (int i=0;i<COMMAND_TIMEOUT_10S;i++) { //wait for 5s for connection
217217
if([CSLRfidAppEngine sharedAppEngine].MQTTSettings.publishTopicCounter==[[CSLRfidAppEngine sharedAppEngine].reader.filteredBuffer count])
218218
break;
219-
[NSThread sleepForTimeInterval:0.1f];
219+
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
220220
}
221221

222222
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Data Upload"

CS108iOSClient/model/CSLReaderSettings.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ -(id)init {
5151
for (int n = 0; n < 16; n++)
5252
[self.dwellTime addObject:@"2000"];
5353
//For CS463, disable all ports except port 0
54+
self.isPortEnabled = [NSMutableArray array];
5455
[self.isPortEnabled addObject:[[NSNumber alloc] initWithBool:TRUE]];
5556
for (int n = 1 ; n < 4; n++)
5657
[self.isPortEnabled addObject:[[NSNumber alloc] initWithBool:FALSE]];

0 commit comments

Comments
 (0)