26
26
#define GATTS_OTA_TAG "gatts_ota"
27
27
#define GATTS_VFX_TAG "gatts_vfx"
28
28
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
32
32
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
36
36
37
37
static uint16_t desc_val_ota = 0x0000 ;
38
38
static 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
85
85
esp_ble_gatts_send_response (gatts_if , param -> read .conn_id , param -> read .trans_id , ESP_GATT_OK , & rsp );
86
86
break ;
87
87
}
88
- case ESP_GATTS_WRITE_EVT : {
88
+ case ESP_GATTS_WRITE_EVT :
89
89
if (!param -> write .is_prep ) {
90
90
if (param -> write .handle == gatts_profile_tbl [PROFILE_IDX_OTA ].descr_handle ) {
91
91
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
98
98
esp_ble_gatts_send_response (gatts_if , param -> write .conn_id , param -> write .trans_id , ESP_GATT_OK , NULL );
99
99
}
100
100
break ;
101
- }
102
101
case ESP_GATTS_EXEC_WRITE_EVT :
103
102
break ;
104
103
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
250
249
esp_ble_gatts_send_response (gatts_if , param -> read .conn_id , param -> read .trans_id , ESP_GATT_OK , & rsp );
251
250
break ;
252
251
}
253
- case ESP_GATTS_WRITE_EVT : {
252
+ case ESP_GATTS_WRITE_EVT :
254
253
if (!param -> write .is_prep ) {
255
254
if (param -> write .handle == gatts_profile_tbl [PROFILE_IDX_VFX ].descr_handle ) {
256
255
desc_val_vfx = param -> write .value [1 ] << 8 | param -> write .value [0 ];
257
- } else {
258
256
#ifdef CONFIG_ENABLE_VFX
257
+ } else {
259
258
vfx_config_t * vfx = vfx_get_conf ();
260
259
#ifndef CONFIG_AUDIO_INPUT_NONE
261
260
ain_mode_t ain_mode = ain_get_mode ();
262
261
#endif
263
- #endif
264
262
switch (param -> write .value [0 ]) {
265
- case 0xEF : {
263
+ case 0xEF :
266
264
if (param -> write .len == 1 ) { // restore default configuration
267
- #ifdef CONFIG_ENABLE_VFX
268
265
vfx -> mode = DEFAULT_VFX_MODE ;
269
266
vfx -> scale_factor = DEFAULT_VFX_SCALE_FACTOR ;
270
267
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
276
273
ain_set_mode (ain_mode );
277
274
app_setenv ("AIN_INIT_CFG" , & ain_mode , sizeof (ain_mode_t ));
278
275
#endif
279
- #endif
280
276
} else if (param -> write .len == 8 ) { // apply new configuration
281
- #ifdef CONFIG_ENABLE_VFX
282
277
vfx -> mode = param -> write .value [1 ];
283
278
vfx -> scale_factor = param -> write .value [2 ] << 8 | param -> write .value [3 ];
284
279
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
290
285
ain_set_mode (ain_mode );
291
286
app_setenv ("AIN_INIT_CFG" , & ain_mode , sizeof (ain_mode_t ));
292
287
#endif
293
- #endif
294
288
} else {
295
289
ESP_LOGE (GATTS_VFX_TAG , "command 0x%02X error" , param -> write .value [0 ]);
296
290
}
297
291
break ;
298
- }
299
292
default :
300
293
ESP_LOGW (GATTS_VFX_TAG , "unknown command: 0x%02X" , param -> write .value [0 ]);
301
294
break ;
302
295
}
296
+ #endif
303
297
}
304
298
}
305
299
306
300
if (param -> write .need_rsp ) {
307
301
esp_ble_gatts_send_response (gatts_if , param -> write .conn_id , param -> write .trans_id , ESP_GATT_OK , NULL );
308
302
}
309
303
break ;
310
- }
311
304
case ESP_GATTS_EXEC_WRITE_EVT :
312
305
break ;
313
306
case ESP_GATTS_MTU_EVT :
0 commit comments