Skip to content

Bluetooth LE access library for CANDY HOUSE SESAME 5 / SESAME 5 PRO / SESAME Bot 2 / SESAME 4 / SESAME 3 / SESAME bot / SESAME 3 bike (SESAME Cycle)

License

Notifications You must be signed in to change notification settings

homy-newfs8/libsesame3bt-core

Repository files navigation

libsesame3bt-core

Bluetooth LE access library for CANDY HOUSE SESAME 5 / SESAME 5 PRO / SESAME Bot 2 / SESAME 4 / SESAME 3 / SESAME bot / SESAME 3 bike (SESAME Cycle)

Usage

This library contains the message processing part. BLE connections must be handled outside of this library.

  1. Prepare a callback object inherited from SesameClientBackend
  2. Create SesameClientCore instance.
  3. Initialize with SesameClientCore::begin() and SesameClientCore::set_key().
  4. Connect to SESAME by any BLE API (use BLE MAC Address of SESAME).
  5. Prepare to access service (UUID=Sesame::SESAME3_SRV_UUID).
  6. Prepare to send data to Tx characteristic in above service (UUID=Sesame::TxUUID).
  7. Prepare to receive notification from Rx characteristic (UUID=Sesame::RxUUID).
  8. When notification received from above Rx characteristic, call SesameClientCore::on_received() with the notification data.
  9. When SesameClientBackend::write_to_tx() is called, send the data to above Tx characteristic(w/o request response).
  10. When SesameClientBackend::disconnect() is called, disconnect from SESAME.
  11. When disconnected from SESAME, call SesameClientCore::on_disconnected().

Dependency

If your execution environment includes Mbed TLS's CMAC functions, define USE_FRAMEWORK_MBEDTLS_CMAC at compile time.

Integrated library example

libsesame3bt is a library that integrates this library with the ESP32 / Android / NimBLE libraries.

With libsesame3bt, you can control SESAME as follows.

platformmio.ini

[env]
platform = espressif32
framework = arduino
lib_deps =
	https://github.com/homy-newfs8/libsesame3bt#0.18.0
build_flags =
	-std=gnu++17
build_unflags =
	-std=gnu++11

Example

Scan

using libsesame3bt::SesameInfo;
using libsesame3bt::SesameScanner;

void do_scan() {
	SesameScanner& scanner = SeameScanner::get();
	std::vector<SesameInfo> results;

	scanner.scan(10, [&results](SesameScanner& _scanner, const SesameInfo* _info)) {
		results.push_back(*_info);
	}
	Serial.printf("%u devices found\n", results.size());
	for (const auto& it : results) {
		Serial.printf("%s: %s: model=%u, registered=%u\n", it.uuid.toString().c_str(), it.address.toString().c_str(),
		                (unsigned int)it.model, it.flags.registered);
	}
}

Control

using libsesame3bt::Sesame;
using libsesame3bt::SesameClient;
using libsesame3bt::SesameInfo;

void do_unlock_lock() {
	SesameClient client{};
	// Use SesameInfo to initialize
	client.begin(sesameInfo.addr, sesameInfo.model);
	// or specify bluetooth address and model type directory
	client.begin(BLEAddress{"***your device address***", BLE_ADDR_RANDOM}, Sesame::model_t::sesame_5);

	client.set_keys(nullptr, SESAME_SECRET);
	client.connect();
	// Wait for connection and authentication done
	// See example/by_scan/by_scan.cpp for details
	client.unlock(u8"**TAG**");
	delay(3000);
	client.lock(u8"***TAG***");
}

Sample App

Integrate to your Home Automation system without code

Server feature

Starting with version 0.8.0, the Sesame Server feature has been added, allowing the device to pretend to be a SESAME 5 device and listen for and handle push button events from CANDY HOUSE Remote/nano and open/close events from the Open Sensor.

See libsesame3bt-server library for usage.

License

MIT AND Apache-2.0

Almost all code is licensed under MIT-style license. Files under src/mbedtls-extra are licensed under Apache-2.0.

See Also

README.ja.md

About

Bluetooth LE access library for CANDY HOUSE SESAME 5 / SESAME 5 PRO / SESAME Bot 2 / SESAME 4 / SESAME 3 / SESAME bot / SESAME 3 bike (SESAME Cycle)

Resources

License

Stars

Watchers

Forks

Packages

No packages published