Skip to content

Commit

Permalink
Carried over v3.1 view controller changes from Objective-C to Swift
Browse files Browse the repository at this point in the history
- Added tag focus for Impinj extension
- Added LNA configurations for improving high volume tag reading
- Added frequency and region configurations for supporting all reader model
- Bug fix on duplicate tags during inventory
- Revised battery level characterization algorithm
- Added save tag data to csv file on inventory page
  • Loading branch information
ksclam committed Jun 9, 2020
1 parent b2b5009 commit 144c466
Show file tree
Hide file tree
Showing 10 changed files with 1,008 additions and 289 deletions.
4 changes: 2 additions & 2 deletions CS108iOSClient.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -627,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";
Expand Down Expand Up @@ -655,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";
Expand Down
Binary file not shown.
816 changes: 537 additions & 279 deletions CS108iOSClient/CSLRfidDemoApp.storyboard

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CS108iOSClient/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>274</string>
<string>293</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSBluetoothAlwaysUsageDescription</key>
Expand Down
41 changes: 41 additions & 0 deletions CS108iOSClient/ViewControllers/CSLDeviceTV.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
49 changes: 49 additions & 0 deletions CS108iOSClient/ViewControllers/CSLInventoryVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 144c466

Please sign in to comment.