Reworked BLE according to v0.11 of the KTag Beacon Specification (#2)
This was done to support the new KTag Konfigurator app, which Jack created for his Senior Design project. Co-authored-by: Joe Kearney <joe@clubk.club> Reviewed-on: #2
This commit is contained in:
parent
4fe072f2d3
commit
bfcdf4c354
26 changed files with 917 additions and 128 deletions
|
@ -30,6 +30,15 @@ static void Wrapping_Up_Entry(StateMachineContext_T * context);
|
|||
static void Wrapping_Up_Do(StateMachineContext_T * context);
|
||||
static void Wrapping_Up_Exit(StateMachineContext_T * context);
|
||||
|
||||
static TimerHandle_t BLEInfoRequestResponseTimer = NULL;
|
||||
static StaticTimer_t xBLEInfoRequestResponseTimerBuffer;
|
||||
static TickType_t xBLEInfoRequestResponseTimerPeriod = 3000 / portTICK_PERIOD_MS;
|
||||
|
||||
static void BLEInfoRequestResponseTimerCallback(TimerHandle_t xTimer)
|
||||
{
|
||||
BLE_UpdateStatusPacket(STATE_WRAPPING_UP);
|
||||
}
|
||||
|
||||
//! Activities for the **Wrapping Up** state.
|
||||
const StateActivity_T STATE_WRAPPING_UP_Activities =
|
||||
{
|
||||
|
@ -47,11 +56,27 @@ static void Wrapping_Up_Entry(StateMachineContext_T * context)
|
|||
LOG("Entering the Wrapping Up state.");
|
||||
NeoPixelsAction_T neopixels_action = {.ID = NEOPIXELS_IDLE, .Prominence = NEOPIXELS_FOREGROUND, .Data = (void *)0x00};
|
||||
xQueueSend(xQueueNeoPixels, &neopixels_action, 0);
|
||||
BLE_UpdateStatusPacket();
|
||||
BLE_UpdateStatusPacket(STATE_WRAPPING_UP);
|
||||
if (BLE_ScanAndAdvertise() != SYSTEMK_RESULT_SUCCESS)
|
||||
{
|
||||
KLOG_ERROR(KLOG_TAG, "Couldn't start BLE!");
|
||||
}
|
||||
|
||||
if (BLEInfoRequestResponseTimer == NULL)
|
||||
{
|
||||
BLEInfoRequestResponseTimer = xTimerCreateStatic(
|
||||
"BLEInfoRequestResponse",
|
||||
xBLEInfoRequestResponseTimerPeriod,
|
||||
pdFALSE,
|
||||
(void *)0,
|
||||
BLEInfoRequestResponseTimerCallback,
|
||||
&xBLEInfoRequestResponseTimerBuffer);
|
||||
}
|
||||
|
||||
if (BLEInfoRequestResponseTimer == NULL)
|
||||
{
|
||||
KLOG_ERROR(KLOG_TAG, "Couldn't create the BLEInfoRequestResponseTimer!");
|
||||
}
|
||||
}
|
||||
|
||||
//! Executes the Wrapping Up state.
|
||||
|
@ -84,8 +109,14 @@ static void Wrapping_Up_Do(StateMachineContext_T * context)
|
|||
break;
|
||||
|
||||
case KEVENT_BLE_PACKET_RECEIVED:
|
||||
// TODO
|
||||
BLE_FreePacketBuffer(Event.Data);
|
||||
if (((BLE_Packet_T *)Event.Data)->Generic.type == BLE_PACKET_TYPE_EVENT)
|
||||
{
|
||||
HandleBLEEventPacket((BLE_EventPacket_T *)Event.Data, context);
|
||||
}
|
||||
else
|
||||
{
|
||||
BLE_FreePacketBuffer(Event.Data);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue