2626#define GATTS_OTA_TAG "gatts_ota"
2727#define GATTS_VFX_TAG "gatts_vfx"
2828
29- #define GATTS_SRV_UUID_OTA 0xFF52
30- #define GATTS_CHAR_UUID_OTA 0x5201
31- #define GATTS_NUM_HANDLE_OTA 4
29+ #define GATTS_SRV_UUID_OTA 0xFF52
30+ #define GATTS_CHAR_UUID_OTA 0x5201
31+ #define GATTS_NUM_HANDLE_OTA 4
3232
33- #define GATTS_SRV_UUID_VFX 0xFF53
34- #define GATTS_CHAR_UUID_VFX 0x5301
35- #define GATTS_NUM_HANDLE_VFX 4
33+ #define GATTS_SRV_UUID_VFX 0xFF53
34+ #define GATTS_CHAR_UUID_VFX 0x5301
35+ #define GATTS_NUM_HANDLE_VFX 4
3636
3737static uint16_t desc_val_ota = 0x0000 ;
3838static uint16_t desc_val_vfx = 0x0000 ;
@@ -85,7 +85,7 @@ static void profile_ota_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t
8585 esp_ble_gatts_send_response (gatts_if , param -> read .conn_id , param -> read .trans_id , ESP_GATT_OK , & rsp );
8686 break ;
8787 }
88- case ESP_GATTS_WRITE_EVT : {
88+ case ESP_GATTS_WRITE_EVT :
8989 if (!param -> write .is_prep ) {
9090 if (param -> write .handle == gatts_profile_tbl [PROFILE_IDX_OTA ].descr_handle ) {
9191 desc_val_ota = param -> write .value [1 ] << 8 | param -> write .value [0 ];
@@ -98,7 +98,6 @@ static void profile_ota_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t
9898 esp_ble_gatts_send_response (gatts_if , param -> write .conn_id , param -> write .trans_id , ESP_GATT_OK , NULL );
9999 }
100100 break ;
101- }
102101 case ESP_GATTS_EXEC_WRITE_EVT :
103102 break ;
104103 case ESP_GATTS_MTU_EVT :
@@ -250,21 +249,19 @@ static void profile_vfx_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t
250249 esp_ble_gatts_send_response (gatts_if , param -> read .conn_id , param -> read .trans_id , ESP_GATT_OK , & rsp );
251250 break ;
252251 }
253- case ESP_GATTS_WRITE_EVT : {
252+ case ESP_GATTS_WRITE_EVT :
254253 if (!param -> write .is_prep ) {
255254 if (param -> write .handle == gatts_profile_tbl [PROFILE_IDX_VFX ].descr_handle ) {
256255 desc_val_vfx = param -> write .value [1 ] << 8 | param -> write .value [0 ];
257- } else {
258256#ifdef CONFIG_ENABLE_VFX
257+ } else {
259258 vfx_config_t * vfx = vfx_get_conf ();
260259 #ifndef CONFIG_AUDIO_INPUT_NONE
261260 ain_mode_t ain_mode = ain_get_mode ();
262261 #endif
263- #endif
264262 switch (param -> write .value [0 ]) {
265- case 0xEF : {
263+ case 0xEF :
266264 if (param -> write .len == 1 ) { // restore default configuration
267- #ifdef CONFIG_ENABLE_VFX
268265 vfx -> mode = DEFAULT_VFX_MODE ;
269266 vfx -> scale_factor = DEFAULT_VFX_SCALE_FACTOR ;
270267 vfx -> lightness = DEFAULT_VFX_LIGHTNESS ;
@@ -276,9 +273,7 @@ static void profile_vfx_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t
276273 ain_set_mode (ain_mode );
277274 app_setenv ("AIN_INIT_CFG" , & ain_mode , sizeof (ain_mode_t ));
278275 #endif
279- #endif
280276 } else if (param -> write .len == 8 ) { // apply new configuration
281- #ifdef CONFIG_ENABLE_VFX
282277 vfx -> mode = param -> write .value [1 ];
283278 vfx -> scale_factor = param -> write .value [2 ] << 8 | param -> write .value [3 ];
284279 vfx -> lightness = (param -> write .value [4 ] << 8 | param -> write .value [5 ]) % 0x0200 ;
@@ -290,24 +285,22 @@ static void profile_vfx_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t
290285 ain_set_mode (ain_mode );
291286 app_setenv ("AIN_INIT_CFG" , & ain_mode , sizeof (ain_mode_t ));
292287 #endif
293- #endif
294288 } else {
295289 ESP_LOGE (GATTS_VFX_TAG , "command 0x%02X error" , param -> write .value [0 ]);
296290 }
297291 break ;
298- }
299292 default :
300293 ESP_LOGW (GATTS_VFX_TAG , "unknown command: 0x%02X" , param -> write .value [0 ]);
301294 break ;
302295 }
296+ #endif
303297 }
304298 }
305299
306300 if (param -> write .need_rsp ) {
307301 esp_ble_gatts_send_response (gatts_if , param -> write .conn_id , param -> write .trans_id , ESP_GATT_OK , NULL );
308302 }
309303 break ;
310- }
311304 case ESP_GATTS_EXEC_WRITE_EVT :
312305 break ;
313306 case ESP_GATTS_MTU_EVT :
0 commit comments