mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-08 20:47:08 +03:00
@@ -33,7 +33,6 @@ function stopCheckStatusInterval(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function stopRefreshAPInterval(){
|
function stopRefreshAPInterval(){
|
||||||
|
|
||||||
if(refreshAPInterval != null){
|
if(refreshAPInterval != null){
|
||||||
clearTimeout(refreshAPInterval);
|
clearTimeout(refreshAPInterval);
|
||||||
refreshAPInterval = null;
|
refreshAPInterval = null;
|
||||||
@@ -41,7 +40,6 @@ function stopRefreshAPInterval(){
|
|||||||
RefreshAPIIntervalActive = false;
|
RefreshAPIIntervalActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function startCheckStatusInterval(){
|
function startCheckStatusInterval(){
|
||||||
StatusIntervalActive = true;
|
StatusIntervalActive = true;
|
||||||
checkStatusInterval = setTimeout(checkStatus, 950);
|
checkStatusInterval = setTimeout(checkStatus, 950);
|
||||||
@@ -52,7 +50,6 @@ function startRefreshAPInterval(){
|
|||||||
refreshAPInterval = setTimeout(refreshAP, 2800);
|
refreshAPInterval = setTimeout(refreshAP, 2800);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function RepeatCheckStatusInterval(){
|
function RepeatCheckStatusInterval(){
|
||||||
if(StatusIntervalActive)
|
if(StatusIntervalActive)
|
||||||
startCheckStatusInterval();
|
startCheckStatusInterval();
|
||||||
@@ -155,7 +152,6 @@ $(document).ready(function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#yes-disconnect").on("click", function() {
|
$("#yes-disconnect").on("click", function() {
|
||||||
|
|
||||||
stopCheckStatusInterval();
|
stopCheckStatusInterval();
|
||||||
selectedSSID = "";
|
selectedSSID = "";
|
||||||
|
|
||||||
@@ -206,7 +202,6 @@ $(document).ready(function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
function performConnect(conntype){
|
function performConnect(conntype){
|
||||||
|
|
||||||
//stop the status refresh. This prevents a race condition where a status
|
//stop the status refresh. This prevents a race condition where a status
|
||||||
//request would be refreshed with wrong ip info from a previous connection
|
//request would be refreshed with wrong ip info from a previous connection
|
||||||
//and the request would automatically shows as succesful.
|
//and the request would automatically shows as succesful.
|
||||||
@@ -277,10 +272,10 @@ function refreshAP(){
|
|||||||
});
|
});
|
||||||
apList = data;
|
apList = data;
|
||||||
refreshAPHTML(apList);
|
refreshAPHTML(apList);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RepeatRefreshAPInterval();
|
//TODO daduke
|
||||||
|
// RepeatRefreshAPInterval();
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshAPHTML(data){
|
function refreshAPHTML(data){
|
||||||
@@ -295,9 +290,6 @@ function refreshAPHTML(data){
|
|||||||
|
|
||||||
function checkStatus(){
|
function checkStatus(){
|
||||||
$.getJSON( "/status.json", function( data ) {
|
$.getJSON( "/status.json", function( data ) {
|
||||||
if(data.hasOwnProperty('autoexec1') && data['autoexec1'] != ""){
|
|
||||||
$("#autoexec1_current").text(data["autoexec1"]);
|
|
||||||
}
|
|
||||||
if(data.hasOwnProperty('ssid') && data['ssid'] != ""){
|
if(data.hasOwnProperty('ssid') && data['ssid'] != ""){
|
||||||
if(data["ssid"] === selectedSSID){
|
if(data["ssid"] === selectedSSID){
|
||||||
//that's a connection attempt
|
//that's a connection attempt
|
||||||
@@ -349,6 +341,10 @@ function checkStatus(){
|
|||||||
$("#gw").text(data["gw"]);
|
$("#gw").text(data["gw"]);
|
||||||
$("#wifi-status").slideDown( "fast", function() {});
|
$("#wifi-status").slideDown( "fast", function() {});
|
||||||
}
|
}
|
||||||
|
//TODO daduke
|
||||||
|
console.log("stopping timers..");
|
||||||
|
stopCheckStatusInterval();
|
||||||
|
stopRefreshAPInterval
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(data.hasOwnProperty('urc') && data['urc'] === 2){
|
else if(data.hasOwnProperty('urc') && data['urc'] === 2){
|
||||||
@@ -443,9 +439,9 @@ function generateCommand() {
|
|||||||
var commandLine = commandHeader + '-n ' + $("#player").val();
|
var commandLine = commandHeader + '-n ' + $("#player").val();
|
||||||
|
|
||||||
if (output == 'bt') {
|
if (output == 'bt') {
|
||||||
commandLine += ' -o "BT -n \'' + $("#btsink").val() + '\'" -R -u m -Z 192000 -r "44100-44100"';
|
commandLine += ' -o "BT -n \'' + $("#btsink").val() + '\'" -R -Z 192000';
|
||||||
} else if (output == 'spdif') {
|
} else if (output == 'spdif') {
|
||||||
commandLine += ' -o SPDIF';
|
commandLine += ' -o SPDIF -R -Z 192000';
|
||||||
} else {
|
} else {
|
||||||
commandLine += ' -o I2S';
|
commandLine += ' -o I2S';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,11 +237,14 @@ function handleClick(cb) {
|
|||||||
<header><h1>Firmware upgrade</h1></header>
|
<header><h1>Firmware upgrade</h1></header>
|
||||||
<form name="multipart" action="otaform" method="post" enctype="multipart/form-data" onsubmit="do_upload(this); return false;">
|
<form name="multipart" action="otaform" method="post" enctype="multipart/form-data" onsubmit="do_upload(this); return false;">
|
||||||
<progress id="progr" value="0" max="100" >Upload Progress</progress>
|
<progress id="progr" value="0" max="100" >Upload Progress</progress>
|
||||||
<input type="file" name="ota" id="ota" size="20" accept=".bin" onchange="file_change();" style="font-size: 12pt">
|
<input type="file" name="ota" id="ota" size="20" accept=".bin" onchange="file_change();">
|
||||||
<span id="file_info" style="font-size:12pt;"></span>
|
<span id="file_info"></span>
|
||||||
<input type="submit" id="update" disabled="" value="upload">
|
<input type="submit" id="update" disabled="" value="Upload">
|
||||||
<input type="submit" id="factory" disabled="" value="factory">
|
|
||||||
</form>
|
</form>
|
||||||
|
<h2>Reboot system with new firmware</h2>
|
||||||
|
<div class="buttons">
|
||||||
|
<input type="button" id="reboot" value="Reboot" onclick='handleClick(this);' />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="wifi">
|
<div id="wifi">
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ void wifi_manager_start(){
|
|||||||
/* start wifi manager task */
|
/* start wifi manager task */
|
||||||
xTaskCreate(&wifi_manager, "wifi_manager", 4096, NULL, WIFI_MANAGER_TASK_PRIORITY, &task_wifi_manager);
|
xTaskCreate(&wifi_manager, "wifi_manager", 4096, NULL, WIFI_MANAGER_TASK_PRIORITY, &task_wifi_manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t wifi_manager_get_flag(){
|
uint8_t wifi_manager_get_flag(){
|
||||||
uint8_t value=0;
|
uint8_t value=0;
|
||||||
nvs_handle handle;
|
nvs_handle handle;
|
||||||
@@ -244,6 +245,7 @@ esp_err_t wifi_manager_save_autoexec_flag(uint8_t flag){
|
|||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t wifi_manager_save_autoexec_config(char * value, char * name, int len){
|
esp_err_t wifi_manager_save_autoexec_config(char * value, char * name, int len){
|
||||||
nvs_handle handle;
|
nvs_handle handle;
|
||||||
char val[len+1];
|
char val[len+1];
|
||||||
@@ -276,8 +278,8 @@ esp_err_t wifi_manager_save_autoexec_config(char * value, char * name, int len){
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
|
|
||||||
}
|
}
|
||||||
esp_err_t wifi_manager_save_sta_config(){
|
|
||||||
|
|
||||||
|
esp_err_t wifi_manager_save_sta_config(){
|
||||||
nvs_handle handle;
|
nvs_handle handle;
|
||||||
esp_err_t esp_err;
|
esp_err_t esp_err;
|
||||||
ESP_LOGI(TAG, "About to save config to flash");
|
ESP_LOGI(TAG, "About to save config to flash");
|
||||||
@@ -320,7 +322,6 @@ esp_err_t wifi_manager_save_sta_config(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool wifi_manager_fetch_wifi_sta_config(){
|
bool wifi_manager_fetch_wifi_sta_config(){
|
||||||
|
|
||||||
nvs_handle handle;
|
nvs_handle handle;
|
||||||
esp_err_t esp_err;
|
esp_err_t esp_err;
|
||||||
|
|
||||||
@@ -403,7 +404,6 @@ void wifi_manager_clear_ip_info_json(){
|
|||||||
|
|
||||||
|
|
||||||
void wifi_manager_generate_ip_info_json(update_reason_code_t update_reason_code){
|
void wifi_manager_generate_ip_info_json(update_reason_code_t update_reason_code){
|
||||||
|
|
||||||
wifi_config_t *config = wifi_manager_get_wifi_sta_config();
|
wifi_config_t *config = wifi_manager_get_wifi_sta_config();
|
||||||
if(config){
|
if(config){
|
||||||
|
|
||||||
@@ -445,16 +445,14 @@ void wifi_manager_generate_ip_info_json(update_reason_code_t update_reason_code)
|
|||||||
else{
|
else{
|
||||||
wifi_manager_clear_ip_info_json();
|
wifi_manager_clear_ip_info_json();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wifi_manager_clear_access_points_json(){
|
void wifi_manager_clear_access_points_json(){
|
||||||
strcpy(accessp_json, "[]\n");
|
strcpy(accessp_json, "[]\n");
|
||||||
}
|
}
|
||||||
void wifi_manager_generate_acess_points_json(){
|
|
||||||
|
|
||||||
|
void wifi_manager_generate_acess_points_json(){
|
||||||
strcpy(accessp_json, "[");
|
strcpy(accessp_json, "[");
|
||||||
|
|
||||||
|
|
||||||
@@ -483,8 +481,6 @@ void wifi_manager_generate_acess_points_json(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool wifi_manager_lock_sta_ip_string(TickType_t xTicksToWait){
|
bool wifi_manager_lock_sta_ip_string(TickType_t xTicksToWait){
|
||||||
if(wifi_manager_sta_ip_mutex){
|
if(wifi_manager_sta_ip_mutex){
|
||||||
if( xSemaphoreTake( wifi_manager_sta_ip_mutex, xTicksToWait ) == pdTRUE ) {
|
if( xSemaphoreTake( wifi_manager_sta_ip_mutex, xTicksToWait ) == pdTRUE ) {
|
||||||
@@ -499,12 +495,12 @@ bool wifi_manager_lock_sta_ip_string(TickType_t xTicksToWait){
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wifi_manager_unlock_sta_ip_string(){
|
void wifi_manager_unlock_sta_ip_string(){
|
||||||
xSemaphoreGive( wifi_manager_sta_ip_mutex );
|
xSemaphoreGive( wifi_manager_sta_ip_mutex );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wifi_manager_safe_update_sta_ip_string(uint32_t ip){
|
void wifi_manager_safe_update_sta_ip_string(uint32_t ip){
|
||||||
|
|
||||||
if(wifi_manager_lock_sta_ip_string(portMAX_DELAY)){
|
if(wifi_manager_lock_sta_ip_string(portMAX_DELAY)){
|
||||||
|
|
||||||
struct ip4_addr ip4;
|
struct ip4_addr ip4;
|
||||||
@@ -524,7 +520,6 @@ char* wifi_manager_get_sta_ip_string(){
|
|||||||
return wifi_manager_sta_ip;
|
return wifi_manager_sta_ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool wifi_manager_lock_json_buffer(TickType_t xTicksToWait){
|
bool wifi_manager_lock_json_buffer(TickType_t xTicksToWait){
|
||||||
if(wifi_manager_json_mutex){
|
if(wifi_manager_json_mutex){
|
||||||
if( xSemaphoreTake( wifi_manager_json_mutex, xTicksToWait ) == pdTRUE ) {
|
if( xSemaphoreTake( wifi_manager_json_mutex, xTicksToWait ) == pdTRUE ) {
|
||||||
@@ -539,6 +534,7 @@ bool wifi_manager_lock_json_buffer(TickType_t xTicksToWait){
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wifi_manager_unlock_json_buffer(){
|
void wifi_manager_unlock_json_buffer(){
|
||||||
xSemaphoreGive( wifi_manager_json_mutex );
|
xSemaphoreGive( wifi_manager_json_mutex );
|
||||||
}
|
}
|
||||||
@@ -547,12 +543,8 @@ char* wifi_manager_get_ap_list_json(){
|
|||||||
return accessp_json;
|
return accessp_json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t wifi_manager_event_handler(void *ctx, system_event_t *event)
|
esp_err_t wifi_manager_event_handler(void *ctx, system_event_t *event)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch(event->event_id) {
|
switch(event->event_id) {
|
||||||
|
|
||||||
case SYSTEM_EVENT_WIFI_READY:
|
case SYSTEM_EVENT_WIFI_READY:
|
||||||
@@ -629,7 +621,6 @@ wifi_config_t* wifi_manager_get_wifi_sta_config(){
|
|||||||
return wifi_manager_config_sta;
|
return wifi_manager_config_sta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wifi_manager_connect_async(){
|
void wifi_manager_connect_async(){
|
||||||
/* in order to avoid a false positive on the front end app we need to quickly flush the ip json
|
/* in order to avoid a false positive on the front end app we need to quickly flush the ip json
|
||||||
* There'se a risk the front end sees an IP or a password error when in fact
|
* There'se a risk the front end sees an IP or a password error when in fact
|
||||||
@@ -648,7 +639,6 @@ char* wifi_manager_get_ip_info_json(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void wifi_manager_destroy(){
|
void wifi_manager_destroy(){
|
||||||
|
|
||||||
vTaskDelete(task_wifi_manager);
|
vTaskDelete(task_wifi_manager);
|
||||||
task_wifi_manager = NULL;
|
task_wifi_manager = NULL;
|
||||||
|
|
||||||
@@ -675,11 +665,8 @@ void wifi_manager_destroy(){
|
|||||||
wifi_manager_event_group = NULL;
|
wifi_manager_event_group = NULL;
|
||||||
vQueueDelete(wifi_manager_queue);
|
vQueueDelete(wifi_manager_queue);
|
||||||
wifi_manager_queue = NULL;
|
wifi_manager_queue = NULL;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wifi_manager_filter_unique( wifi_ap_record_t * aplist, uint16_t * aps) {
|
void wifi_manager_filter_unique( wifi_ap_record_t * aplist, uint16_t * aps) {
|
||||||
int total_unique;
|
int total_unique;
|
||||||
wifi_ap_record_t * first_free;
|
wifi_ap_record_t * first_free;
|
||||||
@@ -731,7 +718,6 @@ void wifi_manager_filter_unique( wifi_ap_record_t * aplist, uint16_t * aps) {
|
|||||||
*aps = total_unique;
|
*aps = total_unique;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BaseType_t wifi_manager_send_message_to_front(message_code_t code, void *param){
|
BaseType_t wifi_manager_send_message_to_front(message_code_t code, void *param){
|
||||||
queue_message msg;
|
queue_message msg;
|
||||||
msg.code = code;
|
msg.code = code;
|
||||||
@@ -746,26 +732,19 @@ BaseType_t wifi_manager_send_message(message_code_t code, void *param){
|
|||||||
return xQueueSend( wifi_manager_queue, &msg, portMAX_DELAY);
|
return xQueueSend( wifi_manager_queue, &msg, portMAX_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wifi_manager_set_callback(message_code_t message_code, void (*func_ptr)(void*) ){
|
void wifi_manager_set_callback(message_code_t message_code, void (*func_ptr)(void*) ){
|
||||||
|
|
||||||
if(cb_ptr_arr && message_code < MESSAGE_CODE_COUNT){
|
if(cb_ptr_arr && message_code < MESSAGE_CODE_COUNT){
|
||||||
cb_ptr_arr[message_code] = func_ptr;
|
cb_ptr_arr[message_code] = func_ptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wifi_manager( void * pvParameters ){
|
void wifi_manager( void * pvParameters ){
|
||||||
|
|
||||||
|
|
||||||
queue_message msg;
|
queue_message msg;
|
||||||
BaseType_t xStatus;
|
BaseType_t xStatus;
|
||||||
EventBits_t uxBits;
|
EventBits_t uxBits;
|
||||||
uint8_t retries = 0;
|
uint8_t retries = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* initialize the tcp stack */
|
/* initialize the tcp stack */
|
||||||
tcpip_adapter_init();
|
tcpip_adapter_init();
|
||||||
|
|
||||||
@@ -1138,7 +1117,4 @@ void wifi_manager( void * pvParameters ){
|
|||||||
} /* end of for loop */
|
} /* end of for loop */
|
||||||
|
|
||||||
vTaskDelete( NULL );
|
vTaskDelete( NULL );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user