You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When no device is connected, advertisements will be sent at a regular interval (100ms by default). A device that actively scans, will also receive a scan response packet. This contains useful info about the state.
iBeacon advertisement packet
This packet is according to iBeacon spec, see for example here.
Shows if the Crownstone has something new to tell.
int 8
Temperature
1
Chip temperature (°C)
int 32
Power usage
4
The power usage at this moment (mW).
int 32
Accumulated energy
4
The accumulated energy (kWh).
Switch State Packet
To be able to distinguish between switching with relay and switching with PWM, the switch state is a bit struct with
the following layout
Bit 7 is used for the Relay Flag, where 0 = OFF, 1 = ON
Bits 6-0 are used for PWM, where 100 is full ON, 0 is OFF, dimmed in between
Services
When connected, the following services are available.
Crownstone service
The crownstone service has UUID 24f00000-7d10-4805-bfc1-7663a01c3bff and provides all the functionality of the Crownstone through the following services
Read or Notify on a previously selected state variable
The control characteristics (Control, Mesh Control, Config Control and State Control) of the Crownstone service return a uint 16 code on execution of the command. The code determines success or failure of the command. If commands have to be executed sequentially, make sure that the return value of the previous command was received before calling the next (either by polling or subscribing). The possible values of the return values are listed in the table below
Value
Name
Description
0
SUCCESS
completed successfully
1
VALUE_UNDEFINED
no value provided
2
WRONG_PAYLOAD_LENGTH
wrong payload lenght provided
3
UNKNOWN_OP_CODE
unknown operation code, e.g. notify for config read
5
BUFFER_LOCKED
buffer is locked, failed queue command
256
COMMAND_NOT_FOUND
command type not found
257
NOT_AVAILABLE
command not available in this mode
258
WRONG_PARAMETER
wrong parameter provided
259
COMMAND_FAILED
other failure
260
NOT_IMPLEMENTED
command not implemented (only debug version)
512
INVALID_MESSAGE
invalid mesh message provided
768
READ_CONFIG_FAILED
read configuration failed
769
WRITE_CONFIG_DISABLED
write configuration disalbed for this type
770
CONFIG_NOT_FOUND
config type not found
1024
STATE_NOT_FOUND
state type not found
1025
STATE_WRITE_DISABLED
writing to state disabled
Setup service
The setup service has UUID 24f10000-7d10-4805-bfc1-7663a01c3bff and is only available after a factory reset.
Read or Notify on a previously selected config setting
The control characteristics (Control, and Config Control) of the Setup Service return a uint 16 code on execution of the command. The code determines success or failure of the command. If commands have to be executed sequentially, make sure that the return value of the previous command was received before calling the next (either by polling or subscribing). The possible values are the same as for the Crownstone Service, see above.
General service
The general service has UUID 24f20000-7d10-4805-bfc1-7663a01c3bff.
Characteristic
UUID
Date type
Description
Temperature
24f20001-7d10-4805-bfc1-7663a01c3bff
int 32
Chip temperature in Celcius. Notifications are available.
Reset
24f20002-7d10-4805-bfc1-7663a01c3bff
uint 8
Write 1 to reset. Write 66 to go to DFU mode.
Power service
The power service has UUID 24f30000-7d10-4805-bfc1-7663a01c3bff.
Characteristic
UUID
Date type
Description
PWM
24f30001-7d10-4805-bfc1-7663a01c3bff
uint 8
Set PWM value. Value of 0 is completely off, 255 (100 on new devices) is completely on.
Validate Setup, only available in setup mode, makes sure everything is configured, then reboots to normal mode
18
Request Service Data
-
Causes the crownstone to send it's service data over the mesh
Enable Scanner payload
Type
Name
Length
Description
uint 8
enable
1
0 = OFF, other = ON
uint 16
delay
1
start scanner with delay in ms
Configuration packet
Type
Name
Length
Description
uint 8
Type
1
Type, see table with configuration types below.
uint 8
OpCode
1
The op code determines if it's a write or a read operation, see table with op codes below
uint 16
Length
2
Length of the payload in bytes.
uint 8
Payload
Length
Payload data, depends on type.
Available configurations types:
Type nr
Type name
Payload type
Description
0
Device name
char []
Name of the device.
1
Device type
char []
Deprecated.
2
Room
uint 8
Deprecated.
3
Floor
uint 8
Floor number. Deprecated
4
Nearby timeout
uint 16
Time in ms before switching off when none is nearby
5
PWM frequency
uint 8
Sets PWM frequency not implemented
6
iBeacon major
uint 16
iBeacon major number.
7
iBeacon minor
uint 16
iBeacon minor number.
8
iBeacon UUID
uint 8 [16]
iBeacon UUID.
9
iBeacon Tx Power
int 8
iBeacon signal strength at 1 meter.
10
Wifi settings
char []
Json with the wifi settings: { "ssid": "<name here>", "key": "<password here>"}.
11
TX power
int 8
TX power, can be: -40, -30, -20, -16, -12, -8, -4, 0, or 4.
12
Advertisement interval
uint 16
Advertisement interval between 0x0020 and 0x4000 in units of 0.625 ms.
13
Passkey
uint 8 [6]
Passkey of the device: must be 6 digits.
14
Min env temp
int 8
If temperature (in degrees Celcius) goes below this value, send an alert (not implemented yet).
15
Max env temp
int 8
If temperature (in degrees Celcius) goes above this value, send an alert (not implemented yet).
16
Scan duration
uint 16
Scan duration in ms. Setting this too high may cause the device to reset during scanning.
17
Scan send delay
uint 16
Time in ms to wait before sending scan results over the mesh. Setting this too low may cause the device to reset during scanning.
18
Scan break duration
uint 16
Waiting time in ms between sending results and next scan. Setting this too low may cause the device to reset during scanning.
19
Boot delay
uint 16
Time to wait with radio after boot, Setting this too low may cause the device to reset on boot.
20
Max chip temp
int 8
If the chip temperature (in degrees Celcius) goes above this value, the power gets switched off.
21
Scan filter
uint 8
Filter out certain types of devices from the scan results (1 for GuideStones, 2 for CrownStones, 3 for both).
22
Scan filter fraction
uint 16
If scan filter is set, do not filter them out each every X scan results.
23
Current limit
uint 8
Set current limit to not implemented
24
Mesh enabled
uint 8
Stores if mesh is enabled. read only
25
Encryption enabled
uint 8
Stores if encryption is enabled. read only
26
iBeacon enabled
uint 8
Stores if iBeacon is enabled. read only
27
Scanner enabled
uint 8
Stores if device scanning is enabled. read only
28
Continuous power measurement enabled
uint 8
Stores if continuous power measurement is enabled. read only
29
Tracker enabled
uint 8
Stores if device tracking is enabled. read only
30
ADC sample rate
...
TBD
31
Power sample burst interval
...
TBD
32
Power sample continuous interval
...
TBD
33
Power sample continuous number samples
...
TBD
34
Crownstone Identifier
uint 16
Crownstone identifier used in advertisement package
35
Owner encryption key
uint 8 [16]
16 byte key used to encrypt/decrypt owner access functions
36
Member encryption key
uint 8 [16]
16 byte key used to encrypt/decrypt member access functions
37
Guest encryption key
uint 8 [16]
16 byte key used to encrypt/decrypt guest access functions
38
Default ON
uint 8
Set's the default switch state to 255 if true, or to 0 if false. Value is 0 for false, or any other for true
39
Scan Interval
uint 16
Set the scan interval to ...
40
Scan Window
uint 16
Set the scan window to ...
41
Relay High Duration
uint 16
Set the time/duration that the relay is set to high
42
Low Tx Power
int 8
Set the tx power used when in low transmission power for bonding
43
Voltage Multiplier
float
Set the voltage multiplier (for power measurement)
44
Current Multiplier
float
Set the current multiplier (for power measurement)
45
Voltage Zero
float
Set the voltage zero level (for power measurement)
46
Current Zero
float
Set the current zero level (for power measurement)
47
Power Zero
float
Set the power zero level (for power measurement)
OpCodes:
OpCode
Name
Description
0
Read
Select the configuration setting for reading. will load it from storage, then write it to the Config Read Characteristic. Length and payload of the configuration packet will be ignored
1
Write
Write the configuration setting to storage.
Note: On the Config Read Characteristic, the OpCode is set to Read (0), and the length and payload will have actual data depending on the type.
State packet
Type
Name
Length
Description
uint 8
Type
1
Type, see table with configuration types below.
uint 8
OpCode
1
The op code determines if it's a write, read, or notify operation, see table with op codes below
Select the configuration setting for reading. will load it from storage, then write it to the Config Read Characteristic. Length and payload of the configuration packet will be ignored
1
Write
Write the state variable disabled
2
Notify
Enable/Disable notifications for state variable. Every time the state variable is updated, the new value is written to the State Read Characteristic. To use effectively, enable GATT Notifications on the State Read Characteristic. Length has to be 1, and payload is 0 = disable, other = enable
Note: On the State Read Characteristic, the OpCode is also set to distinguish between a one time read, and a continuous notification. In return, the length and payload will have actual data depending on the type.
Power curve packet, TBD
Type
Name
Length
Description
uint 16
numSamples
2
Number of current samples + voltage samples, including the first samples.
uint 16
firstCurrent
2
First current sample.
uint 16
lastCurrent
2
Last current sample.
uint 16
firstVoltage
2
First voltage sample.
uint 16
lastVoltage
2
Last voltage sample.
uint 32
firstTimeStamp
4
Timestamp of first current sample.
uint 32
lastTimeStamp
4
Timestamp of last sample.
int 8 []
currentDiffs
numSamples/2-1
Array of differences with previous current sample.
int 8 []
voltageDiffs
numSamples/2-1
Array of differences with previous voltage sample.
Each mesh data message is notified in multiple pieces, as a notification can only be 20 bytes. The op code of the Mesh notification tells whether it is a single, or the first, last or a middle piece of a multipart message.
Type
Name
Length
Description
uint 16
Handle
2
Handle on which the messages was sent or received.
uint 8
Length
1
Length of the data of this part.
uint 8
Data
Length
Data of this part. If OpCode is Data, it is the length of the whole mesh message, otherwise it is the length of the current part.