The class MicroappController has functionality to store a second app (and perhaps in the future even more apps) on another part of the flash memory.
More...
#include <cs_MicroappController.h>
The class MicroappController has functionality to store a second app (and perhaps in the future even more apps) on another part of the flash memory.
◆ MicroappController() [1/2]
Singleton, constructor, also copy constructor, is private.
◆ MicroappController() [2/2]
◆ allowSoftInterrupts()
bool MicroappController::allowSoftInterrupts |
( |
MicroappSdkType |
type, |
|
|
uint8_t |
id |
|
) |
| |
Checks whether the microapp has empty interrupt slots to deal with a new softInterrupt.
◆ callMicroapp()
void MicroappController::callMicroapp |
( |
| ) |
|
|
protected |
Resume the previously started coroutine.
◆ checkFlashBoundaries()
cs_ret_code_t MicroappController::checkFlashBoundaries |
( |
uint8_t |
appIndex, |
|
|
uintptr_t |
address |
|
) |
| |
|
protected |
Check if start address of the microapp is within the flash boundaries assigned to the microapps.
◆ clear()
void MicroappController::clear |
( |
uint8_t |
appIndex | ) |
|
Clear a microapp state:
- Remove all registered interrupts.
◆ generateSoftInterrupt()
void MicroappController::generateSoftInterrupt |
( |
MicroappSdkType |
type, |
|
|
uint8_t |
id |
|
) |
| |
Call the microapp in an interrupt context.
◆ getInputMicroappBuffer()
uint8_t * MicroappController::getInputMicroappBuffer |
( |
| ) |
|
Get incoming microapp buffer (from coargs).
◆ getInstance()
◆ getOperatingState()
Get operating state from IPC ram.
- Parameters
-
[in] | appIndex | Currently, only appIndex 0 is supported. |
◆ getOutputMicroappBuffer()
uint8_t * MicroappController::getOutputMicroappBuffer |
( |
| ) |
|
Get outgoing microapp buffer (from coargs).
◆ getRegisteredInterrupt()
Get the registered soft interrupt of given type.
- Returns
- Null pointer when the given type is not registered.
-
The registered interrupt of the given type.
◆ getScanFilter()
microapp_sdk_ble_scan_filter_t & MicroappController::getScanFilter |
( |
| ) |
|
Get the current scan filter.
◆ handleAck()
bool MicroappController::handleAck |
( |
| ) |
|
|
protected |
Retrieve ack from the outgoing buffer that the microapp may have overwritten.
Particularly check if the microapp exit was on finishing an interrupt. In that case, ignore the request made by the microapp
- Returns
- true if the request in the incoming buffer should be handled
-
false if the request in the incoming buffer should be ignored
◆ handleRequest()
bool MicroappController::handleRequest |
( |
| ) |
|
|
protected |
Retrieve request from the microapp and let MicroappRequestHandler handle it.
Return whether the microapp should be called again immediately or not. This depends on both the type of request (i.e. for YIELDs do not call again) and on whether the max number of consecutive calls has been reached
- Returns
- true if the microapp should be called again
-
false if the microapp should not be called again
◆ incrementEmptySoftInterruptSlots()
void MicroappController::incrementEmptySoftInterruptSlots |
( |
| ) |
|
Increment the number of empty interrupt slots.
◆ initMemory()
uint16_t MicroappController::initMemory |
( |
uint8_t |
appIndex | ) |
|
◆ isCpuBusy()
bool MicroappController::isCpuBusy |
( |
| ) |
|
Checks whether the CPU is busy.
This is done by checking if:
- The scheduler is almost full.
- ADC buffers have been skipped.
◆ isEventInterruptRegistered()
bool MicroappController::isEventInterruptRegistered |
( |
CS_TYPE |
type | ) |
|
Returns true when given bluenet event type is registered as interrupt.
◆ operator=()
◆ registerBluenetEventInterrupt()
Register interrupts for bluenet events.
◆ registerSoftInterrupt()
cs_ret_code_t MicroappController::registerSoftInterrupt |
( |
MicroappSdkType |
type, |
|
|
uint8_t |
id |
|
) |
| |
Register interrupts that allow generation of interrupts to the microapp.
◆ setEmptySoftInterruptSlots()
void MicroappController::setEmptySoftInterruptSlots |
( |
uint8_t |
emptySlots | ) |
|
Set the number of empty interrupt slots.
Should be called on microapp yield requests, which contain an emptyInterruptSlots field.
- Parameters
-
◆ setIpcRam()
void MicroappController::setIpcRam |
( |
| ) |
|
◆ setOperatingState()
Set operating state in IPC ram.
This can be used after (an accidental) boot to decide if a microapp has been the reason for that reboot. In that case the microapp can be disabled so not to cause more havoc.
- Parameters
-
[in] | appIndex | Currently, only appIndex 0 is supported. |
[in] | state | The state (running or not running) of this microapp. |
◆ setScanFilter()
cs_ret_code_t MicroappController::setScanFilter |
( |
microapp_sdk_ble_scan_filter_t & |
filter | ) |
|
Set a scan filter.
Validity of the filter is not checked.
◆ startMicroapp()
void MicroappController::startMicroapp |
( |
uint8_t |
appIndex | ) |
|
Actually run the app.
- Parameters
-
[in] | appIndex | (currently ignored) |
◆ stopAfterMicroappRequest()
bool MicroappController::stopAfterMicroappRequest |
( |
microapp_sdk_header_t * |
header | ) |
|
|
protected |
After particular microapp requests we want to stop the microapp (end of loop etc.) and continue with bluenet.
This function returns true for such requests.
- Parameters
-
[in] | header | Header of the microapp request |
- Returns
- true if the microapp is yielding
-
false if the microapp is not yielding
◆ tickMicroapp()
void MicroappController::tickMicroapp |
( |
uint8_t |
appIndex | ) |
|
◆ _consecutiveMicroappCallCounter
uint8_t MicroappController::_consecutiveMicroappCallCounter = 0 |
|
private |
Counter for consecutive microapp calls.
Limited to MICROAPP_MAX_NUMBER_CONSECUTIVE_CALLS
◆ _emptySoftInterruptSlots
uint8_t MicroappController::_emptySoftInterruptSlots = 1 |
|
private |
Keeps track of how many empty interrupt slots are available on the microapp side.
Start with 1, but will be set to the correct value in the request handler.
◆ _eventInterruptRegistrations
Keep up registered bluenet event interrupt registrations.
◆ _scanFilter
microapp_sdk_ble_scan_filter_t MicroappController::_scanFilter = {.type = CS_MICROAPP_SDK_BLE_SCAN_FILTER_NONE, .rssi = 0} |
|
private |
Keep up the current scan filter.
◆ _softInterruptRegistrations
Buffer for keeping track of registered interrupts.
◆ _tickCounter
uint8_t MicroappController::_tickCounter = 0 |
|
private |
To throttle the ticks themselves.
◆ MICROAPP_MAX_BLUENET_EVENT_INTERRUPT_REGISTRATIONS
const uint8_t MicroappController::MICROAPP_MAX_BLUENET_EVENT_INTERRUPT_REGISTRATIONS = 10 |
|
staticprivate |
The maximum number of registered bluenet event interrupts.
◆ MICROAPP_MAX_CALL_DURATION_MS
const uint32_t MicroappController::MICROAPP_MAX_CALL_DURATION_MS = 20 |
|
staticprivate |
The maximum time in ms a call to a microapp can take.
Take into account that real interrupts are included in this time.
◆ MICROAPP_MAX_NUMBER_CONSECUTIVE_CALLS
const uint8_t MicroappController::MICROAPP_MAX_NUMBER_CONSECUTIVE_CALLS = 3 |
|
staticprivate |
The maximum number of calls to the main thread of a microapp, per microapp tick.
Any call passed this, will be executed later. We want at least 3, so you can set the RGB values of a led together.
◆ MICROAPP_MAX_SOFT_INTERRUPT_REGISTRATIONS
const uint8_t MicroappController::MICROAPP_MAX_SOFT_INTERRUPT_REGISTRATIONS = 10 |
|
staticprivate |
The maximum number of registered interrupts.
◆ MICROAPP_MAX_SOFT_INTERRUPTS_WITHIN_A_TICK
const int8_t MicroappController::MICROAPP_MAX_SOFT_INTERRUPTS_WITHIN_A_TICK = 3 |
|
staticprivate |
The max number of interrupt calls per type per microapp tick.
Any interrupt passed this, will be dropped. We can use a low value, because service discovery is not limited.
Suggestion: allow for bursts by setting a higher threshold, but decrease the counter only by N every tick.
◆ microappData
Some runtime data we have to store for a microapp.
The documentation for this class was generated from the following file: