mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-06 11:36:59 +03:00
add RSSI + disable equalizer when not needed - release
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "esp_pthread.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_wifi.h"
|
||||
|
||||
void get_mac(u8_t mac[]) {
|
||||
esp_read_mac(mac, ESP_MAC_WIFI_STA);
|
||||
@@ -58,3 +59,11 @@ void embedded_init(void) {
|
||||
sb_controls_init();
|
||||
if (sb_display_init()) custom_player_id = 100;
|
||||
}
|
||||
|
||||
u16_t get_RSSI(void) {
|
||||
wifi_ap_record_t wifidata;
|
||||
esp_wifi_sta_get_ap_info(&wifidata);
|
||||
// we'll assume dBm, -30 to -100
|
||||
if (wifidata.primary != 0) return 100 + wifidata.rssi + 30;
|
||||
else return 0xffff;
|
||||
}
|
||||
|
||||
@@ -59,6 +59,9 @@ void register_external(void);
|
||||
void deregister_external(void);
|
||||
void decode_restore(int external);
|
||||
|
||||
// must provide or define as 0xffff
|
||||
u16_t get_RSSI(void);
|
||||
|
||||
// to be defined to nothing if you don't want to support these
|
||||
extern struct visu_export_s {
|
||||
pthread_mutex_t mutex;
|
||||
|
||||
@@ -45,11 +45,18 @@ void equalizer_open(u32_t sample_rate) {
|
||||
equalizer.update = false;
|
||||
|
||||
if (equalizer.handle) {
|
||||
LOG_INFO("equalizer initialized");
|
||||
bool active = false;
|
||||
|
||||
for (int i = 0; i < EQ_BANDS; i++) {
|
||||
esp_equalizer_set_band_value(equalizer.handle, equalizer.gain[i], i, 0);
|
||||
esp_equalizer_set_band_value(equalizer.handle, equalizer.gain[i], i, 1);
|
||||
active |= equalizer.gain[i] != 0;
|
||||
}
|
||||
|
||||
// do not activate equalizer if all gain are 0
|
||||
if (!active) equalizer_close();
|
||||
|
||||
LOG_INFO("equalizer initialized %u", active);
|
||||
} else {
|
||||
LOG_WARN("can't init equalizer");
|
||||
}
|
||||
|
||||
@@ -183,7 +183,11 @@ static void sendSTAT(const char *event, u32_t server_timestamp) {
|
||||
packN(&pkt.stream_buffer_size, status.stream_size);
|
||||
packN(&pkt.bytes_received_H, (u64_t)status.stream_bytes >> 32);
|
||||
packN(&pkt.bytes_received_L, (u64_t)status.stream_bytes & 0xffffffff);
|
||||
#if EMBEDDED
|
||||
packn(&pkt.signal_strength, get_RSSI());
|
||||
#else
|
||||
pkt.signal_strength = 0xffff;
|
||||
#endif
|
||||
packN(&pkt.jiffies, now);
|
||||
packN(&pkt.output_buffer_size, status.output_size);
|
||||
packN(&pkt.output_buffer_fullness, status.output_full);
|
||||
|
||||
Reference in New Issue
Block a user