Skip to content
Snippets Groups Projects
Commit 43bca5af authored by schneider's avatar schneider
Browse files

feat(mp-ble): Allow to close current connection

parent 92227700
Branches
Tags
No related merge requests found
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "api/interrupt-sender.h" #include "api/interrupt-sender.h"
#include "wsf_buf.h" #include "wsf_buf.h"
#include "app_api.h"
#include "svc_core.h" #include "svc_core.h"
#include "FreeRTOS.h" #include "FreeRTOS.h"
...@@ -92,6 +93,16 @@ void ble_epic_dm_api_event(dmEvt_t *dm_event) ...@@ -92,6 +93,16 @@ void ble_epic_dm_api_event(dmEvt_t *dm_event)
} }
} }
void epic_ble_close_connection(uint8_t connId)
{
AppConnClose(connId);
}
int epic_ble_is_connection_open(void)
{
return AppConnIsOpen();
}
int epic_ble_set_device_name(const uint8_t *buf, uint16_t len) int epic_ble_set_device_name(const uint8_t *buf, uint16_t len)
{ {
return epic_ble_atts_set_attr(GAP_DN_HDL, buf, len); return epic_ble_atts_set_attr(GAP_DN_HDL, buf, len);
......
...@@ -177,6 +177,8 @@ typedef _Bool bool; ...@@ -177,6 +177,8 @@ typedef _Bool bool;
#define API_BLE_GET_ATT_WRITE 0x1BD #define API_BLE_GET_ATT_WRITE 0x1BD
#define API_BLE_FREE_ATT_WRITE 0x1BE #define API_BLE_FREE_ATT_WRITE 0x1BE
#define API_BLE_ATTS_DYN_ADD_CHARACTERISTIC 0x1BF #define API_BLE_ATTS_DYN_ADD_CHARACTERISTIC 0x1BF
#define API_BLE_CLOSE_CONNECTION 0x170
#define API_BLE_IS_CONNECTION_OPEN 0x171
#define API_BLE_SET_DEVICE_NAME 0x172 #define API_BLE_SET_DEVICE_NAME 0x172
#define API_BLE_GET_DEVICE_NAME 0x173 #define API_BLE_GET_DEVICE_NAME 0x173
#define API_BLE_GET_ADDRESS 0x174 #define API_BLE_GET_ADDRESS 0x174
...@@ -2607,7 +2609,8 @@ API(API_BLE_ATTS_HANDLE_VALUE_IND, int epic_ble_atts_handle_value_ind(uint8_t co ...@@ -2607,7 +2609,8 @@ API(API_BLE_ATTS_HANDLE_VALUE_IND, int epic_ble_atts_handle_value_ind(uint8_t co
API(API_BLE_ATTS_SET_BUFFER, int epic_ble_atts_set_buffer(uint16_t value_handle, size_t len, bool append)); API(API_BLE_ATTS_SET_BUFFER, int epic_ble_atts_set_buffer(uint16_t value_handle, size_t len, bool append));
API(API_BLE_FREE_EVENT, int epic_ble_free_event(struct epic_ble_event *e)); API(API_BLE_FREE_EVENT, int epic_ble_free_event(struct epic_ble_event *e));
API(API_BLE_CLOSE_CONNECTION, void epic_ble_close_connection(uint8_t connId));
API(API_BLE_IS_CONNECTION_OPEN, int epic_ble_is_connection_open(void));
API(API_BLE_SET_DEVICE_NAME, int epic_ble_set_device_name(const uint8_t *buf, uint16_t len)); API(API_BLE_SET_DEVICE_NAME, int epic_ble_set_device_name(const uint8_t *buf, uint16_t len));
API(API_BLE_GET_DEVICE_NAME, int epic_ble_get_device_name(uint8_t **buf, uint16_t *len)); API(API_BLE_GET_DEVICE_NAME, int epic_ble_get_device_name(uint8_t **buf, uint16_t *len));
API(API_BLE_GET_ADDRESS, void epic_ble_get_address(uint8_t *addr)); API(API_BLE_GET_ADDRESS, void epic_ble_get_address(uint8_t *addr));
......
...@@ -352,10 +352,12 @@ int mp_bluetooth_gap_advertise_start( ...@@ -352,10 +352,12 @@ int mp_bluetooth_gap_advertise_start(
const uint8_t *sr_data, const uint8_t *sr_data,
size_t sr_data_len size_t sr_data_len
) { ) {
// Temporarily going to scanner drops the connection // Dropping any current connection starts advertising on the card10
// TODO: modify the advertising data // TODO: modify the advertising data
epic_ble_set_mode(false, true); int connection = epic_ble_is_connection_open();
epic_ble_set_mode(false, false); if (connection > 0) {
epic_ble_close_connection(connection);
}
return 0; return 0;
} }
...@@ -631,7 +633,7 @@ int mp_bluetooth_gatts_set_buffer(uint16_t value_handle, size_t len, bool append ...@@ -631,7 +633,7 @@ int mp_bluetooth_gatts_set_buffer(uint16_t value_handle, size_t len, bool append
// Disconnect from a central or peripheral. // Disconnect from a central or peripheral.
int mp_bluetooth_gap_disconnect(uint16_t conn_handle) int mp_bluetooth_gap_disconnect(uint16_t conn_handle)
{ {
raise(); epic_ble_close_connection(conn_handle);
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