Commit 1aa04cf5 authored by schneider's avatar schneider
Browse files

feat(ble): Give pycardium a connection event if a connection is already open

parent 866d5133
Pipeline #5167 passed with stages
in 29 seconds
......@@ -10,6 +10,7 @@
#include "FreeRTOS.h"
#include "queue.h"
#include "timers.h"
#include <stdint.h>
#include <string.h>
......@@ -24,8 +25,11 @@ static StaticQueue_t ble_event_queue_data;
static uint8_t adv_data_buf[HCI_ADV_DATA_LEN];
static uint8_t sr_data_buf[HCI_ADV_DATA_LEN];
static dmEvt_t connection_open_event;
static TimerHandle_t dm_timer;
static StaticTimer_t dm_timer_data;
static dmEvt_t connection_open_event;
static bool connection_open;
int epic_ble_free_event(struct epic_ble_event *e)
......@@ -147,14 +151,39 @@ int epic_ble_is_connection_open(void)
return AppConnIsOpen();
}
void vDmTimerCallback()
{
send_dm_event(&connection_open_event);
}
int epic_ble_init(void)
{
if (dm_timer == NULL) {
dm_timer = xTimerCreateStatic(
"dmtimer",
1,
pdFALSE, /* one-shot */
0,
vDmTimerCallback,
&dm_timer_data);
}
epic_interrupt_enable(EPIC_INT_BLE);
if (connection_open) {
// Give pycardium a bit of time and then let it
// know that there already is an open connection
int millis = 100;
int ticks = millis * (configTICK_RATE_HZ / 1000);
xTimerChangePeriod(dm_timer, ticks, 0);
}
return 0;
}
int epic_ble_deinit(void)
{
xTimerStop(dm_timer, 0);
epic_interrupt_disable(EPIC_INT_BLE);
return 0;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment