SonosUPNP Library won't compile on ESP8266-01 (version 3.1.2) and Arduino IDE (Windows 1.8.19) #9219
Replies: 1 comment
-
GCC is showing the exact error. The library has a function
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I know the SonosUPNP (T.Mittet) library is pretty old (https://github.com/tmittet/sonos). But it still very useful to me. I can read a sketch off an old ESP and write it to a new one without issue. But if I take the same sketch and try to compile it now, it will not compile. Does anyone have a working version of the library? Or can you point me in the direction of a suitable substitute?
My end goal is to update my SonosIR sketch from an old instructable I found online years ago (https://www.instructables.com/SonosIR/). Any advice you can share will be greatly appreciated. Thank you.
Here is my code (straigh from the instructable):
/* SonosIR.ino
*/
//IRremote library. https://github.com/z3t0/Arduino-IRremote
//To make this work with Denon amps like mine you need my updated ir_Sharp.cpp, IRRemote.h and irRecv.cpp files
//which you can find in my fork of Arduino-IRremote: https://github.com/buestad/Arduino-IRremote
#include <IRremote.h>
//SonosUPnP library. https://github.com/tmittet/sonos
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <WiFiManager.h>
#include <WiFiClient.h>
#include <SonosUPnP.h>
#include <MicroXPath_P.h>
//Pins
#define IR_SEND_PIN 3 //this is hard-coded in the IRremote library
#define IR_RECV_PIN 2
//Constants
#define SONOS_STATUS_POLL_DELAY_S 1 //Poll the sonos each second
#define AMP_POWER_OFF_DELAY_S 300 //Wait 300 seconds = 5 minutes before turning off amp
#define ETHERNET_ERROR_DHCP "E: DHCP"
#define ETHERNET_ERROR_CONNECT "E: Connect"
WiFiClient g_ethClient;
SonosUPnP g_sonos = SonosUPnP(g_ethClient, ðConnectError);
WiFiManager wm;
//The Sonos device IP and ID (can be found in the Sonos app)
IPAddress g_sonosIP(192, 168, 0, 223);
const char g_sonosID[] = "0123";
IRrecv irrecv(IR_RECV_PIN);
IRsend irsend;
decode_results results;
unsigned long lastSonos = millis();
unsigned long lastIR = millis();
bool cPlay;
int offTimer = -1;
void setup()
{
//Serial.begin(9600);
//delay(10);
irrecv.enableIRIn(); // Start the receiver
delay(100);
wm.autoConnect();
}
void loop()
{
unsigned long now = millis();
if((unsigned long)(now - lastSonos) > (SONOS_STATUS_POLL_DELAY_S*1000) )
{
pollSonos();
lastSonos = now;
}
if (irrecv.decode(&results))
{
if ((unsigned long)(now - lastIR) > 250)
{
IRAction(results.decode_type, results.address, results.value);
//Serial.print(results.decode_type == SHARP ? "SHARP ": "UNKNOWN ");
//Serial.print(results.address);
//Serial.print(" ");
//Serial.println(results.value, HEX);
}
lastIR = now;
irrecv.resume(); // Receive the next value
}
}
void IRAction(unsigned int protocol, unsigned int adr, unsigned int data)
{
if(protocol != SHARP || !(adr == 0x02 || adr == 0x08))
return;
switch(data)
{
//change source to CD, TV, DVD ...
case 0xC4: //CD
case 0xC9: //TV
case 0xE3: //DVD
//Serial.println("Changed source");
if(offTimer >= 0 && cPlay)
{
offTimer = -1;
cPlay = false;
}
break;
case 0x5C: //Play
//Serial.println("Play");
g_sonos.play(g_sonosIP);
break;
case 0x5E: //Stop
//Serial.println("Stop/Pause");
g_sonos.pause(g_sonosIP);
break;
case 0x58: //Skip next
//Serial.println("Skip next");
g_sonos.skip(g_sonosIP, SONOS_DIRECTION_FORWARD);
break;
case 0x59: //Skip prev
//Serial.println("Skip prev");
g_sonos.skip(g_sonosIP, SONOS_DIRECTION_BACKWARD);
break;
default:
//not recognized...
break;
}
}
void pollSonos()
{
int st = g_sonos.getState(g_sonosIP); //play
bool pl = isPlay(st);
//Serial.print("pl = ");
//Serial.print(pl);
//Serial.print(" cPlay = ");
//Serial.print(cPlay);
//Serial.print(" timer = ");
//Serial.println(offTimer);
if(pl && !cPlay)
{
//Change state from stop to play
//Serial.println("Amp ON!");
cPlay = true;
//Denon Sharp Device 2: Power ON: adress 02 = 0x02, data 225 = 0xE1
irsend.sendSharp(0x02,0xE1);
}
else if(!pl && cPlay && offTimer == -1)
{
// Serial.println("Schedule Amp OFF...");
//Change state from play to stop, but wait...
offTimer = AMP_POWER_OFF_DELAY_S;
}
if(pl && offTimer != -1)
{
offTimer = -1;
}
if(offTimer > 0 && cPlay)
{
offTimer -= SONOS_STATUS_POLL_DELAY_S;
}
if(offTimer == 0 && cPlay)
{
// Serial.println("Amp OFF!");
cPlay = false;
offTimer == -1;
}
//Serial.println("pollSonos() done...");
}
bool isPlay(int st)
{
if(st == 1)
return true;
return false;
}
void ethConnectError()
{
//Serial.println(ETHERNET_ERROR_CONNECT);
}
Here is the error.
Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Generic ESP8266 Module, 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, dtr (aka nodemcu), 26 MHz, 40MHz, DOUT (compatible), 1MB (FS:64KB OTA:~470KB), 2, nonos-sdk 2.2.1+100 (190703), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
C:\Users\thisUser\Documents\Arduino\libraries\sonos\src\SonosUPnP.cpp: In member function 'const char* SonosUPnP::getUpnpService(uint8_t)':
C:\Users\ thisUser \Documents\Arduino\libraries\sonos\src\SonosUPnP.cpp:788:1: error: control reaches end of non-void function [-Werror=return-type]
788 | }
| ^
C:\Users\ thisUser \Documents\Arduino\libraries\sonos\src\SonosUPnP.cpp: In member function 'const char* SonosUPnP::getUpnpEndpoint(uint8_t)':
C:\Users\ thisUser \Documents\Arduino\libraries\sonos\src\SonosUPnP.cpp:799:1: error: control reaches end of non-void function [-Werror=return-type]
799 | }
| ^
cc1plus.exe: some warnings being treated as errors
exit status 1
Error compiling for board Generic ESP8266 Module.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Beta Was this translation helpful? Give feedback.
All reactions