2 Inter-driver communications tutorial - Rain Driver
3 Copyright (C) 2007 Jasem Mutlaq (mutlaqja@ikarustech.com)
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
32 #include <sys/types.h>
33 #include <sys/socket.h>
34 #include <netinet/in.h>
44 #define MAIN_GROUP "Main"
47 static ISwitch PowerS[] = {{
"CONNECT" ,
"Connect" ,
ISS_OFF, 0, 0},{
"DISCONNECT",
"Disconnect",
ISS_ON, 0, 0}};
48 static ISwitchVectorProperty PowerSP = { mydev,
"CONNECTION" ,
"Connection", MAIN_GROUP,
IP_RW,
ISR_1OFMANY, 60,
IPS_IDLE, PowerS,
NARRAY(PowerS),
"", 0};
58 static ISwitchVectorProperty RainSP = { mydev,
"Control Rain",
"", MAIN_GROUP,
IP_RW,
ISR_1OFMANY, 0,
IPS_IDLE, RainS ,
NARRAY(RainS),
"", 0};
68 void ISNewBLOB (
const char *dev,
const char *name,
int sizes[],
int blobsizes[],
char *blobs[],
char *formats[],
char *names[],
int n) {}
74 if (dev && strcmp (dev, mydev))
78 if (!strcmp (name, PowerSP.
name))
90 IDSetSwitch(&PowerSP,
"Rain Collector is offline.");
96 if (!strcmp (name, RainSP.
name))
100 IDMessage(mydev,
"The Rain Collector is offline!");
114 IDSetLight(&RainLP,
"Alert! Alert! Rain detected!");
120 IDSetLight(&RainLP,
"Rain threat passed. The skies are clear.");
128 void ISNewText (
const char *dev,
const char *name,
char *texts[],
char *names[],
int n)
132 if (dev && strcmp (mydev, dev))
136 n=n; dev=dev; name=name; names=names; texts=texts;
141 void ISNewNumber (
const char *dev,
const char *name,
double values[],
char *names[],
int n)