use make based BLE device name

This commit is contained in:
Morgan 'ARR\!' Allen 2021-09-08 20:41:24 -07:00
parent 20871b9059
commit 584d6dc04a
3 changed files with 9 additions and 5 deletions

View file

@ -9,6 +9,6 @@ typedef struct {
} event_callback_handle_t;
int8_t ble_send_notification(void *buf, uint8_t size);
void ble_init();
void ble_init(char *name);
#endif

View file

@ -399,7 +399,7 @@ int8_t ble_send_notification(void *buf, uint8_t size) {
return ble_gattc_notify_custom(conn_handle, svc_handle_button, om);
}
void ble_init() {
void ble_init(char *name) {
esp_err_t err;
memset(&callback_handlers, 0, sizeof(event_callback_handle_t) * CONFIG_CACO_MAX_SERVICES);
@ -418,9 +418,10 @@ void ble_init() {
err = ble_gatts_add_svcs(service_defs);
ESP_ERROR_CHECK(err);
ESP_LOGI(TAG, "Setting device name: %s", CONFIG_BARBACK_ID);
ESP_LOGI(TAG, "Setting device name: %s", name);
err = ble_svc_gap_device_name_set(CONFIG_BARBACK_ID);
device_name = name;
err = ble_svc_gap_device_name_set(name);
ESP_ERROR_CHECK(err);
vTaskDelay(500 / portTICK_PERIOD_MS);

View file

@ -39,9 +39,12 @@ void app_main(void) {
ESP_LOGI(TAG, "MAC: [%02X:%02X:%02X:%02X:%02X:%02X]", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
char *name = malloc(strlen(TAG) + 4);
sprintf(name, "%s-%02X", TAG, mac[5]);
user_button_init();
pumps_init();
ble_init();
ble_init(name);
xTaskCreate(console_task, "console", 4048, NULL, tskIDLE_PRIORITY + 3, NULL);