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

feat(mp-ble): Allow to read mac address

parent e25f56c2
Branches
Tags
1 merge request!446Initial MicroPython BLE support (GATTS)
......@@ -30,6 +30,9 @@ struct log_packet_header {
uint32_t timestamp_us_h;
uint32_t timestamp_us_l;
};
static uint8_t bdAddr[6] = { 0xCA, 0x4D, 0x10, 0x00, 0x00, 0x00 };
static const uint8_t log_header[] = {
'b', 't', 's', 'n', 'o', 'o', 'p', 0, 0, 0, 0, 1, 0, 0, 0x03, 0xea
};
......@@ -178,7 +181,6 @@ static void WsfInit(void)
/* TODO: We need a source of MACs */
static void setAddress(void)
{
uint8_t bdAddr[6] = { 0xCA, 0x4D, 0x10, 0x00, 0x00, 0x00 };
char buf[32];
int result = epic_config_get_string("ble_mac", buf, sizeof(buf));
......@@ -222,6 +224,11 @@ static void setAddress(void)
HciVsSetBdAddr(bdAddr);
}
/*************************************************************************************************/
void epic_ble_get_address(uint8_t *addr)
{
memcpy(addr, bdAddr, sizeof(bdAddr));
}
/*************************************************************************************************/
static void vTimerCallback(xTimerHandle pxTimer)
{
//printf("wake\n");
......
......@@ -177,6 +177,7 @@ typedef _Bool bool;
#define API_BLE_GET_ATT_WRITE 0x1BD
#define API_BLE_FREE_ATT_WRITE 0x1BE
#define API_BLE_ATTS_DYN_ADD_CHARACTERISTIC 0x1BF
#define API_BLE_GET_ADDRESS 0x174
/* clang-format on */
......@@ -2605,6 +2606,7 @@ 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_GET_ADDRESS, void epic_ble_get_address(uint8_t *addr));
#endif /* _EPICARDIUM_H */
......@@ -327,7 +327,7 @@ bool mp_bluetooth_is_active(void)
// Gets the MAC addr of this device in big-endian format.
void mp_bluetooth_get_device_addr(uint8_t *addr)
{
raise();
epic_ble_get_address(addr);
}
size_t mp_bluetooth_gap_get_device_name(const uint8_t **buf)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment