Serial Monitor get's flooded with "No Socket Available" message. This seems to occur even before I Try to communicate with my Hue bridge through my hub port. Does anyone see why this is occurring after my wireless connection is established?
Serial Output:
Firmware needs upgrade
Attempting to connect to WPA SSID: ifiw_ym
connected to the networkSSID: ifiw_ym
BSSID: 0:B2:8F:6A:C4:28
signal strength (RSSI):-47
Encryption Type:4
IP Address: 192.168.1.7
192.168.1.7
MAC address: 78:C4:E:1:9F:B1
in loopin loopin loopNo Socket available
No Socket available
in loopNo Socket available
No Socket available
in loopNo Socket available
No Socket available
in loopNo Socket available
No Socket available
...
code:
#include <SPI.h>
#include <WiFi.h>
// Hue constants
const char hueHubIP[] = "192.168.1.6";
const char hueUsername[] = "my_hue_app";
const int hueHubPort = 80;
boolean activated = false;
// Hue variables
boolean hueOn;
int hueBri; // brightness value
long hueHue; // hue value
String hueCmd; // Hue command
unsigned long buffer=0; //buffer for received data storage
unsigned long addr;
// Wireless network
char ssid[] = "**********";
char pass[] = "**********";
int status = WL_IDLE_STATUS;
WiFiClient client;
//0:B2:8F:6A:C4:28
void setup() {
Serial.begin(9600);
while (!Serial) {
;
}
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
while (true);
}
String fv = WiFi.firmwareVersion();
if (fv != "1.1.0") {
Serial.println("Firmware needs upgrade");
}
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to WPA SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
Serial.print("connected to the network");
printCurrentNet();
printWifiData();
}
void loop() {
Serial.print("in loop");
// printCurrentNet();
alterHueColors();
}
void alterHueColors() {
if(activated){
client.println("Hue is activated");
// A series of four sample commands, which colour fades two lights between red and pink. Read up on the Hue API
// documentation for more details on the exact commands to be used, but note that quote marks must be escaped.
String command = "{\"on\": true,\"hue\": 50100,\"sat\":255,\"bri\":255,\"transitiontime\":"+String(random(15,25))+"}";
setHue(3,command);
command = "{\"on\": true,\"hue\": 65280,\"sat\":255,\"bri\":255,\"transitiontime\":"+String(random(15,25))+"}";
setHue(4,command);
command = "{\"hue\": 65280,\"sat\":255,\"bri\":255,\"transitiontime\":"+String(random(15,25))+"}";
setHue(3,command);
command = "{\"hue\": 50100,\"sat\":255,\"bri\":255,\"transitiontime\":"+String(random(15,25))+"}";
setHue(4,command);
activated = true;
}
else{
activated = false;
client.println("deactivated");
//was activated, so send a single off command
String command = "{\"on\": false}";
setHue(3,command);
setHue(4,command);
}
}
It's also interesting to not that my print calls in alterHueColors() aren't triggering.
activated = false
to begin with. So inalterHueColors()
theif
condition will never betrue
and only theelse
block gets executed because it keepsactivated = false;
.192.168.1.6:80
from any other pc on the network?