Browse Source

Add some more debug logging

Sebastien 5 years ago
parent
commit
4cbe54f692
2 changed files with 34 additions and 8 deletions
  1. 28 7
      components/driver_bt/bt_app_sink.c
  2. 6 1
      components/squeezelite/output_i2s.c

+ 28 - 7
components/driver_bt/bt_app_sink.c

@@ -399,16 +399,37 @@ void bt_sink_init(bt_cmd_cb_t cmd_cb, bt_data_cb_t data_cb)
 
     /*
      * Set default parameters for Legacy Pairing
-     * Use fixed pin code
      */
     esp_bt_pin_type_t pin_type = ESP_BT_PIN_TYPE_FIXED;
-    esp_bt_pin_code_t pin_code;
-	pin_code[0] = '1';
-    pin_code[1] = '2';
-    pin_code[2] = '3';
-    pin_code[3] = '4';
-    esp_bt_gap_set_pin(pin_type, 4, pin_code);
 
+    char * pin_code = get_nvs_value_alloc_default(NVS_TYPE_STR, "bt_sink_pin", STR(CONFIG_BT_SINK_PIN), 0);
+    if(strlen(pin_code)>ESP_BT_PIN_CODE_LEN){
+
+    	ESP_LOGW(BT_AV_TAG, "BT Sink pin code [%s] too long. ", pin_code);
+    	pin_code[ESP_BT_PIN_CODE_LEN] = '\0';
+    	ESP_LOGW(BT_AV_TAG, "BT Sink pin truncated code [%s]. ", pin_code);
+    }
+
+    esp_bt_pin_code_t esp_pin_code;
+    bool bError=false;
+    memset(esp_pin_code, 0x00, sizeof(esp_pin_code) );
+    ESP_LOGW(BT_AV_TAG, "BT Sink pin code is: [%s] ", pin_code);
+
+    for(int i=0;i<strlen(pin_code);i++){
+    	if(pin_code[i] < '0' || pin_code[i] > '9' ) {
+    		ESP_LOGE(BT_AV_TAG,"Invalid number found in sequence");
+    		bError=true;
+    	}
+    	esp_pin_code[i]= pin_code[i];
+
+    }
+    if(bError){
+    	esp_pin_code[0]='1';
+    	esp_pin_code[1]='2';
+    	esp_pin_code[2]='3';
+    	esp_pin_code[3]='4';
+    }
+    esp_bt_gap_set_pin(pin_type, strlen(pin_code), esp_pin_code);
 }
 
 void bt_sink_deinit(void)

+ 6 - 1
components/squeezelite/output_i2s.c

@@ -196,6 +196,7 @@ void output_init_i2s(log_level level, char *device, unsigned output_buf_size, ch
 	loglevel = level;
 	
 #ifdef TAS575x
+	LOG_INFO("Initializing TAS575x ");
 	gpio_pad_select_gpio(JACK_GPIO);
 	gpio_set_direction(JACK_GPIO, GPIO_MODE_INPUT);
 			
@@ -358,7 +359,11 @@ void output_close_i2s(void) {
  */
 bool output_volume_i2s(unsigned left, unsigned right) {
 #ifdef TAS575x	
-	if (!spdif) gpio_set_level(VOLUME_GPIO, left || right);
+
+	if (!spdif) {
+		LOG_INFO("Setting TAS575x volume GPIO");
+		gpio_set_level(VOLUME_GPIO, left || right);
+	}
 #endif	
  return false;	
 }