Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
1 merge request!461BLE: Re-use open connection in pycardium
Pipeline #5167 passed
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "FreeRTOS.h" #include "FreeRTOS.h"
#include "queue.h" #include "queue.h"
#include "timers.h"
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
...@@ -24,8 +25,11 @@ static StaticQueue_t ble_event_queue_data; ...@@ -24,8 +25,11 @@ static StaticQueue_t ble_event_queue_data;
static uint8_t adv_data_buf[HCI_ADV_DATA_LEN]; static uint8_t adv_data_buf[HCI_ADV_DATA_LEN];
static uint8_t sr_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; static bool connection_open;
int epic_ble_free_event(struct epic_ble_event *e) int epic_ble_free_event(struct epic_ble_event *e)
...@@ -147,14 +151,39 @@ int epic_ble_is_connection_open(void) ...@@ -147,14 +151,39 @@ int epic_ble_is_connection_open(void)
return AppConnIsOpen(); return AppConnIsOpen();
} }
void vDmTimerCallback()
{
send_dm_event(&connection_open_event);
}
int epic_ble_init(void) 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); 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; return 0;
} }
int epic_ble_deinit(void) int epic_ble_deinit(void)
{ {
xTimerStop(dm_timer, 0);
epic_interrupt_disable(EPIC_INT_BLE); epic_interrupt_disable(EPIC_INT_BLE);
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment