add command, argument evaluation
This commit is contained in:
@ -68,9 +68,42 @@ String MqttConfig::exec(String params) {
|
||||
}
|
||||
} else if (params.startsWith("add ")) {
|
||||
// add an mbus client, params: token address period
|
||||
char paramBuf[64];
|
||||
char *paramPtr;
|
||||
strncpy(paramBuf, params.c_str(), sizeof(paramBuf));
|
||||
paramPtr = paramBuf;
|
||||
char *tokenStr = 0;
|
||||
char *addressStr = 0;
|
||||
char *periodStr = 0;
|
||||
if ((paramPtr != 0) && (*paramPtr != 0)){
|
||||
// command
|
||||
strsep(¶mPtr, " ");
|
||||
}
|
||||
if ((paramPtr != 0) && (*paramPtr != 0)){
|
||||
tokenStr = strsep(¶mPtr, " ");
|
||||
}
|
||||
if ((paramPtr != 0) && (*paramPtr != 0)){
|
||||
addressStr = strsep(¶mPtr, " ");
|
||||
}
|
||||
if ((paramPtr != 0) && (*paramPtr != 0)){
|
||||
periodStr = strsep(¶mPtr, " ");
|
||||
}
|
||||
|
||||
configWrite(CONFIG_DEVICES, sizeof(mc->m_mbusDevTuple), (char*)mc->m_mbusDevTuple);
|
||||
res = "done";
|
||||
if ((tokenStr != 0) && (*tokenStr != 0) &&
|
||||
(addressStr != 0) && (*addressStr != 0) &&
|
||||
(periodStr != 0) && (*periodStr != 0)) {
|
||||
*out << "Token: " << tokenStr << endl;
|
||||
*out << "Address: " << addressStr << endl;
|
||||
*out << "Period: " << periodStr << endl;
|
||||
|
||||
res = "done";
|
||||
} else {
|
||||
*out << "not enough arguments" << endl;
|
||||
res = "failure";
|
||||
}
|
||||
|
||||
|
||||
// configWrite(CONFIG_DEVICES, sizeof(mc->m_mbusDevTuple), (char*)mc->m_mbusDevTuple);
|
||||
} else if (params.startsWith("del ")) {
|
||||
// delete an mbus client, params: index
|
||||
int space = params.indexOf(' ');
|
||||
|
Reference in New Issue
Block a user