Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ArduinoHue/ArduinoHue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int ArduinoHue::fillRequestAndProcess(int light,boolean useState){
return STATUS_POST_ERROR;

}
int ArduinoHue::setHueSat(int light, int hue, int sat){
int ArduinoHue::setHueSat(int light, unsigned hue, int sat){
strcpy_P(_buffer, (char*)change_color_string);
sprintf(_lastResponse, _buffer, hue, sat);
return fillRequestAndProcess(light,true);
Expand Down
4 changes: 2 additions & 2 deletions ArduinoHue/ArduinoHue.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <avr/pgmspace.h>

const char turn_on_off[] PROGMEM = "{\"on\":%s}";
const char change_color_string[] PROGMEM = "{\"hue\":%i,\"sat\":%i}";
const char change_color_string[] PROGMEM = "{\"hue\":%u,\"sat\":%i}";
const char set_bri_string[] PROGMEM = "{\"bri\":%i}";
const char set_alert_string[] PROGMEM = "{\"alert\":\"%s\"}";

Expand All @@ -20,7 +20,7 @@ class ArduinoHue{
public:
int turnOff(int light);
int turnOn(int light);
int setHueSat(int light,int hue, int sat);
int setHueSat(int light,unsigned hue, int sat);
int setBri(int light, int bri);
int setShortAlert(int light, boolean on);
int setLongAlert(int light, boolean on);
Expand Down
16 changes: 8 additions & 8 deletions SerialHue/SerialBridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#replace this with your serial device.
# ser = serial.Serial('/dev/tty.usbmodemfd141', 9600)

ser = serial.Serial('/dev/tty.usbmodemfd131', 9600)
ser = serial.Serial('/dev/ttyACM0', 9600)
#ser = serial.Serial('/dev/tty.usbserial-A800I2RW', 9600)
siteStartChar = 0x04
siteEndChar = 0x05
Expand All @@ -19,13 +19,13 @@ def readValue(endChar):
val = ser.read()
if ord(val) == endChar:
return tmp
tmp += val
#print tmp
tmp += val.decode("utf-8")

def put(s, r, d):
#"http://192.168.1.10/api/22a828f1898a4257c3f181e753241337/lights/1/state"
r = requests.put(s+r, data=d)
resp = r.content
print resp;
print(resp)
ser.write(resp)

while 1:
Expand All @@ -36,15 +36,15 @@ def put(s, r, d):
postRequest = ""
postData = ""
site = readValue(siteEndChar)
print 'postSite=', site
print('postSite=', site)
elif ord(val) == postStartChar:
postRequest = ""
postRequest = readValue(postEndChar)
print 'postRequest=', postRequest
print('postRequest=', postRequest)
elif ord(val) == dataStartChar:
postData = ""
postData = readValue(dataEndChar)
print 'postData=', postData
print('postData=', postData)
put(site, postRequest, postData)
else:
print val
print(val)
4 changes: 3 additions & 1 deletion SerialHue/SerialHue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ boolean SerialHue::makePost(char* request, char* data){
_serial->print(_ipAddress);
_serial->write(0x05);
_serial->write(0x06);
_serial->print("/api/22a828f1898a4257c3f181e753241337/");
_serial->print("/api/");
_serial->print(_username);
_serial->print("/");
_serial->print(request);
_serial->write(0x07);
_serial->write(0x08);
Expand Down