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

feat(mp-ble): Allow to set/get device name

parent 0a8142ab
No related branches found
No related tags found
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 "svc_core.h"
#include "FreeRTOS.h" #include "FreeRTOS.h"
#include "queue.h" #include "queue.h"
...@@ -90,3 +91,14 @@ void ble_epic_dm_api_event(dmEvt_t *dm_event) ...@@ -90,3 +91,14 @@ void ble_epic_dm_api_event(dmEvt_t *dm_event)
LOG_WARN("ble", "could not allocate dm event"); LOG_WARN("ble", "could not allocate dm event");
} }
} }
int epic_ble_set_device_name(const uint8_t *buf, uint16_t len)
{
return epic_ble_atts_set_attr(GAP_DN_HDL, buf, len);
}
int epic_ble_get_device_name(uint8_t **buf, uint16_t *len)
{
uint8_t ret = AttsGetAttr(GAP_DN_HDL, len, buf);
return ret;
}
...@@ -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_SET_DEVICE_NAME 0x172
#define API_BLE_GET_DEVICE_NAME 0x173
#define API_BLE_GET_ADDRESS 0x174 #define API_BLE_GET_ADDRESS 0x174
/* clang-format on */ /* clang-format on */
...@@ -2606,6 +2608,8 @@ API(API_BLE_ATTS_SET_BUFFER, int epic_ble_atts_set_buffer(uint16_t value_handle, ...@@ -2606,6 +2608,8 @@ API(API_BLE_ATTS_SET_BUFFER, int epic_ble_atts_set_buffer(uint16_t value_handle,
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_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_ADDRESS, void epic_ble_get_address(uint8_t *addr)); API(API_BLE_GET_ADDRESS, void epic_ble_get_address(uint8_t *addr));
#endif /* _EPICARDIUM_H */ #endif /* _EPICARDIUM_H */
......
...@@ -332,14 +332,14 @@ void mp_bluetooth_get_device_addr(uint8_t *addr) ...@@ -332,14 +332,14 @@ void mp_bluetooth_get_device_addr(uint8_t *addr)
size_t mp_bluetooth_gap_get_device_name(const uint8_t **buf) size_t mp_bluetooth_gap_get_device_name(const uint8_t **buf)
{ {
raise(); uint16_t len;
return 0; epic_ble_get_device_name((uint8_t **)buf, &len);
return len;
} }
int mp_bluetooth_gap_set_device_name(const uint8_t *buf, size_t len) int mp_bluetooth_gap_set_device_name(const uint8_t *buf, size_t len)
{ {
raise(); return epic_ble_set_device_name(buf, len);
return 0;
} }
// Start advertisement. Will re-start advertisement when already enabled. // Start advertisement. Will re-start advertisement when already enabled.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment