Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous build fixes #145

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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: 2 additions & 0 deletions OpenSprinkler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ bool OpenSprinkler::load_hardware_mac(byte* mac, bool wired) {
mac[4] = 0x31;
mac[5] = iopts[IOPT_DEVICE_ID];

#if !defined(__FreeBSD__)
if (m_server == NULL) return true;

if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == 0) return true;
Expand All @@ -623,6 +624,7 @@ bool OpenSprinkler::load_hardware_mac(byte* mac, bool wired) {
}
}
close(fd);
#endif
return true;
}

Expand Down
40 changes: 26 additions & 14 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
#!/usr/bin/env bash

UNAME_s=$(uname -s)

while getopts ":s" opt; do
case $opt in
Expand All @@ -10,24 +12,34 @@ while getopts ":s" opt; do
done
echo "Building OpenSprinkler..."

if [ "$1" == "demo" ]; then
echo "Installing required libraries..."
echo "Installing required libraries..."
case $UNAME_s in
FreeBSD)
pkg install -y mosquitto
;;
*)
apt-get install -y libmosquitto-dev
echo "Compiling firmware..."
g++ -o OpenSprinkler -DDEMO -m32 main.cpp OpenSprinkler.cpp program.cpp server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp -lpthread -lmosquitto
;;
esac

if [ "$1" == "demo" ]; then
CFLAGS="-DDEMO -m32"
elif [ "$1" == "osbo" ]; then
echo "Installing required libraries..."
apt-get install -y libmosquitto-dev
echo "Compiling firmware..."
g++ -o OpenSprinkler -DOSBO main.cpp OpenSprinkler.cpp program.cpp server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp -lpthread -lmosquitto
CFLAGS="-DOSBO"
else
echo "Installing required libraries..."
apt-get install -y libmosquitto-dev
echo "Compiling firmware..."
g++ -o OpenSprinkler -DOSPI main.cpp OpenSprinkler.cpp program.cpp server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp -lpthread -lmosquitto
CFLAGS="-DOSPI"
fi
echo "Compiling firmware..."
SRCS="main.cpp OpenSprinkler.cpp program.cpp server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp"
if [ $UNAME_s = FreeBSD ]; then
CXX=c++
CFLAGS="$CFLAGS -I/usr/local/include -L/usr/local/lib"
else
CXX=g++
fi
$CXX -o OpenSprinkler $CFLAGS $SRCS -lpthread -lmosquitto

if [ ! "$SILENT" = true ] && [ -f OpenSprinkler.launch ] && [ ! -f /etc/init.d/OpenSprinkler.sh ]; then
if [ "$UNAME_s" != FreeBSD ] && [ ! "$SILENT" = true ] && [ -f OpenSprinkler.launch ] && [ ! -f /etc/init.d/OpenSprinkler.sh ]; then

read -p "Do you want to start OpenSprinkler on startup? " -n 1 -r
echo
Expand Down
2 changes: 1 addition & 1 deletion etherport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ bool EthernetServer::begin()
DEBUG_PRINTLN("can't setsockopt IPV6_V6ONLY");
return false;
}
if (bind(m_sock, (struct sockaddr *) &sin, sizeof(sin)) < 0)
if (::bind(m_sock, (struct sockaddr *) &sin, sizeof(sin)) < 0)
{
DEBUG_PRINTLN("shell bind error");
return false;
Expand Down
8 changes: 4 additions & 4 deletions gpio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,10 @@ void attachInterrupt(int pin, const char* mode, void (*isr)(void)) {

pthread_t threadId ;
pthread_mutex_lock (&pinMutex) ;
pinPass = pin ;
pthread_create (&threadId, NULL, interruptHandler, NULL) ;
while (pinPass != -1)
delay(1) ;
pinPass = pin ;
pthread_create (&threadId, NULL, interruptHandler, NULL) ;
while (pinPass != -1)
delay(1) ;
pthread_mutex_unlock (&pinMutex) ;
}
#else
Expand Down