SesameSDK on iOS/Android is a delightful Bluetooth/IoT(Internet of Things) library for your iOS/Android app. The official Sesame app is built on this SesameSDK. By using SesameSDK, your app will have ALL functions and features that Sesame app has, which means, you will be able to
- Register Sesame
- Lock door
- Unlock door
- Share keys
- Read door history
- Update Sesame firmware
- Configure Auto-lock
- Configure angles
- Get the statuses such battery status
- iOS/iPadOS Widget
- Apple Watch app
with your app.
Please note, SesameSDK currently only supports Sesame 2 series or Sesame 1 that runs SesameOS 2 which will be available in late 2020.
Minimum Targets | Minimum Bluetooth Target | Minimum IDEs |
---|---|---|
iOS 11 iPadOS 13.1 |
Bluetooth 4.0 LE | Xcode 11.5 |
Android 5.0 | Bluetooth 4.0 LE | Android Studio 4.0 |
- SesameSDK.framework
- AWSAPIGateway.framework
- Download SesameSDK and play with the included iOS/Android Demo app. または Apple TestFlight / Google Drive から Demo app をダウンロードする。
- Drag the SesameSDK.framework and AWSAPIGateway.framework into your project.
- Get the API Key and the Identity Pool ID from CANDY HOUSE in order to register Sesame device and access the history.
- Setup the API Key and the Identity Pool ID in
didFinishLaunchingWithOptions
ofAppDelegate
.
import SesameSDK
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
...
CHConfiguration.shared.setAPIKey("API_KEY")
CHConfiguration.shared.setIdentityPoolId("IDENTITY_POOL_ID")
...
}
- Scan for Sesame devices.
CHBleManager.shared.enableScan()
- Disconnect Sesame devices and stop Bluetooth scanning when entering the background.
CHBleManager.shared.disableScan()
CHBleManager.shared.disConnectAll()
- Set up
CHBleManager
's delegate property to discover unregistered Sesame devices.
CHBleManager.shared.delegate = self
Once you delegate to CHBleManager
and also adopted the CHBleManagerDelegate
protocol, you will recevie unregistered Sesame devices in the following methods.
class SomeClass: CHBleManagerDelegate {
public func didDiscoverUnRegisteredSesames(sesames: [CHSesame2]) {
// Your implementation
}
public func didDiscoverUnRegisteredSesame(sesame: CHSesame2) {
// Your implementation
}
}
- Connect unregistered Sesame devices.
Before registering a Sesame device, you have to connect to it in order to send commands to it.
public func didDiscoverUnRegisteredSesames(sesames: [CHSesame2]) {
for sesame2 in sesame2s {
sesame2.connect()
}
}
When you are ready to register the Sesame device, you can send the register command as long as the device's status is .readytoRegister
, otherwise, you may want to delegate to the device so you can monitor the status updates of the Sesame device, and be able to connect to it once the status becomes .readytoRegister
.
class SomeClass: CHSesame2Delegate {
func register() {
// Resiger the device if it is ready.
if sesame2.deviceStatus == .readytoRegister {
sesame2.registerSesame( { result in
// Completion handler
})
} else {
// Otherwise monitor the status until it is ready.
sesame2.delegate = self as CHSesame2Delegate
}
}
func onBleDeviceStatusChanged(device: CHSesame2, status: CHSesame2Status) {
if status == .readytoRegister {
device.registerSesame( { result in
// Completion handler
})
}
}
}
After successfully registering Sesame device with device.registerSesame
, you can operate the Sesame device. The following examples demonstrate how to operate the Sesame device.
Every registered Sesame device can be retrieved via CHBleManager.shared.getSesames()
.
CHBleManager.shared.getSesames() { result in
switch result {
case .success(let ssms):
// Success handle
case .failure(let error):
// Error handle
}
}
- You may want to
connect()
the device before sending any command.
sesame2.connect()
delegate
to the Sesame device if you would like to receive the Sesame device's status updates.
sesame2.delegate = self
class SomeClass: CHSesame2Delegate {
/// Will be invoked whenever sesame device interaction status changed.
/// - Parameters:
/// - device: Sesame device.
/// - status: `CHDeviceStatus`
func onBleDeviceStatusChanged(device: CHSesame2, status: CHSesame2Status)
/// Will be invoked whenever sesame device status has changed.
/// - Parameters:
/// - device: Sesame device.
/// - status: `CHSesameMechStatus`
/// - intention: `CHSesameIntention`
func onMechStatusChanged(device: CHSesame2, status: CHSesame2MechStatus, intention: CHSesame2Intention)
}
- Locked/Unlocked angle adjustment:
// Lock: 90°, Unlock: 0°
var config = CHSesameLockPositionConfiguration(lockTarget: 1024/4, unlockTarget: 0)
sesame2.configureLockPosition(configure: &config)
- Enable/Disable auto-lock:
sesame2.enableAutolock(delay: second[row]) { (delay) -> Void in
// Complete handler
}
sesame2.disableAutolock() { (delay) -> Void in
// Complete handler
}
- Drop Key:
This command will clear the Sesame keys saved in SesameSDK. This means you will not able to retrieve the Sesame device viaCHBleManager.shared.getSesames()
.
sesame2.dropKey()
- Reset Sesame:
This command will reset the Sesame device and clear the Sesame keys saved in SesameSDK.
sesame2.resetSesame()
- UUID:
Every Sesame device has a unique identifier.
sesame2.deviceId
- Sesame device status (
noSignal
,receiveBle
,connecting
,loginStatus
, etc.) Please see Documents/CHSesame2Status.md
sesame2.deviceStatus
- Sesame mechanical status (angle position, battery status, etc) Please see Documents/CHSesame2MechStatus.md
sesame2.mechStatus
sesame2.toggle { result in
// Completion handler
}
SesameSDK can export keys(Base64 encoded JSON objects) to you, and you can share the keys with other people in many ways.
- Export Sesame keys:
sesame2.getKey()
- Import Sesame keys:
Once you imported keys(Base64 encoded JSON objects) successfully, you can retrieve the device viaCHBleManager.shared.getSesames()
.
CHDeviceManager.shared.receiveSesame2Keys(sesame2Keys: [String]) { result in
switch result {
case .success(_):
// Success handler
case .failure(let error):
// Error handler
}
}
- If you found a bug, and can provide steps to reliably reproduce it, open an issue.
- If you have a feature request, open an issue.
- If you want to contribute, submit a pull request.
- If you believe you have identified a security vulnerability with SesameSDK, you should report it as soon as possible via email to developers@candyhouse.co Please do not post it to a public issue tracker.
SesameSDK is maintained by CANDY HOUSE, Inc. under the MIT License.