Event listener.
Definition: cs_EventListener.h:17
Class that enables the feature to run microapps on the firmware.
Definition: cs_Microapp.h:21
cs_ret_code_t checkHeader(microapp_ctrl_header_t *packet)
Checks if control command header is ok.
void resetTestState(uint8_t index)
Resets app state tests in ram only.
void resetState(uint8_t index)
Resets app state in ram only.
bool _loaded
Local flag to indicate that ram section has been loaded.
Definition: cs_Microapp.h:66
bool _started[g_MICROAPP_COUNT]
Keep up whether the microapp has been started yet.
Definition: cs_Microapp.h:61
void init(OperationMode operationMode)
Initialize storage, and load microapps in normal mode.
static Microapp & getInstance()
Definition: cs_Microapp.h:23
cs_ret_code_t handleGetInfo(cs_result_t &result)
Handle control commands.
cs_ret_code_t resumeFactoryReset()
Remove next microapp and sends an event when done: EVT_MICROAPP_FACTORY_RESET_DONE.
cs_ret_code_t storeState(uint8_t index)
Store app state to flash.
void onExcessiveCallDuration(uint8_t appIndex)
To be called when a microapp took too long to yield.
void onStorageEvent(cs_async_result_t &event)
Handle microapp storage event.
void tick()
To be called every tick.
cs_ret_code_t handleDisable(microapp_ctrl_header_t *packet)
uint8_t _currentMicroappIndex
Keep up which microapp is currently being operated on.
Definition: cs_Microapp.h:73
cs_ret_code_t startApp(uint8_t index)
Start app, if it passed all tests according to cached state.
bool canRunApp(uint8_t index)
Checks app state and returns true if this app is allowed to run.
void updateStateFromOperatingData(uint8_t index)
Update state from operating data in IPC.
cs_ret_code_t handleRemove(microapp_ctrl_header_t *packet)
cs_ret_code_t handleEnable(microapp_ctrl_header_t *packet)
cs_ret_code_t enableApp(uint8_t index)
Enables app: checks sdk version.
cs_ret_code_t handleUpload(microapp_upload_internal_t *packet)
cs_ret_code_t handleMessage(microapp_message_internal_t *packet, cs_result_t &result)
cs_ret_code_t factoryReset()
Removes all microapps and sends an event when done: EVT_MICROAPP_FACTORY_RESET_DONE.
cs_ret_code_t validateApp(uint8_t index)
Validates app: compare checksum.
Microapp()
Singleton, constructor, also copy constructor, is private.
void loadState(uint8_t index)
void operator=(Microapp const &)=delete
bool _factoryResetMode
Whether we are in factory reset mode.
Definition: cs_Microapp.h:78
microapp_state_t _states[g_MICROAPP_COUNT]
The state of each microapp.
Definition: cs_Microapp.h:55
cs_ret_code_t handleValidate(microapp_ctrl_header_t *packet)
void handleEvent(event_t &event)
Handle incoming events.
Microapp(Microapp const &)=delete
Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: Oct 9,...
Definition: cs_Event.h:26
constexpr uint8_t MICROAPP_INDEX_NONE
Invalid microapp index.
Definition: cs_MicroappPackets.h:43
uint16_t cs_ret_code_t
Definition: cs_Typedefs.h:21
OperationMode
Definition: cs_Types.h:440
Definition: cs_PacketsInternal.h:71
Definition: cs_PacketsInternal.h:46
Definition: cs_PacketsInternal.h:384
State of tests of a microapp, also stored in flash.
Definition: cs_MicroappPackets.h:108
Definition: cs_PacketsInternal.h:379