Skip to content

chronicled/drone-demo-controller

Repository files navigation

Drone Demo Controller

iOS app for controlling Chronicled's drone demo

Description

This app verifies Chronicled BLE chips using Apple's CoreBluetooth library. This app also controls the demo's lights and drapes

Demo Explaination

  • Done approaches iPhone near drapes to be opened
  • This app discovers the chip and requests a challenge from the server. The identity used is the deviceID. A deviceID is a 6 byte unique hex string. ble:1.0:1234567890ab
 static func requestChallenge(identity: String, cb: (Response<AnyObject, NSError> -> ())) {
     let req = Alamofire.request(.POST,
                                 "\(Config.domain)requestChallenge",
                                 parameters: ["identity" : identity],
                                 encoding: .JSON,
                                 headers: headers)

     req.responseJSON(completionHandler: cb)
 }
  • If the Registrant has access to the door, a challenge will be returned from the server. If the Registrant doesn't have access, the chip will be rejected. The app will connect to the chip if a challenge is returned:
self.centralManager?.connectPeripheral(peripheral, options: nil)
  • After connecting to the chip, the app writes the challenge received from the server to the Challenge Characteristic of the BLE chip
peripheral.writeValue(challenge.dataWithHexString(),
                      forCharacteristic: challengeCharecteristic,
                      type: .WithResponse)
  • Now the app waits for the signature to be generated by the chip. The signature will be written to the Signature characteristic. After the signature has been generated, the app reads the signature.
peripheral.readValueForCharacteristic(self.signatureChararacteristic)
  • The app then sends the signature, challenge, and identity to the verification endpoint.
static func sendVerification(identity: String,
                             challenge: String,
                             signature: String,
                             cb: (Response<AnyObject, NSError> -> ())) {
    let params = [
        "identity" : identity,
        "challenge" : challenge,
        "signature" : signature
    ]

    let req = Alamofire.request(.POST,
                                "\(Config.domain)verifyChallenge",
                                parameters: params,
                                encoding: .JSON,
                                headers: headers)

    req.responseJSON(completionHandler: cb)
}
  • The server will return whether or not the signature is verified. Using this response, the app will either reject or grand acccess to the chip.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published