Skip to content

tedee-com/tedee-example-ble-ios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tedee lock communication example

About

This example project was created by Tedee team to show you how to use Tedee Mobile SDK for iOS.

This project was created using Swift language and run it on iOS device.

Using this example you will be able to connect and communicate with only one lock at the time.

Requirements

Hardware

  1. Tedee Lock - you can order it in our online store
  2. iPhone (real device) with iOS 17.2+ and installed Tedee app
  3. Mac with Sonoma or newer macOS installed
  4. USB - Lightning cable (to connect iPhone to Mac)

Software

  1. Xcode 15.2+ from App Store

Other

  1. Tedee account created in Tedee app
  2. Lock is paired with (added to) Tedee account.
  3. Lock Serial number and Device ID from Tedee app
    • go to: Lock details > Settings (gear icon) > Information

Warning

This project cannot be run on Xcode simulator, you will have to run it on physical device (iPhone).

Initial configuration

Step 1 - configure Xcode project

  1. clone this repository

  2. open tedee example.xcodeproj file in Xcode

  3. in file navigator select tedee example and choose target tedee example from TARGETS

  4. change tab to Signing & Capabilities

  5. change Team to Personal Team

  6. change Bundle Identifier to something else, for example: [YOUR COMPANY DOMAIN].tedee-example

Step 2 - Pairing iPhone with Xcode

  1. On iPhone go to Setting > Privacy & Security, scroll to the bottom to Security section, tap on Developer Mode and enable it

  2. Connect iPhone to your Mac with USB - Lightning cable

  3. Click in the top bar on Any iOS Device or similar text right to tedee example target

  4. Click on Add Additional Simulators...

  5. Cancel Create a new simulator window

  6. On the left sidemenu select Devices and click on the + icon at the bottom

  7. Select connected iPhone from the list

  8. Tap Trust on iPhone to trust your Mac connection and confirm with your iPhone passcode

  9. Click Done

  10. You can select Connect via Network for connecting Xcode to iPhone via WiFi but we do not recommend this if you do not have experience with Xcode

  1. Now you should see your iPhone in top bar, if it's not, click and select it from devices list

Step 3 - Running project

Now you are ready to build the project and upload it to your iPhone.

  1. Cmd + R will build project and run it on connected iPhone.
  2. Unlock your iPhone during build to give Xcode right to upload and start app on it.

First Launch

On first launch app will ask you for permission to use Bluetooth.

App will also generate public key that is required to lock certificate (see next steps). Look for Public key to register in api: in Xcode console. If it didn't opened tap on the in bottom bar to open Xcode console. You will see there also steps that are taken by the app to unlock the lock (connect, start encrypted session, send unlock command, receive response).

Step 4 - register tedee example app

  1. log in to Tedee Portal with credentials from created Tedee account

  2. click on your initials in top right corner

  3. click on Personal Access Keys and generate new access key with permissions:

    • Device certificates - Operate
    • Mobile devices - Read
    • Mobile devices - Write
  4. Go to Tedee API and authorize yourself with created Personal Access Key

    1. proper format is PersonalKey [YOUR PERSONAL ACCESS KEY]
    2. confirm with Authorize
    3. go to Mobile section and use POST /api/[api version]/my/mobile route and click on try it out
    4. enter name (lock name from Tedee iOS app), operatingSystem set to 3 and publicKey the one that was generated by tedee example app on first launch
    5. response will return id that is required in next step (as MobileID)
    6. go to DeviceCertificate section and use /api/[api version]/my/devicecertificate/getformobile
    7. click on Try it out
    8. fill MobileID gathered from previous request response and Device ID from Tedee app
    9. store somewhere response result, you will need it in next step

Warning

Generated certificate has expiration date, which is attached to the response with certificate. After certificate expiration you will not be able to operate the lock and you need to get new one.

Step 4 - fill required configuration

  1. open Configuration.swift in project navigator
  2. replace empty value of SerialNumber with your Tedee lock serial number
  3. replace empty value of CertificateString with certificate value from last API request results
  4. replace empty value of Expiration with expirationDate value from last API request results
  5. replace empty value of DevicePublicKey with devicePublicKey value from last API request results
  6. replace empty value of MobilePublicKey with mobilePublicKey value from last API request results

Step 5 - Connect and send commands

  1. compile and run app again with Cmd + R
  2. if everything is configured properly you should be able to connect to the lock, send commands to it and see bluetooth notification send by the lock (e.g. when you manually close or open lock)

Important

if you have issue with connecting to the lock and sdk returns secureSessionFailed error, open Tedee app and make sure that Tedee app is able to connect to the the same lock and you are able to lock/unlock your lock. After that, this example app should be able to successfully connect to the lock.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages