Skip to content

Commit c858982

Browse files
committed
ble: code clean up
1 parent c2131dd commit c858982

File tree

2 files changed

+29
-31
lines changed

2 files changed

+29
-31
lines changed

main/src/user/ble_app.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,5 @@ void ble_app_init(void)
105105
ESP_ERROR_CHECK(esp_ble_gatts_app_register(PROFILE_IDX_VFX));
106106
ESP_ERROR_CHECK(esp_ble_gatts_app_register(PROFILE_IDX_VER));
107107

108-
ESP_ERROR_CHECK(esp_ble_gatt_set_local_mtu(500));
109-
110108
ESP_LOGI(BLE_APP_TAG, "started.");
111109
}

main/src/user/ble_gatts.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -187,43 +187,43 @@ static void profile_vfx_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t
187187
#endif
188188
if (!param->write.is_prep) {
189189
switch (param->write.value[0]) {
190-
case 0xEF: {
191-
if (param->write.len == 1) { // Restore Default Configuration
190+
case 0xEF: {
191+
if (param->write.len == 1) { // Restore Default Configuration
192192
#ifdef CONFIG_ENABLE_VFX
193-
vfx->mode = DEFAULT_VFX_MODE;
194-
vfx->scale_factor = DEFAULT_VFX_SCALE_FACTOR;
195-
vfx->lightness = DEFAULT_VFX_LIGHTNESS;
196-
vfx->backlight = DEFAULT_VFX_BACKLIGHT;
197-
vfx_set_conf(vfx);
198-
app_setenv("VFX_INIT_CFG", vfx, sizeof(vfx_config_t));
193+
vfx->mode = DEFAULT_VFX_MODE;
194+
vfx->scale_factor = DEFAULT_VFX_SCALE_FACTOR;
195+
vfx->lightness = DEFAULT_VFX_LIGHTNESS;
196+
vfx->backlight = DEFAULT_VFX_BACKLIGHT;
197+
vfx_set_conf(vfx);
198+
app_setenv("VFX_INIT_CFG", vfx, sizeof(vfx_config_t));
199199
#ifndef CONFIG_AUDIO_INPUT_NONE
200-
ain_mode = DEFAULT_AIN_MODE;
201-
audio_input_set_mode(ain_mode);
202-
app_setenv("AIN_INIT_CFG", &ain_mode, sizeof(uint8_t));
200+
ain_mode = DEFAULT_AIN_MODE;
201+
audio_input_set_mode(ain_mode);
202+
app_setenv("AIN_INIT_CFG", &ain_mode, sizeof(uint8_t));
203203
#endif
204204
#endif
205-
} else if (param->write.len == 8) { // Update with New Configuration
205+
} else if (param->write.len == 8) { // Update with New Configuration
206206
#ifdef CONFIG_ENABLE_VFX
207-
vfx->mode = param->write.value[1];
208-
vfx->scale_factor = param->write.value[2] << 8 | param->write.value[3];
209-
vfx->lightness = (param->write.value[4] << 8 | param->write.value[5]) % 0x0200;
210-
vfx->backlight = param->write.value[6];
211-
vfx_set_conf(vfx);
212-
app_setenv("VFX_INIT_CFG", vfx, sizeof(vfx_config_t));
207+
vfx->mode = param->write.value[1];
208+
vfx->scale_factor = param->write.value[2] << 8 | param->write.value[3];
209+
vfx->lightness = (param->write.value[4] << 8 | param->write.value[5]) % 0x0200;
210+
vfx->backlight = param->write.value[6];
211+
vfx_set_conf(vfx);
212+
app_setenv("VFX_INIT_CFG", vfx, sizeof(vfx_config_t));
213213
#ifndef CONFIG_AUDIO_INPUT_NONE
214-
ain_mode = param->write.value[7];
215-
audio_input_set_mode(ain_mode);
216-
app_setenv("AIN_INIT_CFG", &ain_mode, sizeof(uint8_t));
214+
ain_mode = param->write.value[7];
215+
audio_input_set_mode(ain_mode);
216+
app_setenv("AIN_INIT_CFG", &ain_mode, sizeof(uint8_t));
217217
#endif
218218
#endif
219-
} else {
220-
ESP_LOGE(GATTS_VFX_TAG, "command 0x%02X error", param->write.value[0]);
221-
}
222-
break;
219+
} else {
220+
ESP_LOGE(GATTS_VFX_TAG, "command 0x%02X error", param->write.value[0]);
223221
}
224-
default:
225-
ESP_LOGW(GATTS_VFX_TAG, "unknown command: 0x%02X", param->write.value[0]);
226-
break;
222+
break;
223+
}
224+
default:
225+
ESP_LOGW(GATTS_VFX_TAG, "unknown command: 0x%02X", param->write.value[0]);
226+
break;
227227
}
228228
}
229229

@@ -433,7 +433,7 @@ void ble_gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if,
433433

434434
/* If the gatts_if equal to profile A, call profile A cb handler,
435435
* so here call each profile's callback */
436-
for (int idx = 0; idx < PROFILE_IDX_MAX; idx++) {
436+
for (int idx=0; idx<PROFILE_IDX_MAX; idx++) {
437437
if (gatts_if == ESP_GATT_IF_NONE || /* ESP_GATT_IF_NONE, not specify a certain gatt_if, need to call every profile cb function */
438438
gatts_if == gatts_profile_tbl[idx].gatts_if) {
439439
if (gatts_profile_tbl[idx].gatts_cb) {

0 commit comments

Comments
 (0)