All Projects → nkaminski → csrmesh

nkaminski / csrmesh

Licence: LGPL-3.0 License
Reverse engineered bridge implementation of the CSRMesh BTLE protocol

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to csrmesh

Ct Smart Home
A ready-to-use Node-RED setup for home automation
Stars: ✭ 132 (+103.08%)
Mutual labels:  home-automation, bluetooth-low-energy
switchmate
A python-based command line utility for controlling Switchmate switches
Stars: ✭ 34 (-47.69%)
Mutual labels:  home-automation, bluetooth-low-energy
home assistant-ble
Companion application for home-assistant, sending bluetooth low energy detection
Stars: ✭ 21 (-67.69%)
Mutual labels:  home-automation, bluetooth-low-energy
Xiaomi Flower Care Api
Xiaomi Flower Care (MiFlora) API wrapper.
Stars: ✭ 111 (+70.77%)
Mutual labels:  home-automation, bluetooth-low-energy
pycalima
Python interface for Pax Calima Fan via Bluetooth LE
Stars: ✭ 34 (-47.69%)
Mutual labels:  home-automation, bluetooth-low-energy
home
Monorepo for all home automation related development, including integrated firmware, PCBs, configuration, and bridges
Stars: ✭ 104 (+60%)
Mutual labels:  home-automation
home-assistant-ansible
🎭 Ansible playbooks/role for the setup of Home Assistant.
Stars: ✭ 48 (-26.15%)
Mutual labels:  home-automation
itag
iTag tracker manager for real people
Stars: ✭ 35 (-46.15%)
Mutual labels:  bluetooth-low-energy
rfoutlet
Control remote controlled outlets via Raspberry PI
Stars: ✭ 14 (-78.46%)
Mutual labels:  home-automation
deskbluez
Connects to a low energy actuator system via bluetooth and allows remote control via command line or internal managed interface.
Stars: ✭ 56 (-13.85%)
Mutual labels:  bluetooth-low-energy
modbus4mqtt
Modbus TCP <-> MQTT glue. YAML configuration. Robust.
Stars: ✭ 21 (-67.69%)
Mutual labels:  home-automation
ruuvitag-demo
Demo of reading Bluetooth Low Energy sensor measurements of RuuviTag environmental sensors and feeding them to MQTT, a database and dashboards
Stars: ✭ 14 (-78.46%)
Mutual labels:  bluetooth-low-energy
X10RF-Arduino
Arduino Library for sending x10 messages by RF
Stars: ✭ 17 (-73.85%)
Mutual labels:  home-automation
HAController
A very simple home automation controller in Visual Basic .NET
Stars: ✭ 15 (-76.92%)
Mutual labels:  home-automation
raincloudy
RainCloudy is a library written in Python 3.x that manages the Melnor RainCloud Smart Garden Watering Irrigation Timer.
Stars: ✭ 22 (-66.15%)
Mutual labels:  home-automation
Home-Assistant-Main
My Home Assistant Configuration Be sure to ⭐ my repo so you can keep up to date on the daily progress!
Stars: ✭ 54 (-16.92%)
Mutual labels:  home-automation
AISecurityCamera
A simple Security Camera example which detects motion and perform face recognition
Stars: ✭ 27 (-58.46%)
Mutual labels:  home-automation
pybluez-examples
Example Bluetooth tasks using the Python PyBluez module
Stars: ✭ 59 (-9.23%)
Mutual labels:  bluetooth-low-energy
jarvis
Jarvis Home Automation
Stars: ✭ 81 (+24.62%)
Mutual labels:  home-automation
automate-home
Yet another python home automation (iot) project. Because a smart light is more than just on or off.
Stars: ✭ 59 (-9.23%)
Mutual labels:  home-automation

csrmesh

Reverse engineered bearer/bridge implementation of the CSRMesh BTLE protocol including all necessary cryptographic and packing routines required to send valid packets over a CSRMesh BTLE network. This particular implementation currently supports the CSRMesh lighting API and the MOVE controller, it has been succssfully tested with a pair of Feit HomeBrite smart LED bulbs and a Teptron MOVE. However, the implemtation of other CSRMesh APIs should be quite straightforward if needed. This implementation now supports sending packets to multi-device mesh networks as well as addressing devices by either device ID or group ID.

Tested Devices

  • Feit HomeBrite A19 Household, Model AOM800/827/LED/HBR
  • Feit HomeBrite B10 Household, Model CFC300/LED/HBR
  • Teptron MOVE (partial support, see issue #17)

Requirements

  • Python 2.7.x or 3.x
  • bluez 5.3 or newer
  • bluepy
  • pycryptodomex

Usage

csrmesh-cli {lightbulb,move} [-h] --pin (4 digit pin) --dest (destination BTLE address)
[--level LEVEL] [--red RED] [--green GREEN] [--blue BLUE] [--objid OBJID] [--position POSITION]

All lighting levels are represented using numbers from 0 (off) to 255 (maximum). The Teptron MOVE controller position is specified as 0 (up) to 255 (down).

Object ID's are specified via the following syntax:

  • An object ID of zero results in a broadcast message. This is the default.
  • Positive object ID's will be interpreted as an individual device ID. Device indicies begin at 1.
  • Negative object ID's will be interpreted as group numbers.

Addressing examples:

Bulb/Device 5 -> --objid 5 
Group 3       -> --objid -3
Broadcast     -> --objid 0 (or omit the --objid option)

Protocol Documentation

Network Key Derivation

The 128 bit network key used in CSRMesh networks is derived by concatenating the ASCII representation of the PIN with a null byte and the string 'MCP', computing the SHA256 hash of the string, reversing the order of the bytes in the resulting hash, and taking the first 16 bytes as the key.

Forming Authenticated Packets

Packets sent to CSRMesh devices require authentication as well as encryption. All multibyte types are represented in little endian format. To form a valid packet, the sequence/nonce value, constant 0x0080, and 10 null bytes are concatenated together to form a 128 bit initialization vector (IV). This IV, as well as the network key derived earlier is then used to initialaize AES-128 in OFB mode. The arbitrary length data payload is then encrypted using this AES-OFB instance to form the encrypted payload. Next, a message authentication code is computed using HMAC-SHA256, using the network key as the secret, of the following data: 8 null bytes, sequence number, constant 0x80 and encrypted payload. The order of the bytes in the resulting hash are then reversed and the hash truncated to 8 bytes. The final output packet can then be built by contatenating the sequence/nonce value, constant 0x80, encrypted payload, truncated HMAC, and the constant 0xff.

Sending packets

Packets are then sent via the Bluetooth LE GATT protocol. To send a packet, the data must be written to two write only handles, for Feit HomeBrite lightbulbs that is 0x0011 and 0x0014 for the Teptron MOVE that is 0x0021. If the packet is longer than 20 bytes, the first 20 bytes first are written to the first handle and then the remaining bytes are written to the handle with an address increased by 3 (e.g. handle 0x0011 +3 = 0x0014).

Commands for the MOVE

The Teptron MOVE supports a set of commands, all commands seem to use the 0x0021 handle and 0x73 prefixed before the command itself (this number is also present in the lightbulb commands, we don't know the origin of it). A list of commands for the MOVE is available here: http://www.teptron.com/MOVE_UART_Commands_ver1.0.pdf

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].