Class to connect to another crownstone, and write control commands.
Definition: cs_CrownstoneCentral.h:26
ConnectSteps
Definition: cs_CrownstoneCentral.h:106
OperationMode _opMode
Operation mode of the crownstone we are connected to.
Definition: cs_CrownstoneCentral.h:136
void sendOperationResult(event_t &event)
void onDiscovery(ble_central_discovery_t &result)
void readSessionData()
Read session key or session data, depending on operation mode.
cs_ret_code_t init()
Initializes the class:
void onWrite(ble_central_write_result_t &result)
void onDiscoveryDone(cs_ret_code_t retCode)
void startTimeoutTimer(uint16_t timeoutMs)
uint16_t _timeoutCountDown
A countdown until timeout.
Definition: cs_CrownstoneCentral.h:172
uint16_t _sessionKeyHandle
Handles that we need for reading and writing.
Definition: cs_CrownstoneCentral.h:127
stone_id_t _stoneId
Keep up to which stone ID we're connected.
Definition: cs_CrownstoneCentral.h:162
UUID _serviceUuids[SERVICE_INDEX_COUNT]
Service UUIDs we need for discovery.
Definition: cs_CrownstoneCentral.h:122
void setStep(uint8_t step)
WriteControlSteps
Definition: cs_CrownstoneCentral.h:117
ServiceIndex
Definition: cs_CrownstoneCentral.h:96
@ SERVICE_INDEX_DFU
Definition: cs_CrownstoneCentral.h:100
@ SERVICE_INDEX_SETUP
Definition: cs_CrownstoneCentral.h:98
@ SERVICE_INDEX_CROWNSTONE
Definition: cs_CrownstoneCentral.h:97
@ SERVICE_INDEX_COUNT
Definition: cs_CrownstoneCentral.h:101
@ SERVICE_INDEX_DEVICE_INFO
Definition: cs_CrownstoneCentral.h:99
uint8_t _currentStep
Asynchronous step of an operation we are currently executing.
Definition: cs_CrownstoneCentral.h:146
uint16_t _resultCccdHandle
Definition: cs_CrownstoneCentral.h:131
cs_ret_code_t connect(const device_address_t &address, uint16_t timeoutMs=3000)
Connect, discover, and read session data.
cs_data_t requestWriteBuffer()
Request the write buffer.
bool finalizeStep(ConnectSteps step, cs_ret_code_t retCode)
void onReadDuringConnect(ble_central_read_result_t &result)
void resetNotifactionMergerState()
Reset notification merger variables.
void onMacAddress(mesh_topo_mac_result_t &result)
void setStep(ConnectSteps step)
cs_ret_code_t mergeNotification(const cs_const_data_t ¬ificationData, cs_data_t &resultData)
Merge this notification data with that of others.
uint8_t _notificationNextIndex
The notification index that we expect to get next.
Definition: cs_CrownstoneCentral.h:151
cs_ret_code_t connect(stone_id_t stoneId, uint16_t timeoutMs=3000)
Connect, discover, and read session data.
uint16_t _notificationMergedDataSize
The current size of the merged notification data.
Definition: cs_CrownstoneCentral.h:156
void onTimeout()
Event handlers.
void onRead(ble_central_read_result_t &result)
uint16_t _timeoutMs
Keep up which timeout we use.
Definition: cs_CrownstoneCentral.h:167
uint16_t _controlHandle
Definition: cs_CrownstoneCentral.h:129
void finalizeOperation(Operation operation, cs_ret_code_t retCode)
Finalize an operation.
Operation _currentOperation
The operation we're currently executing.
Definition: cs_CrownstoneCentral.h:141
cs_ret_code_t disconnect()
Terminate current connection.
bool finalizeStep(WriteControlSteps step, cs_ret_code_t retCode)
void handleEvent(event_t &event)
Internal usage.
void finalizeOperation(Operation operation, uint8_t *data, uint8_t dataSize)
void setStep(WriteControlSteps step)
Operation
Definition: cs_CrownstoneCentral.h:104
bool isBusy()
Check whether an operation is in progress.
uint16_t _resultHandle
Definition: cs_CrownstoneCentral.h:130
void onNotification(ble_central_notification_t &result)
void reset()
Reset connection variables.
void onConnect(cs_ret_code_t retCode)
bool finalizeStep(uint8_t step, cs_ret_code_t retCode)
Returns true when you can continue.
cs_ret_code_t write(cs_control_cmd_t commandType, uint8_t *data, uint16_t size)
Write a control command, and get the result.
uint16_t _sessionDataHandle
Definition: cs_CrownstoneCentral.h:128
Event listener.
Definition: cs_EventListener.h:17
Class that enables the use of 128 bit service UUIDs.
Definition: cs_UUID.h:35
Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: Oct 9,...
Definition: cs_Event.h:26
uint16_t cs_control_cmd_t
Definition: cs_Typedefs.h:22
uint8_t stone_id_t
Definition: cs_Typedefs.h:23
uint16_t cs_ret_code_t
Definition: cs_Typedefs.h:21
OperationMode
Definition: cs_Types.h:440
Describes a service or characteristic that has been discovered.
Definition: cs_BleCentralPackets.h:41
Definition: cs_BleCentralPackets.h:76
Definition: cs_BleCentralPackets.h:70
Definition: cs_BleCentralPackets.h:65
Variable length data encapsulation in terms of length and pointer to data.
Definition: cs_PacketsInternal.h:38
Packets (structs) that are used internally in the firmware, and can be changed freely.
Definition: cs_PacketsInternal.h:27
Definition: cs_PacketsInternal.h:97
Definition: cs_PacketsInternal.h:389