fgorina/9BMetrics

Change Pin Code

Closed this issue · 2 comments

How about changing the pin code?

I did complete changing the pin code. Changing will take effect after device restart.

    func setPincode(pincode : String){
        //Checking
        if pincode.characters.count != 6 {
            print("wrong attempt changing pincode with non 6 numbers")
            return
        }
        for i in pincode.characters {
            let someString = String(i)
            if Int(someString) == nil{
                print("wrong attempt changing pincode with non number symbol")
                return
            }
        }

        // That write Pincode
        var index = 0
        for i in 23 ..< 26{
            let index0 = pincode.startIndex.advancedBy(index)
            let ch0 = pincode[index0] as Character
            let int0 = Int(String(ch0))!
            let b0 = UInt8(int0)

            let index1 = pincode.startIndex.advancedBy(index+1)
            let ch1 = pincode[index1] as Character
            let int1 = Int(String(ch1))!
            let b1 = UInt8(int1)

            var message = BLENinebotMessage(commandToWrite: UInt8(i), dat:[b0, b1] )
            if let dat = message?.toNSData(){
                self.connection.writeValue(dat)
            }

            // Get value to see if it is OK
            message = BLENinebotMessage(com: UInt8(i), dat: [UInt8(2)])
            if let dat = message?.toNSData(){
                self.connection.writeValue(dat)
            }
            index += 2;
        }
    }

Thanks will include it in next distribution

Paco Gorina
E-mail : fgorina@gmail.com
Tlf.:+34 619 790 158(tel:+34%20619%20790%20158)

On 24 maig 2016 , 10:36 +0200, ILYAnotifications@github.com, wrote:

Closed#4(#4).


You are receiving this because you are subscribed to this thread.
Reply to this email directly orview it on GitHub(#4 (comment))