30 void init(uint8_t deviceType);
Event listener.
Definition: cs_EventListener.h:17
Class that keeps up states of other stones.
Definition: cs_ExternalStates.h:34
Definition: cs_ServiceData.h:20
service_data_encrypted_microapp_t _microappServiceData
Microapp data to be advertised in crownstone service data.
Definition: cs_ServiceData.h:157
uint16_t getPartialTimestampOrCounter(uint32_t timestamp, uint32_t counter)
When a timestamp is available, return partial timestamp, else returns a counter.
void setDeviceType(uint8_t deviceType)
Set the device type field of the service data.
uint8_t _switchState
Cache switch state.
Definition: cs_ServiceData.h:113
int32_t _powerUsageReal
Cache the power usage in mW.
Definition: cs_ServiceData.h:128
void updateAccumulatedEnergy(int32_t energy)
Set the energy used field of the service data.
TYPIFY(STATE_ERRORS) _stateErrors
Cache the state errors.
void fillWithSetupState(uint32_t timestamp)
Put the state of this Crownstone in setup mode in the service data.
int32_t _energyUsed
Cache the energy used, in units of 64 J.
Definition: cs_ServiceData.h:131
void sendMeshState(bool event)
Send the state over the mesh.
void fillWithAlternativeState(uint32_t timestamp)
Put the alternative state of this Crownstone in the service data.
bool _microappServiceDataSet
Whether the microapp wants to advertise service data.
Definition: cs_ServiceData.h:152
uint16_t getPartialBehaviourHash(uint32_t behaviourHash)
Get a part of the behaviour hash.
bool fillServiceData(uint32_t timestamp)
Selects a type of data and puts this in the service data.
int8_t _temperature
Cache the temperature.
Definition: cs_ServiceData.h:122
uint16_t getArraySize()
Get the size of the service data.
uint8_t * getArray()
Get the service data as array.
void updateTemperature(int8_t temperature)
Set the temperature field of the service data.
void updateCrownstoneId(stone_id_t crownstoneId)
Set the ID field of the service data.
void updateServiceData(bool initial)
Update the service data.
int16_t compressPowerUsageMilliWatt(int32_t powerUsageMW)
Compress power usage, according to service data protocol v3.
ExternalStates _externalStates
Definition: cs_ServiceData.h:147
int8_t _powerFactor
Cache the power factor.
Definition: cs_ServiceData.h:125
service_data_state_extra_flags_t _extraFlags
Cache extra flags.
Definition: cs_ServiceData.h:119
bool fillWithMicroapp(uint32_t timestamp)
Put microapp data in the service data.
void handleEvent(event_t &event)
Called when there are events to handle.
uint32_t _firstErrorTimestamp
Cache timestamp of first error.
Definition: cs_ServiceData.h:137
uint16_t timestampToPartialTimestamp(uint32_t timestamp)
Convert timestamp to a partial timestamp, according to service data protocol v3.
void fillWithError(uint32_t timestamp)
Put the error state of this Crownstone in the service data.
app_timer_id_t _updateTimerId
Definition: cs_ServiceData.h:100
uint32_t _updateCount
Counter that keeps up the number of times that the advertisement has been updated.
Definition: cs_ServiceData.h:145
void fillWithHubState(uint32_t timestamp)
Put the hub state in the service data.
app_timer_t _updateTimerData
Timer used to periodically update the advertisement.
Definition: cs_ServiceData.h:99
void encryptServiceData()
Encrypt the service data.
void init(uint8_t deviceType)
Init the service data, make sure you set important fields first.
void updateSwitchState(uint8_t switchState)
Set the switch state field of the service data.
void updatePowerUsage(int32_t powerUsage)
Set the power usage field of the service data.
OperationMode _operationMode
Cache the operation mode.
Definition: cs_ServiceData.h:142
uint32_t _sendStateCountdown
Definition: cs_ServiceData.h:139
int32_t decompressPowerUsage(int16_t compressedPowerUsage)
Decompress power usage, according to service data protocol v3.
service_data_t _serviceData
Stores the last (current) advertised service data.
Definition: cs_ServiceData.h:107
void fillWithState(uint32_t timestamp)
Put the state of this Crownstone in the service data.
bool fillWithExternalState()
Put the state or error state of another Crownstone in the service data.
static void staticTimeout(ServiceData *ptr)
Definition: cs_ServiceData.h:160
service_data_state_flags_t _flags
Cache flags.
Definition: cs_ServiceData.h:116
stone_id_t _crownstoneId
Cache own ID.
Definition: cs_ServiceData.h:110
Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: Oct 9,...
Definition: cs_Event.h:26
#define MESH_SEND_STATE_INTERVAL_MS
Definition: cs_Config.h:207
#define TICK_INTERVAL_MS
Interval in milliseconds at which tick events are dispatched.
Definition: cs_Config.h:277
uint8_t stone_id_t
Definition: cs_Typedefs.h:23
OperationMode
Definition: cs_Types.h:440
Microapp data that will be encrypted.
Definition: cs_ServiceDataPackets.h:147
Definition: cs_ServiceDataPackets.h:40
Service data.
Definition: cs_ServiceDataPackets.h:259