Result Code
Code | Message |
---|---|
200 | Success |
201 | Oprerator time out |
2002 | Parameter error |
2003 | Server error |
2004 | Chip output error |
2005 | No latitude and longitude information |
401 | Chip loses connection |
60001 | Parameter is null |
200000091 | User Cancel |
Every time you read data through nfc, you need to open NFC first, then issue an instruction to read the data (you can issue multiple commands) and then close NFC.
//open nfc
VeChainNFCSDK.openNFC()
// send command
// ... Can send multiple commands
//close nfc
VeChainNFCSDK.invalidateNFC ()
Read configuration information of chip operation
//open nfc
VeChainNFCSDK.openNFC()
//send command
VeChainNFCSDK.readConfig { (response,errorCode) in
if errorCode == ErrorCode.SuccessCode
{
print("success")
}
//close nfc
VeChainNFCSDK.invalidateNFC ()
}
Get write chip configuration information verification code
The configuration information of temperature, humidity or acceleration should be set before the chip works to ensure that it is the same chip and verified by the verification code. Read the verification code as follows:
//open nfc
VeChainNFCSDK.openNFC()
//send command
VeChainNFCSDK.readVerifyCode { (response, errorCode) in
if code == ErrorCode.SuccessCode
{
print("success")
}
close nfc
VeChainNFCSDK.invalidateNFC ()
}
Setting up Chip Work Configuration
//open nfc
VeChainNFCSDK.openNFC()
//send command
VeChainNFCSDK.setupConfig(configModel:WriteConfigModel) {(response,errorCode) in
if (errorCode == ErrorCode.SuccessCode)
{
print("success")
}
//close nfc
VeChainNFCSDK.invalidateNFC ()
}
WriteConfigModel:
public var verifyCode:Int = 0 // verified by the verification code
public var account:String = "" // the account modifies config
public var isTempEnable:Bool = false // Whether the temperature acquisition function is on.
public var interval:Int = 0 // Temperature acquisition interval (minute), greater than or equal to 1.
public var startDelay:Int = 0 // Delay time (minute), greater than or equal to 0.
public var runningTime:Int = 0 // Running time (minute), 0 to unlimited time.
public var validMinimum:Float = 0.0 // Minimum Temperature (°c) Accurate 1-digit decimal, not lower than -40.
public var validMaximum:Float = 0.0 // Maximum Temperature (°c) Accurate 1-digit decimal,not higher than 85.
public var isHumidityEnable:Bool = false // Whether the humidity acquisition function is on.
public var humidityInterval:Int = 0 // Humidity acquisition interval (minute), greater than or equal to 1.
public var humidityStartDelay:Int = 0 // Delay time (minute), greater than or equal to 0.
public var humidityRunningTime:Int = 0 // Running time (minute), 0 to unlimited time.
public var isAccelerateEnable:Int = false // Whether the Acceleration acquisition function is on.
Read the collected temperature, humidity and acceleration data
VeChainNFCSDK.openNFC()
VeChainNFCSDK.readSensorData() { (sensorDataModel,errorCode) in
if (errorCode == ErrorCode.SuccessCode)
{
print("success")
}
VeChainNFCSDK.invalidateNFC()
}
SensorCollectionDataModel description
public var tempGroupSize:Int = 0 //Number of compression of temperature data
public var humidityGroupSize:Int = 0 //Number of humidity data compressed
public var accGroupSize:Int = 0 //Number of acceleration data compression
public var tempDataList:Array<Any> = Array<Any>()
public var tempTimeList:Array<Any> = Array<Any>()
public var tempHash:Array<Any> = Array<Any>()
public var humidityDataList:Array<Any> = Array<Any>()
public var humidityTimeList:Array<Any> = Array<Any>()
public var humidityHash:Array<Any> = Array<Any>()
public var accelerateDataList:Array<Any> = Array<Any>()
public var accelerateTimeList:Array<Any> = Array<Any>()
public var accelerateHash:Array<Any> = Array<Any>()
public var config:String = ""//Hexadecimal string
public var configModel:ConfigDataModel = ConfigDataModel() //
ConfigDataModel description
public var isTempEnable:Bool = false //Is the temperature measurement on
public var interval:Int = 0//Unit minute
public var startDelay:Int = 0//Unit minute
public var runningTime:Int = 0//Unit minute
public var validMinimum:Float = 0.0//Actual value*10
public var validMaximum:Float = 0.0//Actual value*10
public var accuracy:Int = 0//Temperature data storage accuracy
public var isHumidityEnable:Bool = false //Is the humidity measurement on
public var humidityInterval:Int = 0 //Humidity measurement interval,Unit minute
public var humidityStartDelay:Int = 0 //Unit minute
public var humidityRunningTime:Int = 0 //Unit minute
public var isAccelerateEnable:Bool = false //Is the accelerate measurement on
public var configTime:Int = 0//Positioning accuracy,Unit meters
public var status:Int = 0
public var account:String = ""
public var configLongitude:Float = 0.0//(Actual value*1000000);
public var configLatitude:Float = 0.0//(Actual value*1000000);
public var configLocationAccuracy:Int = 0//Positioning accuracy,Unit meters
public var isStop:Bool = false //Whether the chip is suspended
public var isTemperatureStop:Bool = false //Whether temperature acquisition is stopped
public var isHumidityStop:Bool = false //Whether humidity acquisition is stopped
public var isAccelerateStop:Bool = false //Whether acceleration acquisition is stopped
public var isTemperatureFull:Bool = false //Whether temperature data is full
public var isHumidityFull:Bool = false //Whether humidity data is full
public var isAccelerateFull:Bool = false //Whether accelerate data is full
public var isSupportTemperature:Bool = false
public var isSupportHumidity:Bool = false
public var isSupportAcceleration:Bool = false
public var uid:String = ""//Hexadecimal string
public var vid:String = ""//Hexadecimal string
public var saltNo:String = ""//Hexadecimal string
public var remainingRunTime:Float = ""//Calculated battery runtime
public var battery:Int = ""//Battery percentage 0 ~ 100
public var currentTime:Int = 0 // 'current' as in: when the response class was created
public var correctionFactor:Double = 0.0 //correction factor
Verification of chip collection data
SDK is used to verify whether the data is true and reliable, or whether the data has been modified.If the data is not true or modified, the validation return failure
let verifyModel = VerifyDataModel()
verifyModel.data = self.sensorDataModel.dataList
verifyModel.signature = self.sensorDataModel.signature
switch opType {
case .readTemperature:
verifyModel.groupSize = String(self.sensorDataModel.tempGroupSize)
case .readHumidity:
verifyModel.groupSize = String(self.sensorDataModel.humidityGroupSize)
case .readAcceleration:
verifyModel.groupSize = String(self.sensorDataModel.accGroupSize)
default:
break
}
verifyModel.uid = self.sensorDataModel.uid
verifyModel.vid = self.sensorDataModel.vid
verifyModel.saltNo = self.sensorDataModel.saltNo
verifyModel.config = self.sensorDataModel.config
VeChainNFCSDK.verfiyHash(verifyModel:verifyModel) { (code) in
if code == ErrorCode.SuccessCode{
TAlert.show(type: .info, text: "checkhash success")
}else{
TAlert.show(type: .info, text: "checkhash fail")
}
}
Comments
0 comments
Please sign in to leave a comment.