Skip to content

Commit 5c08ca6

Browse files
committed
ota: switch to BLE interface & drop SPP support
1 parent 42979ff commit 5c08ca6

File tree

17 files changed

+206
-406
lines changed

17 files changed

+206
-406
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ Bluetooth Visual Speaker based on ESP32 chip.
88
* A2DP Audio Streaming
99
* I2S & PDM Input / I2S Output
1010
* VFX Output (GIF / Audio FFT / Rainbow / Star Sky / ...)
11-
* BLE Control Interface (for VFX Output)
11+
* BLE Control Interface (OTA Firmware Update / VFX Remote Control)
1212
* Audio Prompt (Connected / Disconnected / WakeUp / Sleep)
13-
* OTA Firmware Update (via SPP Profile)
1413
* Sleep & WakeUp Key
1514

1615
## Preparing

main/Kconfig.projbuild

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,11 @@ config BT_NAME
77
help
88
Bluetooth name exposed by the device.
99

10-
menuconfig ENABLE_OTA_OVER_SPP
11-
bool "Enable OTA over SPP"
12-
default n
13-
help
14-
Enable OTA feature, you can use the SPP profile to upload the new firmware.
15-
16-
config BT_SPP_SERVER_NAME
17-
string "SPP Server Name"
18-
default "OTA"
19-
depends on ENABLE_OTA_OVER_SPP
20-
help
21-
Bluetooth SPP server name.
22-
2310
config ENABLE_BLE_CONTROL_IF
2411
bool "Enable BLE Control Interface"
2512
default n
2613
help
27-
Select this to enable BLE Control Interface.
14+
Select this to enable BLE OTA and RC features.
2815
endmenu
2916

3017
menu "Audio Configuration"

main/inc/core/os.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,24 @@ typedef enum user_event_group_bits {
1515
OS_PWR_SLEEP_BIT = BIT0,
1616
OS_PWR_RESTART_BIT = BIT1,
1717

18-
BT_SPP_IDLE_BIT = BIT2,
19-
BT_OTA_LOCK_BIT = BIT3,
18+
BT_A2DP_IDLE_BIT = BIT2,
19+
BT_A2DP_DATA_BIT = BIT3,
2020

21-
BT_A2DP_IDLE_BIT = BIT4,
22-
BT_A2DP_DATA_BIT = BIT5,
21+
BLE_GATTS_IDLE_BIT = BIT4,
22+
BLE_GATTS_LOCK_BIT = BIT5,
2323

24-
BLE_GATTS_IDLE_BIT = BIT6,
24+
VFX_RELOAD_BIT = BIT6,
25+
VFX_FFT_NULL_BIT = BIT7,
2526

26-
VFX_RELOAD_BIT = BIT7,
27-
VFX_FFT_NULL_BIT = BIT8,
27+
KEY_SCAN_RUN_BIT = BIT8,
2828

29-
KEY_SCAN_RUN_BIT = BIT9,
29+
AUDIO_RENDER_CLR_BIT = BIT9,
3030

3131
AUDIO_INPUT_RUN_BIT = BIT10,
3232
AUDIO_INPUT_FFT_BIT = BIT11,
3333

34-
AUDIO_RENDER_CLR_BIT = BIT12,
35-
36-
AUDIO_PLAYER_RUN_BIT = BIT13,
37-
AUDIO_PLAYER_IDLE_BIT = BIT14,
34+
AUDIO_PLAYER_RUN_BIT = BIT12,
35+
AUDIO_PLAYER_IDLE_BIT = BIT13,
3836
} user_event_group_bits_t;
3937

4038
extern EventGroupHandle_t user_event_group;

main/inc/user/ble_gatts.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include "esp_gatts_api.h"
1212

1313
enum gatts_profile_idx {
14+
PROFILE_IDX_OTA,
1415
PROFILE_IDX_VFX,
15-
PROFILE_IDX_VER,
1616

1717
PROFILE_IDX_MAX,
1818
};
@@ -34,6 +34,8 @@ typedef struct gatts_profile_inst {
3434

3535
extern gatts_profile_inst_t gatts_profile_tbl[];
3636

37+
extern void gatts_ota_send_notification(const char *data, uint32_t len);
38+
3739
extern void ble_gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param);
3840

3941
#endif /* INC_USER_BLE_GATTS_H_ */

main/inc/user/bt_spp.h

Lines changed: 0 additions & 17 deletions
This file was deleted.

main/inc/user/ota.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#ifndef INC_USER_OTA_H_
99
#define INC_USER_OTA_H_
1010

11-
#include "esp_spp_api.h"
11+
#include <stdint.h>
1212

13-
extern void ota_exec(esp_spp_cb_param_t *param);
13+
extern void ota_exec(const char *data, uint32_t len);
1414
extern void ota_end(void);
1515

1616
#endif /* INC_USER_OTA_H_ */

main/src/core/os.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
EventGroupHandle_t user_event_group;
2222

23-
#if defined(CONFIG_ENABLE_WAKEUP_KEY) || defined(CONFIG_ENABLE_SLEEP_KEY) || defined(CONFIG_ENABLE_OTA_OVER_SPP)
23+
#if defined(CONFIG_ENABLE_WAKEUP_KEY) || defined(CONFIG_ENABLE_SLEEP_KEY) || defined(CONFIG_ENABLE_BLE_CONTROL_IF)
2424
static EventBits_t sleep_wait_bits = 0;
2525
static EventBits_t restart_wait_bits = 0;
2626

@@ -153,7 +153,7 @@ void os_init(void)
153153
#endif
154154
#endif // CONFIG_ENABLE_WAKEUP_KEY
155155

156-
#if defined(CONFIG_ENABLE_WAKEUP_KEY) || defined(CONFIG_ENABLE_SLEEP_KEY) || defined(CONFIG_ENABLE_OTA_OVER_SPP)
156+
#if defined(CONFIG_ENABLE_WAKEUP_KEY) || defined(CONFIG_ENABLE_SLEEP_KEY) || defined(CONFIG_ENABLE_BLE_CONTROL_IF)
157157
xTaskCreatePinnedToCore(os_power_task_handle, "osPowerT", 2048, NULL, 5, NULL, 0);
158158
#endif
159159
}

main/src/user/ble_app.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ void ble_app_init(void)
102102
ESP_ERROR_CHECK(esp_ble_gatts_register_callback(ble_gatts_event_handler));
103103
ESP_ERROR_CHECK(esp_ble_gap_register_callback(ble_gap_event_handler));
104104

105+
ESP_ERROR_CHECK(esp_ble_gatts_app_register(PROFILE_IDX_OTA));
105106
ESP_ERROR_CHECK(esp_ble_gatts_app_register(PROFILE_IDX_VFX));
106-
ESP_ERROR_CHECK(esp_ble_gatts_app_register(PROFILE_IDX_VER));
107+
108+
ESP_ERROR_CHECK(esp_ble_gatt_set_local_mtu(ESP_GATT_MAX_MTU_SIZE));
107109

108110
ESP_LOGI(BLE_APP_TAG, "started.");
109111
}

0 commit comments

Comments
 (0)