Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
cs_CmdSource.h
Go to the documentation of this file.
1/*
2 * Author: Crownstone Team
3 * Copyright: Crownstone (https://crownstone.rocks)
4 * Date: Jul 22, 2019
5 * License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)
6 */
7
8#pragma once
9
10#include <cstdint>
11
13 CS_CMD_SOURCE_TYPE_ENUM = 0, // Source ID is one of cs_cmd_source_id.
14 CS_CMD_SOURCE_TYPE_BEHAVIOUR = 1, // Source ID is the Nth behaviour rule.
15 CS_CMD_SOURCE_TYPE_BROADCAST = 3, // Source ID is the device ID.
16 CS_CMD_SOURCE_TYPE_UART = 4, // Source ID is the device ID.
17};
18
24 CS_CMD_SOURCE_INTERNAL = 2, // Internal control command, should not be used.
25 CS_CMD_SOURCE_CONNECTION = 4, // BLE connection.
26 CS_CMD_SOURCE_SWITCHCRAFT = 5, // Switchcraft trigger.
27 CS_CMD_SOURCE_TAP_TO_TOGLE = 6, // Tap to toggle trigger.
28 CS_CMD_SOURCE_MICROAPP = 7, // Command comes from a microapp.
29};
30
34struct __attribute__((packed)) cmd_source_t {
35 bool flagExternal : 1; // True when the command was received via mesh. Bit 0.
36 uint8_t reserved : 4; // Reserved for flags. Bits 1-4.
37 uint8_t type : 3; // See cs_cmd_source_type. Bits 5-7.
38 uint8_t id : 8; // Source ID, depends on type.
39
41 : flagExternal(false), reserved(0), type(CS_CMD_SOURCE_TYPE_ENUM), id(sourceId) {}
42
45 uint8_t sourceId = CS_CMD_SOURCE_NONE,
46 bool viaMesh = false)
47 : flagExternal(viaMesh), reserved(0), type(type), id(sourceId) {}
48};
49
54struct __attribute__((packed)) cmd_source_with_counter_t {
56 uint8_t count; // Command counter, increases each command.
57 cmd_source_with_counter_t(cmd_source_t source = CS_CMD_SOURCE_NONE) : source(source), count(0) {}
58 cmd_source_with_counter_t(cmd_source_t source, uint8_t count) : source(source), count(count) {}
59};
cs_cmd_source_type
Definition: cs_CmdSource.h:12
@ CS_CMD_SOURCE_TYPE_UART
Definition: cs_CmdSource.h:16
@ CS_CMD_SOURCE_TYPE_BEHAVIOUR
Definition: cs_CmdSource.h:14
@ CS_CMD_SOURCE_TYPE_BROADCAST
Definition: cs_CmdSource.h:15
@ CS_CMD_SOURCE_TYPE_ENUM
Definition: cs_CmdSource.h:13
cs_cmd_source_id
Command originates from .
Definition: cs_CmdSource.h:22
@ CS_CMD_SOURCE_SWITCHCRAFT
Definition: cs_CmdSource.h:26
@ CS_CMD_SOURCE_TAP_TO_TOGLE
Definition: cs_CmdSource.h:27
@ CS_CMD_SOURCE_MICROAPP
Definition: cs_CmdSource.h:28
@ CS_CMD_SOURCE_NONE
Definition: cs_CmdSource.h:23
@ CS_CMD_SOURCE_CONNECTION
Definition: cs_CmdSource.h:25
@ CS_CMD_SOURCE_INTERNAL
Definition: cs_CmdSource.h:24
Struct that tells where a command originated from.
Definition: cs_CmdSource.h:34
cmd_source_t(cs_cmd_source_type type=CS_CMD_SOURCE_TYPE_ENUM, uint8_t sourceId=CS_CMD_SOURCE_NONE, bool viaMesh=false)
Definition: cs_CmdSource.h:43
cmd_source_t(cs_cmd_source_id sourceId=CS_CMD_SOURCE_NONE)
Definition: cs_CmdSource.h:40
uint8_t type
Definition: cs_CmdSource.h:37
uint8_t id
Definition: cs_CmdSource.h:38
bool flagExternal
Definition: cs_CmdSource.h:35
uint8_t reserved
Definition: cs_CmdSource.h:36
Struct that tells where a command originated from.
Definition: cs_CmdSource.h:54
cmd_source_with_counter_t(cmd_source_t source, uint8_t count)
Definition: cs_CmdSource.h:58
cmd_source_with_counter_t(cmd_source_t source=CS_CMD_SOURCE_NONE)
Definition: cs_CmdSource.h:57
cmd_source_t source
Definition: cs_CmdSource.h:55
uint8_t count
Definition: cs_CmdSource.h:56