Add arduino-mk Makefile and fix build
This commit is contained in:
parent
3a0663bd70
commit
623d50b873
2 changed files with 154 additions and 151 deletions
|
@ -54,102 +54,6 @@ const int rlight = 6;
|
|||
const int topen = 2;
|
||||
const int tclose = 3;
|
||||
|
||||
// Status LED pins
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
pinMode(glight, OUTPUT);
|
||||
pinMode(rlight, OUTPUT);
|
||||
|
||||
// Buttons with pullup resistor
|
||||
pinMode(topen, INPUT);
|
||||
pinMode(tclose, INPUT);
|
||||
digitalWrite(topen,HIGH);
|
||||
digitalWrite(tclose,HIGH);
|
||||
|
||||
// Start Serial for debugging on the Serial Monitor
|
||||
if(debug){
|
||||
Serial.begin(9600);
|
||||
}
|
||||
// Start Ethernet on Arduino
|
||||
setEth(-1);
|
||||
setRoom(2);
|
||||
|
||||
Timer1.initialize(20000); // 50 mal die Sekunde
|
||||
Timer1.attachInterrupt(setLeds);
|
||||
|
||||
startEthernet();
|
||||
|
||||
delay(1000);
|
||||
|
||||
// Get current Status
|
||||
RequestState();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
readButtons();
|
||||
launchUpdate();
|
||||
}
|
||||
|
||||
|
||||
void readButtons(){
|
||||
int ret=0;
|
||||
if((digitalRead(topen)==LOW)&&(hsopen!=1)){
|
||||
//startEthernet();
|
||||
setRoom(2);
|
||||
TriggerServerUpdate(true);
|
||||
}
|
||||
if((digitalRead(tclose)==LOW)&&(hsopen!=0)){
|
||||
//startEthernet();
|
||||
setRoom(2);
|
||||
TriggerServerUpdate(false);
|
||||
}
|
||||
}
|
||||
|
||||
void launchUpdate(){
|
||||
if(update==1){
|
||||
RequestPing();
|
||||
RequestState();
|
||||
update = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void startEthernet()
|
||||
{
|
||||
client.stop();
|
||||
if(debug){
|
||||
Serial.println("Connecting Arduino to network...");
|
||||
Serial.println();
|
||||
}
|
||||
setEth(-1);
|
||||
delay(1000);
|
||||
|
||||
// Connect to network amd obtain an IP address using DHCP
|
||||
if (Ethernet.begin(mac) == 0)
|
||||
{
|
||||
if(debug){
|
||||
Serial.println("DHCP Failed, reset Arduino to try again");
|
||||
Serial.println();
|
||||
}
|
||||
setEth(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(debug){
|
||||
Serial.println("Arduino connected to network using DHCP");
|
||||
Serial.println();
|
||||
}
|
||||
setEth(1);
|
||||
}
|
||||
if(debug){
|
||||
Serial.println("DONE");
|
||||
Serial.println();
|
||||
}
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void setLeds(){
|
||||
if (pingtimer>=0)
|
||||
{
|
||||
|
@ -256,49 +160,38 @@ void setRoom(int statuss){
|
|||
setLeds();
|
||||
}
|
||||
|
||||
|
||||
void RequestState() {
|
||||
TriggerServerReq("/status-s.php",0);
|
||||
}
|
||||
|
||||
|
||||
void RequestPing() {
|
||||
TriggerServerReq("/ping-get.php?apikey="+pingAPIKey,1);
|
||||
}
|
||||
|
||||
void TriggerServerReq(String s, int mode) {
|
||||
// attempt to connect, and wait a millisecond:
|
||||
if(debug){Serial.println("connecting to server... Status req");}
|
||||
if (client.connect(serverName, 80)) {
|
||||
if(debug){Serial.println("making HTTP request...");}
|
||||
// make HTTP GET request to server:
|
||||
client.println("GET "+ s +" HTTP/1.1");
|
||||
client.println("HOST: it-syndikat.org");
|
||||
client.println("Connection: close");
|
||||
client.println();
|
||||
readServerStatus(mode);
|
||||
}else{
|
||||
if(debug){Serial.println("Not connected...");}
|
||||
void startEthernet()
|
||||
{
|
||||
client.stop();
|
||||
if(debug){
|
||||
Serial.println("Connecting Arduino to network...");
|
||||
Serial.println();
|
||||
}
|
||||
// note the time of this connect attempt:
|
||||
}
|
||||
setEth(-1);
|
||||
delay(1000);
|
||||
|
||||
void TriggerServerUpdate(boolean stat) {
|
||||
// attempt to connect, and wait a millisecond:
|
||||
if(debug){Serial.println("connecting to server... Update Req");}
|
||||
if (client.connect(serverName, 80)) {
|
||||
if(debug){Serial.println("making HTTP request...");}
|
||||
// make HTTP GET request to server:
|
||||
String s =(stat?"true":"false");
|
||||
client.println("GET /update.php?open=" + s + "&apikey="+serverAPIKey+" HTTP/1.1");
|
||||
client.println("HOST: it-syndikat.org");
|
||||
client.println("Connection: close");
|
||||
client.println();
|
||||
readServerStatus(0);
|
||||
}else{
|
||||
if(debug){Serial.println("Not connected...");}
|
||||
// Connect to network amd obtain an IP address using DHCP
|
||||
if (Ethernet.begin(mac) == 0)
|
||||
{
|
||||
if(debug){
|
||||
Serial.println("DHCP Failed, reset Arduino to try again");
|
||||
Serial.println();
|
||||
}
|
||||
setEth(0);
|
||||
}
|
||||
// note the time of this connect attempt:
|
||||
else
|
||||
{
|
||||
if(debug){
|
||||
Serial.println("Arduino connected to network using DHCP");
|
||||
Serial.println();
|
||||
}
|
||||
setEth(1);
|
||||
}
|
||||
if(debug){
|
||||
Serial.println("DONE");
|
||||
Serial.println();
|
||||
}
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
//reads out the status returned by the server and sets the LED's appropriately.
|
||||
|
@ -365,6 +258,109 @@ int readServerStatus(int mode) {
|
|||
client.stop();
|
||||
}
|
||||
|
||||
void TriggerServerReq(String s, int mode) {
|
||||
// attempt to connect, and wait a millisecond:
|
||||
if(debug){Serial.println("connecting to server... Status req");}
|
||||
if (client.connect(serverName, 80)) {
|
||||
if(debug){Serial.println("making HTTP request...");}
|
||||
// make HTTP GET request to server:
|
||||
client.println("GET "+ s +" HTTP/1.1");
|
||||
client.println("HOST: it-syndikat.org");
|
||||
client.println("Connection: close");
|
||||
client.println();
|
||||
readServerStatus(mode);
|
||||
}else{
|
||||
if(debug){Serial.println("Not connected...");}
|
||||
}
|
||||
// note the time of this connect attempt:
|
||||
}
|
||||
|
||||
void RequestState() {
|
||||
TriggerServerReq("/status-s.php",0);
|
||||
}
|
||||
|
||||
// Status LED pins
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
pinMode(glight, OUTPUT);
|
||||
pinMode(rlight, OUTPUT);
|
||||
|
||||
// Buttons with pullup resistor
|
||||
pinMode(topen, INPUT);
|
||||
pinMode(tclose, INPUT);
|
||||
digitalWrite(topen,HIGH);
|
||||
digitalWrite(tclose,HIGH);
|
||||
|
||||
// Start Serial for debugging on the Serial Monitor
|
||||
if(debug){
|
||||
Serial.begin(9600);
|
||||
}
|
||||
// Start Ethernet on Arduino
|
||||
setEth(-1);
|
||||
setRoom(2);
|
||||
|
||||
Timer1.initialize(20000); // 50 mal die Sekunde
|
||||
Timer1.attachInterrupt(setLeds);
|
||||
|
||||
startEthernet();
|
||||
|
||||
delay(1000);
|
||||
|
||||
// Get current Status
|
||||
RequestState();
|
||||
}
|
||||
|
||||
void TriggerServerUpdate(boolean stat) {
|
||||
// attempt to connect, and wait a millisecond:
|
||||
if(debug){Serial.println("connecting to server... Update Req");}
|
||||
if (client.connect(serverName, 80)) {
|
||||
if(debug){Serial.println("making HTTP request...");}
|
||||
// make HTTP GET request to server:
|
||||
String s =(stat?"true":"false");
|
||||
client.println("GET /update.php?open=" + s + "&apikey="+serverAPIKey+" HTTP/1.1");
|
||||
client.println("HOST: it-syndikat.org");
|
||||
client.println("Connection: close");
|
||||
client.println();
|
||||
readServerStatus(0);
|
||||
}else{
|
||||
if(debug){Serial.println("Not connected...");}
|
||||
}
|
||||
// note the time of this connect attempt:
|
||||
}
|
||||
|
||||
void readButtons(){
|
||||
int ret=0;
|
||||
if((digitalRead(topen)==LOW)&&(hsopen!=1)){
|
||||
//startEthernet();
|
||||
setRoom(2);
|
||||
TriggerServerUpdate(true);
|
||||
}
|
||||
if((digitalRead(tclose)==LOW)&&(hsopen!=0)){
|
||||
//startEthernet();
|
||||
setRoom(2);
|
||||
TriggerServerUpdate(false);
|
||||
}
|
||||
}
|
||||
|
||||
void RequestPing() {
|
||||
TriggerServerReq("/ping-get.php?apikey="+pingAPIKey,1);
|
||||
}
|
||||
|
||||
void launchUpdate(){
|
||||
if(update==1){
|
||||
RequestPing();
|
||||
RequestState();
|
||||
update = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
readButtons();
|
||||
launchUpdate();
|
||||
}
|
||||
|
||||
//This just reads the server return and logs it to the serial
|
||||
// @deprecated
|
||||
|
@ -380,4 +376,3 @@ void readServerReturn() {
|
|||
if(debug){Serial.println("disconnecting.");}
|
||||
client.stop();
|
||||
}
|
||||
|
||||
|
|
8
ITS_Open_direct_2fb/Makefile
Normal file
8
ITS_Open_direct_2fb/Makefile
Normal file
|
@ -0,0 +1,8 @@
|
|||
ARDUINO_DIR = /usr/share/arduino
|
||||
ARDMK_DIR = /usr/share/arduino
|
||||
AVR_TOOLS_DIR = /usr
|
||||
|
||||
BOARD_TAG = uno
|
||||
ARDUINO_LIBS = Ethernet SPI
|
||||
|
||||
include $(ARDMK_DIR)/Arduino.mk
|
Reference in a new issue