[Debian-iot-packaging] [openzwave-controlpanel] 17/81: Fixes to eliminate compiler errors from Peter. Topology display. Fix increment delete.
Dara Adib
daradib-guest at moszumanska.debian.org
Thu Dec 22 16:57:46 UTC 2016
This is an automated email from the git hooks/post-receive script.
daradib-guest pushed a commit to branch debian/master
in repository openzwave-controlpanel.
commit 4104956b065edd266af16808b02b55ebe5b5cf7b
Author: glsatz at gmail.com <glsatz at gmail.com>
Date: Sat Aug 20 15:48:52 2011 +0000
Fixes to eliminate compiler errors from Peter.
Topology display.
Fix increment delete.
---
Makefile | 43 ++++++++++++++---------
cp.html | 25 +++++++++++--
cp.js | 94 +++++++++++++++++++++++++++++++++++++++++++++----
ozwcp.cpp | 24 ++++++++++---
ozwcp.h | 17 ++++-----
webserver.cpp | 110 +++++++++++++++++++++++++++++++++++++++++++++++++---------
webserver.h | 3 +-
zwavelib.cpp | 8 ++---
8 files changed, 263 insertions(+), 61 deletions(-)
diff --git a/Makefile b/Makefile
index 869920c..8fd054d 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ LD := g++
AR := ar rc
RANLIB := ranlib
-DEBUG_CFLAGS := -Wall -Wno-format -g -DDEBUG
+DEBUG_CFLAGS := -Wall -Wno-format -g -DDEBUG -Werror
RELEASE_CFLAGS := -Wall -Wno-unknown-pragmas -Wno-format -O3 -DNDEBUG
DEBUG_LDFLAGS := -g
@@ -21,20 +21,26 @@ DEBUG_LDFLAGS := -g
CFLAGS := -c $(DEBUG_CFLAGS)
LDFLAGS := $(DEBUG_LDFLAGS)
-INCLUDES := -I ../open-zwave/cpp/src -I ../open-zwave/cpp/src/command_classes/ \
- -I ../open-zwave/cpp/src/value_classes/ -I ../open-zwave/cpp/src/platform/ \
- -I ../open-zwave/cpp/src/platform/unix -I ../open-zwave/cpp/tinyxml/ \
+OPENZWAVE := ../open-zwave
+LIBMICROHTTPD := ../libmicrohttpd/src/daemon/.libs/libmicrohttpd.a
+
+INCLUDES := -I $(OPENZWAVE)/cpp/src -I $(OPENZWAVE)/cpp/src/command_classes/ \
+ -I $(OPENZWAVE)/cpp/src/value_classes/ -I $(OPENZWAVE)/cpp/src/platform/ \
+ -I $(OPENZWAVE)/cpp/src/platform/unix -I $(OPENZWAVE)/cpp/tinyxml/ \
-I ../libmicrohttpd/src/include
+
# Remove comment below for gnutls support
GNUTLS := #-lgnutls
-LIBZWAVE := $(wildcard ../open-zwave/cpp/lib/linux/*.a)
-LIBUSB := -ludev
-# Remove comment below for gnutls support
-GNUTLS := #-lgnutls
+
+# for Linux uncomment out next two lines
+#LIBZWAVE := $(wildcard $(OPENZWAVE)/cpp/lib/linux/*.a)
+#LIBUSB := -ludev
+
# for Mac OS X comment out above 2 lines and uncomment next 2 lines
-#LIBZWAVE := $(wildcard ../open-zwave/cpp/lib/mac/*.a)
-#LIBUSB := -framework IOKit -framework CoreFoundation
-LIBS := $(LIBZWAVE) $(GNUTLS) ../libmicrohttpd/src/daemon/.libs/libmicrohttpd.a -pthread $(LIBUSB)
+LIBZWAVE := $(wildcard $(OPENZWAVE)/cpp/lib/mac/*.a)
+LIBUSB := -framework IOKit -framework CoreFoundation
+
+LIBS := $(LIBZWAVE) $(GNUTLS) $(LIBMICROHTTPD) -pthread $(LIBUSB)
%.o : %.cpp
$(CXX) $(CFLAGS) $(INCLUDES) -o $@ $<
@@ -44,13 +50,13 @@ LIBS := $(LIBZWAVE) $(GNUTLS) ../libmicrohttpd/src/daemon/.libs/libmicrohttpd.a
all: ozwcp
-ozwcp.o: ozwcp.h webserver.h ../open-zwave/cpp/src/Options.h ../open-zwave/cpp/src/Manager.h \
- ../open-zwave/cpp/src/Node.h ../open-zwave/cpp/src/Group.h \
- ../open-zwave/cpp/src/Notification.h ../open-zwave/cpp/src/platform/Log.h
+ozwcp.o: ozwcp.h webserver.h $(OPENZWAVE)/cpp/src/Options.h $(OPENZWAVE)/cpp/src/Manager.h \
+ $(OPENZWAVE)/cpp/src/Node.h $(OPENZWAVE)/cpp/src/Group.h \
+ $(OPENZWAVE)/cpp/src/Notification.h $(OPENZWAVE)/cpp/src/platform/Log.h
-webserver.o: webserver.h ozwcp.h ../open-zwave/cpp/src/Options.h ../open-zwave/cpp/src/Manager.h \
- ../open-zwave/cpp/src/Node.h ../open-zwave/cpp/src/Group.h \
- ../open-zwave/cpp/src/Notification.h ../open-zwave/cpp/src/platform/Log.h
+webserver.o: webserver.h ozwcp.h $(OPENZWAVE)/cpp/src/Options.h $(OPENZWAVE)/cpp/src/Manager.h \
+ $(OPENZWAVE)/cpp/src/Node.h $(OPENZWAVE)/cpp/src/Group.h \
+ $(OPENZWAVE)/cpp/src/Notification.h $(OPENZWAVE)/cpp/src/platform/Log.h
ozwcp: ozwcp.o webserver.o zwavelib.o
$(LD) -o $@ $(LDFLAGS) ozwcp.o webserver.o zwavelib.o $(LIBS)
@@ -58,3 +64,6 @@ ozwcp: ozwcp.o webserver.o zwavelib.o
dist: ozwcp
rm -f ozwcp.tar.gz
tar -c --exclude=".svn" -hvzf ozwcp.tar.gz ozwcp config/ cp.html cp.js openzwavetinyicon.png README
+
+clean:
+ rm -f ozwcp *.o
diff --git a/cp.html b/cp.html
index 45bec17..a7f920d 100644
--- a/cp.html
+++ b/cp.html
@@ -227,11 +227,32 @@
</div>
<div id="topocntl" name="topocntl" class="rsb" style="display: none; margin-right: 10px;">
<div class="rsb" style="margin-left: 10px;">
- <button id="refreshtopo" name="refreshtopo" onclick="return RefreshTopo();" type="submit">Refresh</button>
+ <button id="refreshtopo" name="refreshtopo" onclick="return TopoLoad('load');" type="submit">Refresh</button>
</div>
</div>
<div class="rsb" style="margin-left: 10px;">
- <span id="netinfo" name="netinfo" class="admmsg"></span>
+ <span id="netinfo" name="netinfo" class="admmsg" style="display: none;"></span>
+ </div>
+ <br>
+ <div id="topo" style="float: left; width: 65%; display: none;"><br><br>
+ <table border="0" cellpadding="1" cellspacing="0" style="text-align: center;">
+ <thead id="topohead">
+ <tr>
+ <th> </th>
+ <th> </th>
+ </tr>
+ </thead>
+ <tbody id="topobody">
+ <tr>
+ <td> </td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td> </td>
+ </tr>
+ </tbody>
+ </table>
</div>
</form>
</fieldset>
diff --git a/cp.js b/cp.js
index d8ef792..f9973de 100644
--- a/cp.js
+++ b/cp.js
@@ -1,5 +1,6 @@
var pollhttp;
var scenehttp;
+var topohttp;
var polltmr=null;
var pollwait=null;
var divcur=new Array();
@@ -32,6 +33,7 @@ var ie=document.all ? true : false;
var curnode=null;
var curscene=null;
var scenes=new Array();
+var routes=new Array();
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
pollhttp=new XMLHttpRequest();
} else {
@@ -42,6 +44,11 @@ if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
} else {
scenehttp=new ActiveXObject("Microsoft.XMLHTTP");
}
+if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
+ topohttp=new XMLHttpRequest();
+} else {
+ topohttp=new ActiveXObject("Microsoft.XMLHTTP");
+}
function SaveNode(newid)
{
var i=newid.substr(4);
@@ -141,10 +148,20 @@ function PollReply()
ainfo.style.display = 'block';
}
elem = xml.getElementsByTagName('update');
- if (elem.length > 0 && elem[0].getAttribute('update') == 'true')
- nodes = new Array;
+ if (elem.length > 0) {
+ var remove = elem[0].getAttribute('remove');
+ if (remove != undefined) {
+ console.log('remove='+remove);
+ var remnodes = remove.split(',');
+ console.log('remnodes len='+remnodes.length);
+ changed = true;
+ for (var i = 0; i < remnodes.length; i++) {
+ nodes[remnodes[i]] = null;
+ }
+ }
+ }
elem = xml.getElementsByTagName('node');
- changed = elem.length > 0;
+ changed |= elem.length > 0;
for (var i = 0; i < elem.length; i++) {
var id = elem[i].getAttribute('id');
nodes[id] = {time: elem[i].getAttribute('time'), btype: elem[i].getAttribute('btype'),
@@ -207,7 +224,7 @@ function PollReply()
if (changed) {
var stuff = '';
for (var i = 1; i < nodes.length; i++) {
- if (nodes[i] == undefined)
+ if (nodes[i] == null)
continue;
var dt = new Date(nodes[i].time*1000);
var yd = new Date(dt.getDate()-1);
@@ -489,22 +506,27 @@ function DoNetHelp()
var ninfo = document.getElementById('netinfo');
var scencntl = document.getElementById('scencntl');
var topocntl = document.getElementById('topocntl');
+ var topo = document.getElementById('topo');
if (document.NetPost.netops.value == 'scen') {
ninfo.innerHTML = 'Scene management and execution.';
ninfo.style.display = 'block';
scencntl.style.display = 'block';
topocntl.style.display = 'none';
+ topo.style.display = 'none';
SceneLoad('load');
} else if (document.NetPost.netops.value == 'topo') {
ninfo.innerHTML = 'Topology views';
ninfo.style.display = 'block';
scencntl.style.display = 'none';
topocntl.style.display = 'block';
+ topo.style.display = 'block';
curscene = null;
+ TopoLoad('load');
} else {
ninfo.style.display = 'none';
scencntl.style.display = 'none';
topocntl.style.display = 'none';
+ topo.style.display = 'none';
curscene = null;
}
return true;
@@ -591,7 +613,7 @@ function DoAdmHelp()
ainfo.style.display = 'block';
ainfo.innerHTML = 'Update the controller with network information from the SUC/SIS.';
} else if (document.AdmPost.adminops.value == 'reqnnu') {
- ainfo.innerHTML = 'Get a node to rebuild it\'s neighbour list.';
+ ainfo.innerHTML = 'Get a node to rebuild its neighbour list.';
ainfo.style.display = 'block';
} else if (document.AdmPost.adminops.value == 'assrr') {
ainfo.innerHTML = 'Assign a network return route to a device.';
@@ -871,7 +893,6 @@ function SceneLoad(fun)
params=params+'&id='+curscene+'&vid='+vals[0]+'-'+vals[1]+'-'+vals[2]+'-'+vals[3]+'-'+vals[4]+'-'+vals[5];
DisplaySceneSceneValue(null);
}
- console.log('SceneLoad '+params);
scenehttp.open('POST','scenepost.html',false);
scenehttp.onreadystatechange = SceneReply;
scenehttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
@@ -1045,10 +1066,69 @@ function DisplaySceneSceneValue(opt)
vu.innerHTML = scenes[curscene].values[j].units;
return false;
}
-function RefreshTopo()
+function TopoLoad(fun)
{
+ var params='fun='+fun;
+ topohttp.open('POST','topopost.html',false);
+ topohttp.onreadystatechange = TopoReply;
+ topohttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ topohttp.setRequestHeader("Content-length", params.length);
+ topohttp.setRequestHeader("Connection", "close");
+ topohttp.send(params);
+
return false;
}
+function TopoReply()
+{
+ var xml;
+ var elem;
+
+ if (topohttp.readyState == 4 && topohttp.status == 200) {
+ xml = topohttp.responseXML;
+ elem = xml.getElementsByTagName('topo');
+ if (elem.length > 0) {
+ var i;
+ var id;
+ var list;
+ for (i = 0; i < elem[0].childNodes.length; i++) {
+ if (elem[0].childNodes[i].nodeType != 1)
+ continue;
+ if (elem[0].childNodes[i].tagName == 'node') {
+ id = elem[0].childNodes[i].getAttribute('id');
+ list = elem[0].childNodes[i].firstChild.nodeValue;
+ routes[id] = list.split(',');
+ }
+ }
+ var stuff = '<tr><th>Nodes</th>';
+ var topohead = document.getElementById('topohead');
+ for (i = 1; i < routes.length; i++) {
+ if (routes[i] == undefined)
+ routes[i]=new Array();
+ stuff=stuff+'<th>'+i+'</th>';
+ }
+ stuff=stuff+'</tr>'
+ topohead.innerHTML = stuff;
+ stuff = '';
+ for (i = 1; i < routes.length; i++) {
+ stuff=stuff+'<tr><td style="vertical-align: top; text-decoration: underline; background-color: #FFFFFF;">'+i+'</td>';
+ var j, k = 0;
+ for (j = 1; j < routes.length; j++) {
+ if (i == j) {
+ stuff=stuff+'<td>*</td>';
+ } else if (k < routes[i].length && j == routes[i][k]) {
+ stuff=stuff+'<td>*</td>';
+ k++;
+ } else {
+ stuff=stuff+'<td> </td>';
+ }
+ }
+ stuff=stuff+'</tr>';
+ }
+ var topobody = document.getElementById('topobody');
+ topobody.innerHTML = stuff;
+ }
+ }
+}
function quotestring(s)
{
return s.replace(/\'/g, "");
diff --git a/ozwcp.cpp b/ozwcp.cpp
index 7f9257a..9bfdce8 100644
--- a/ozwcp.cpp
+++ b/ozwcp.cpp
@@ -66,10 +66,10 @@ bool done = false;
bool needsave = false;
uint32 homeId = 0;
uint8 nodeId = 0;
-char *cmode = "";
+const char *cmode = "";
int32 debug = false;
bool MyNode::nodechanged = false;
-bool MyNode::allchanged = false;
+list<uint8> MyNode::removed;
/*
* MyNode::MyNode constructor
@@ -118,10 +118,10 @@ void MyNode::remove (int32 const ind)
return;
}
if (nodes[ind] != NULL) {
+ addRemoved(ind);
delete nodes[ind];
nodes[ind] = NULL;
nodecount--;
- setAllChanged(true);
}
}
@@ -321,7 +321,7 @@ MyValue *MyNode::lookup (string data)
uint8 ind;
ValueID::ValueGenre vg;
ValueID::ValueType typ;
- uint32 pos1, pos2;
+ size_t pos1, pos2;
string str;
node = strtol(data.c_str(), NULL, 10);
@@ -379,13 +379,27 @@ int32 MyNode::getValueCount ()
/*
* Returns an n'th value
*/
-MyValue *MyNode::getValue (int n)
+MyValue *MyNode::getValue (uint8 n)
{
if (n < values.size())
return values[n];
return NULL;
}
+/*
+ * Returns next item on the removed list.
+ */
+
+uint8 MyNode::getRemoved()
+{
+ if (removed.size() > 0) {
+ uint8 node = removed.front();
+ removed.pop_front();
+ return node;
+ }
+ return 0;
+}
+
//-----------------------------------------------------------------------------
// <OnNotification>
// Callback that is triggered when a value, group or node changes
diff --git a/ozwcp.h b/ozwcp.h
index cd6c33b..f785923 100644
--- a/ozwcp.h
+++ b/ozwcp.h
@@ -50,12 +50,12 @@ using namespace OpenZWave;
#define MAX_NODES 255
-extern char *valueGenreStr(ValueID::ValueGenre);
+extern const char *valueGenreStr(ValueID::ValueGenre);
extern ValueID::ValueGenre valueGenreNum(char const *);
-extern char *valueTypeStr(ValueID::ValueType);
+extern const char *valueTypeStr(ValueID::ValueType);
extern ValueID::ValueType valueTypeNum(char const *);
-extern char *nodeBasicStr (uint8);
-extern char *cclassStr(uint8);
+extern const char *nodeBasicStr (uint8);
+extern const char *cclassStr(uint8);
extern uint8 cclassNum(char const *str);
class MyValue {
@@ -86,15 +86,16 @@ public:
void saveValue(ValueID id);
int32 getValueCount();
static MyValue *lookup(string id);
- MyValue *getValue(int n);
+ MyValue *getValue(uint8 n);
uint32 getTime() { return mtime; }
void setTime(uint32 t) { mtime = t; }
static bool getAnyChanged() { return nodechanged; }
static void setAnyChanged(bool ch) { nodechanged = ch; }
- static bool getAllChanged() { return allchanged; }
- static void setAllChanged(bool ch) { allchanged = ch; }
bool getChanged() { return changed; }
void setChanged(bool ch) { changed = ch; nodechanged = ch; }
+ static void addRemoved(uint8 node) { removed.push_back(node); }
+ static uint32 getRemovedCount() { return removed.size(); }
+ static uint8 getRemoved();
void addGroup(uint8 node, uint8 g, uint8 n, uint8 *v);
MyGroup *getGroup(uint8 i);
void updateGroup(uint8 node, uint8 grp, char *glist);
@@ -108,7 +109,7 @@ private:
uint32 mtime;
bool changed;
static bool nodechanged;
- static bool allchanged;
+ static list<uint8> removed;
vector <MyGroup*> groups;
vector<MyValue*> values;
};
diff --git a/webserver.cpp b/webserver.cpp
index f363221..602ae83 100644
--- a/webserver.cpp
+++ b/webserver.cpp
@@ -145,7 +145,7 @@ int web_send_file (struct MHD_Connection *conn, const char *filename, const int
FILE *fp;
struct MHD_Response *response;
const char *p;
- char *ct = NULL;
+ const char *ct = NULL;
int ret;
if ((p = strchr(filename, '.')) != NULL) {
@@ -203,7 +203,7 @@ void Webserver::web_get_groups (int n, TiXmlElement *ep)
groupElement->SetAttribute("max", p->max);
groupElement->SetAttribute("label", p->label.c_str());
string str = "";
- for (int j = 0; j < p->grouplist.size(); j++) {
+ for (uint j = 0; j < p->grouplist.size(); j++) {
char s[12];
snprintf(s, sizeof(s), "%d", p->grouplist[j]);
str += s;
@@ -273,12 +273,67 @@ void Webserver::web_get_values (int i, TiXmlElement *ep)
}
/*
+ * SendTopoResponse
+ * Process topology request and return appropiate data
+ */
+
+const char *Webserver::SendTopoResponse (struct MHD_Connection *conn, const char *fun,
+ const char *arg1, const char *arg2, const char *arg3)
+{
+ TiXmlDocument doc;
+ char str[16];
+ string s;
+ static char fntemp[32];
+ char *fn;
+ uint i, j;
+ uint8 cnt;
+ uint32 len;
+ uint8 *neighbors;
+ TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "utf-8", "" );
+ doc.LinkEndChild(decl);
+ TiXmlElement* topoElement = new TiXmlElement("topo");
+ doc.LinkEndChild(topoElement);
+
+ if (strcmp(fun, "load") == 0) {
+ cnt = MyNode::getNodeCount();
+ for (i = 0; i < cnt; i++) {
+ len = Manager::Get()->GetNodeNeighbors(homeId, i+1, &neighbors);
+ if (len > 0) {
+ TiXmlElement* nodeElement = new TiXmlElement("node");
+ snprintf(str, sizeof(str), "%d", i+1);
+ nodeElement->SetAttribute("id", str);
+ string list = "";
+ for (j = 0; j < len; j++) {
+ snprintf(str, sizeof(str), "%d", neighbors[j]);
+ list += str;
+ if (j < (len - 1))
+ list += ",";
+ }
+ TiXmlText *textElement = new TiXmlText(list.c_str());
+ nodeElement->LinkEndChild(textElement);
+ topoElement->LinkEndChild(nodeElement);
+ }
+ delete [] neighbors;
+ }
+ }
+ strncpy(fntemp, "/tmp/ozwcp.scenes.XXXXXX", sizeof(fntemp));
+ fn = mktemp(fntemp);
+ if (fn == NULL)
+ return EMPTY;
+ strncat(fntemp, ".xml", sizeof(fntemp));
+ if (debug)
+ doc.Print(stdout, 0);
+ doc.SaveFile(fn);
+ return fn;
+}
+
+/*
* SendSceneResponse
* Process scene request and return appropiate scene data
*/
-char *Webserver::SendSceneResponse (struct MHD_Connection *conn, const char *fun,
- const char *arg1, const char *arg2, const char *arg3)
+const char *Webserver::SendSceneResponse (struct MHD_Connection *conn, const char *fun,
+ const char *arg1, const char *arg2, const char *arg3)
{
TiXmlDocument doc;
char str[16];
@@ -456,14 +511,26 @@ int Webserver::SendPollResponse (struct MHD_Connection *conn)
TiXmlElement* updateElement = new TiXmlElement("update");
pollElement->LinkEndChild(updateElement);
- updateElement->SetAttribute("full", MyNode::getAllChanged() ? "true" : "false");
+ i = MyNode::getRemovedCount();
+ if (i > 0) {
+ logbuffer[0] = '\0';
+ while (i > 0) {
+ uint8 node = MyNode::getRemoved();
+ snprintf(str, sizeof(str), "%d", node);
+ strcat(logbuffer, str);
+ i = MyNode::getRemovedCount();
+ if (i > 0)
+ strcat(logbuffer, ",");
+ }
+ updateElement->SetAttribute("remove", logbuffer);
+ }
pthread_mutex_lock(&nlock);
- if (MyNode::getAnyChanged() || MyNode::getAllChanged()) {
+ if (MyNode::getAnyChanged()) {
i = 0;
j = 1;
while (j <= MyNode::getNodeCount() && i < MAX_NODES) {
- if (nodes[i] != NULL && (MyNode::getAllChanged() || nodes[i]->getChanged())) {
+ if (nodes[i] != NULL && nodes[i]->getChanged()) {
TiXmlElement* nodeElement = new TiXmlElement("node");
pollElement->LinkEndChild(nodeElement);
nodeElement->SetAttribute("id", i);
@@ -483,7 +550,6 @@ int Webserver::SendPollResponse (struct MHD_Connection *conn)
}
i++;
}
- MyNode::setAllChanged(false);
}
pthread_mutex_unlock(&nlock);
strncpy(fntemp, "/tmp/ozwcp.poll.XXXXXX", sizeof(fntemp));
@@ -608,6 +674,9 @@ int web_config_post (void *cls, enum MHD_ValueKind kind, const char *key, const
cp->conn_arg3 = (void *)strdup(data);
else if (strcmp(key, "value") == 0)
cp->conn_arg4 = (void *)strdup(data);
+ } else if (strcmp(cp->conn_url, "/topopost.html") == 0) {
+ if (strcmp(key, "fun") == 0)
+ cp->conn_arg1 = (void *)strdup(data);
}
return MHD_YES;
}
@@ -773,7 +842,14 @@ int Webserver::Handler (struct MHD_Connection *conn, const char *url,
cp->conn_res = (void *)SendSceneResponse(conn, (char *)cp->conn_arg1, (char *)cp->conn_arg2, (char *)cp->conn_arg3, (char *)cp->conn_arg4);
} else
ret = web_send_file(conn, (char *)cp->conn_res, MHD_HTTP_OK, true);
-// ret = web_send_data(conn, EMPTY, MHD_HTTP_OK, false, false, NULL); // no free, no copy
+ } else if (strcmp(url, "/topopost.html") == 0) {
+ if (*up_data_size != 0) {
+ MHD_post_process(cp->conn_pp, up_data, *up_data_size);
+ *up_data_size = 0;
+
+ cp->conn_res = (void *)SendTopoResponse(conn, (char *)cp->conn_arg1, (char *)cp->conn_arg2, (char *)cp->conn_arg3, (char *)cp->conn_arg4);
+ } else
+ ret = web_send_file(conn, (char *)cp->conn_res, MHD_HTTP_OK, true);
} else if (strcmp(url, "/admpost.html") == 0) {
if (*up_data_size != 0) {
MHD_post_process(cp->conn_pp, up_data, *up_data_size);
@@ -820,7 +896,7 @@ int Webserver::Handler (struct MHD_Connection *conn, const char *url,
web_controller_update, this, true));
} else if (strcmp((char *)cp->conn_arg1, "hnf") == 0) {
if (cp->conn_arg2 != NULL && strlen((char *)cp->conn_arg2) > 4) {
- uint8 node = strtol(((char *)cp->conn_arg2) + 4, NULL, 10) + 1;
+ uint8 node = strtol(((char *)cp->conn_arg2) + 4, NULL, 10);
setAdminFunction("Has Node Failed");
setAdminState(
Manager::Get()->BeginControllerCommand(homeId,
@@ -829,7 +905,7 @@ int Webserver::Handler (struct MHD_Connection *conn, const char *url,
}
} else if (strcmp((char *)cp->conn_arg1, "remfn") == 0) {
if (cp->conn_arg2 != NULL && strlen((char *)cp->conn_arg2) > 4) {
- uint8 node = strtol(((char *)cp->conn_arg2) + 4, NULL, 10) + 1;
+ uint8 node = strtol(((char *)cp->conn_arg2) + 4, NULL, 10);
setAdminFunction("Remove Failed Node");
setAdminState(
Manager::Get()->BeginControllerCommand(homeId,
@@ -838,7 +914,7 @@ int Webserver::Handler (struct MHD_Connection *conn, const char *url,
}
} else if (strcmp((char *)cp->conn_arg1, "repfn") == 0) {
if (cp->conn_arg2 != NULL && strlen((char *)cp->conn_arg2) > 4) {
- uint8 node = strtol(((char *)cp->conn_arg2) + 4, NULL, 10) + 1;
+ uint8 node = strtol(((char *)cp->conn_arg2) + 4, NULL, 10);
setAdminFunction("Replace Failed Node");
setAdminState(
Manager::Get()->BeginControllerCommand(homeId,
@@ -853,7 +929,7 @@ int Webserver::Handler (struct MHD_Connection *conn, const char *url,
web_controller_update, this, true));
} else if (strcmp((char *)cp->conn_arg1, "reqnu") == 0) {
if (cp->conn_arg2 != NULL && strlen((char *)cp->conn_arg2) > 4) {
- uint8 node = strtol(((char *)cp->conn_arg2) + 4, NULL, 10) + 1;
+ uint8 node = strtol(((char *)cp->conn_arg2) + 4, NULL, 10);
setAdminFunction("Request Network Update");
setAdminState(
Manager::Get()->BeginControllerCommand(homeId,
@@ -862,7 +938,7 @@ int Webserver::Handler (struct MHD_Connection *conn, const char *url,
}
} else if (strcmp((char *)cp->conn_arg1, "reqnnu") == 0) {
if (cp->conn_arg2 != NULL && strlen((char *)cp->conn_arg2) > 4) {
- uint8 node = strtol(((char *)cp->conn_arg2) + 4, NULL, 10) + 1;
+ uint8 node = strtol(((char *)cp->conn_arg2) + 4, NULL, 10);
setAdminFunction("Request Node Neighbor Update");
setAdminState(
Manager::Get()->BeginControllerCommand(homeId,
@@ -871,7 +947,7 @@ int Webserver::Handler (struct MHD_Connection *conn, const char *url,
}
} else if (strcmp((char *)cp->conn_arg1, "assrr") == 0) {
if (cp->conn_arg2 != NULL && strlen((char *)cp->conn_arg2) > 4) {
- uint8 node = strtol(((char *)cp->conn_arg2) + 4, NULL, 10) + 1;
+ uint8 node = strtol(((char *)cp->conn_arg2) + 4, NULL, 10);
setAdminFunction("Assign Return Route");
setAdminState(
Manager::Get()->BeginControllerCommand(homeId,
@@ -880,7 +956,7 @@ int Webserver::Handler (struct MHD_Connection *conn, const char *url,
}
} else if (strcmp((char *)cp->conn_arg1, "delarr") == 0) {
if (cp->conn_arg2 != NULL && strlen((char *)cp->conn_arg2) > 4) {
- uint8 node = strtol(((char *)cp->conn_arg2) + 4, NULL, 10) + 1;
+ uint8 node = strtol(((char *)cp->conn_arg2) + 4, NULL, 10);
setAdminFunction("Delete All Return Routes");
setAdminState(
Manager::Get()->BeginControllerCommand(homeId,
@@ -1011,7 +1087,7 @@ void Webserver::Free (struct MHD_Connection *conn, void **ptr, enum MHD_RequestT
* Start up the web server
*/
-Webserver::Webserver (int const wport) : logbytes(0), adminstate(false), sortcol(COL_NODE)
+Webserver::Webserver (int const wport) : sortcol(COL_NODE), logbytes(0), adminstate(false)
{
fprintf(stderr, "webserver starting port %d\n", wport);
port = wport;
diff --git a/webserver.h b/webserver.h
index 084228d..9050417 100644
--- a/webserver.h
+++ b/webserver.h
@@ -58,7 +58,8 @@ private:
void web_get_groups(int i, TiXmlElement *ep);
void web_get_values(int i, TiXmlElement *ep);
int SendPollResponse(struct MHD_Connection *conn);
- char *SendSceneResponse(struct MHD_Connection *conn, const char *fun, const char *arg1, const char *arg2, const char *arg3);
+ const char *SendSceneResponse(struct MHD_Connection *conn, const char *fun, const char *arg1, const char *arg2, const char *arg3);
+ const char *SendTopoResponse(struct MHD_Connection *conn, const char *fun, const char *arg1, const char *arg2, const char *arg3);
static bool usb;
static char *devname;
diff --git a/zwavelib.cpp b/zwavelib.cpp
index 72b3c89..b6e4ac7 100644
--- a/zwavelib.cpp
+++ b/zwavelib.cpp
@@ -37,7 +37,7 @@
#include <string.h>
#include "ozwcp.h"
-char *valueGenreStr (ValueID::ValueGenre vg)
+const char *valueGenreStr (ValueID::ValueGenre vg)
{
switch (vg) {
case ValueID::ValueGenre_Basic:
@@ -70,7 +70,7 @@ ValueID::ValueGenre valueGenreNum (char const *str)
return (ValueID::ValueGenre)255;
}
-char *valueTypeStr (ValueID::ValueType vt)
+const char *valueTypeStr (ValueID::ValueType vt)
{
switch (vt) {
case ValueID::ValueType_Bool:
@@ -119,7 +119,7 @@ ValueID::ValueType valueTypeNum (char const *str)
return (ValueID::ValueType)255;
}
-char *nodeBasicStr (uint8 basic)
+const char *nodeBasicStr (uint8 basic)
{
switch (basic) {
case 1:
@@ -134,7 +134,7 @@ char *nodeBasicStr (uint8 basic)
return "unknown";
}
-char *cclassStr (uint8 cc)
+const char *cclassStr (uint8 cc)
{
switch (cc) {
default:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-iot/openzwave-controlpanel.git
More information about the Debian-iot-packaging
mailing list