Post by earlthesquirrel on May 28, 2015 6:56:05 GMT -8
Howdy,
I've been trying to work on what I expected to be a simple JSON service using the
ArduinoConnect Server but can't quite figure out the last bit of the details/wiring
I need. (I don't want to use the RAW interface, I would like to have a simple JSON
configuration)
So far I have :
1) Have the ArduinoConnect Server up and running on the Arduino (it's a Mega). I can hit
the URL and get the EPIC FAIL web page back.
2) I've puzzled out what the REST JSON request should look like :
{"OBJECTTYPE" : "1", "OBJECTID" : "3000", "OBJECTSERVERID" : "W-1",
"PASSWORD" : "RasPiConnectPassword", "OBJECTFLAGS" : "0",
"ARDUINOCONNECTVSERVERVERSIONNUMBER" : "1.6" }
3) I am not sure what should be passed in ObjectType, ObjectId and ObjectServerId.
I have been working from some examples provided by SwitchDoc labs and believe I have
a good start at a Local.h (and believe the Config.h is correct, given 1)
4) I've sometimes gotten EPIC FAIL results, sometimes "Username or Password Mismatch"
when sending the payload in #2. That I don't understand.
5) I don't see an example anywhere of how I'd bind the rest of the pieces together, and
what could be wrong RE: Password. I've verified that the value I have been providing
matches exactly what's in the Config.h file.
Local.h wise, I've got the code at the bottom in there.
So, questions :
1) Hints on the Password issue? I don't know where I should be looking..
2) Based on the code, what else have I been boneheaded about and got wrong...I'm open
for comments, suggestions.
3) How do I get the proper values to pass in the Json? I've looked at the site, but
don't see exactly where/what do do to wire this last bit together.
THANKS in advance for any assistance.
Earl
===========Local.h==============
// prototype - We're only using a single control for now...
void ExecuteLocalREMOTE_WEBVIEW_UITYPE(char returnJSON[], char *buffer, currentObjectStructure *parsedObject);
void Local(char returnJSON[], char *buffer, currentObjectStructure *parsedObject)
{
#ifdef LOCALDEBUG
printObject(parsedObject, "In Local.h");
#endif
switch (atol(parsedObject->ObjectType))
{
case WEBVIEW_CONTROL_UITYPE:
{
ExecuteLocalWEBVIEW_CONTROL_UITYPE(returnJSON, returnJSON, parsedObject);
}
break;
}
}
// Local Execute files
void ExecuteLocalREMOTE_WEBVIEW_UITYPE(char returnJSON[], char *buffer, currentObjectStructure *parsedObject)
{
#ifdef LOCALDEBUG
Serial.println("ExecuteREMOTE_WEBVIEW_UITYPE");
#endif
if (strcmp(parsedObject->ObjectServerID, "W-1") == 0)
{
if (strcmp(parsedObject->Validate, "YES") == 0)
{
// send validated response
returnJSONValidateResponse(returnJSON, returnJSON, parsedObject);
strcpy(returnJSON, buffer);
return;
}
returnJSONResponse(returnJSON, returnJSON, parsedObject, "OK Earl" );
strcpy(returnJSON, buffer);
return;
}
// Note that Local objects DO NOT RETURN an Invalid Response. That is done by the ExecuteJSONCommand function
// returnJSONInValidResponse(returnJSON, returnJSON, parsedObject);
}
I've been trying to work on what I expected to be a simple JSON service using the
ArduinoConnect Server but can't quite figure out the last bit of the details/wiring
I need. (I don't want to use the RAW interface, I would like to have a simple JSON
configuration)
So far I have :
1) Have the ArduinoConnect Server up and running on the Arduino (it's a Mega). I can hit
the URL and get the EPIC FAIL web page back.
2) I've puzzled out what the REST JSON request should look like :
{"OBJECTTYPE" : "1", "OBJECTID" : "3000", "OBJECTSERVERID" : "W-1",
"PASSWORD" : "RasPiConnectPassword", "OBJECTFLAGS" : "0",
"ARDUINOCONNECTVSERVERVERSIONNUMBER" : "1.6" }
3) I am not sure what should be passed in ObjectType, ObjectId and ObjectServerId.
I have been working from some examples provided by SwitchDoc labs and believe I have
a good start at a Local.h (and believe the Config.h is correct, given 1)
4) I've sometimes gotten EPIC FAIL results, sometimes "Username or Password Mismatch"
when sending the payload in #2. That I don't understand.
5) I don't see an example anywhere of how I'd bind the rest of the pieces together, and
what could be wrong RE: Password. I've verified that the value I have been providing
matches exactly what's in the Config.h file.
Local.h wise, I've got the code at the bottom in there.
So, questions :
1) Hints on the Password issue? I don't know where I should be looking..
2) Based on the code, what else have I been boneheaded about and got wrong...I'm open
for comments, suggestions.
3) How do I get the proper values to pass in the Json? I've looked at the site, but
don't see exactly where/what do do to wire this last bit together.
THANKS in advance for any assistance.
Earl
===========Local.h==============
// prototype - We're only using a single control for now...
void ExecuteLocalREMOTE_WEBVIEW_UITYPE(char returnJSON[], char *buffer, currentObjectStructure *parsedObject);
void Local(char returnJSON[], char *buffer, currentObjectStructure *parsedObject)
{
#ifdef LOCALDEBUG
printObject(parsedObject, "In Local.h");
#endif
switch (atol(parsedObject->ObjectType))
{
case WEBVIEW_CONTROL_UITYPE:
{
ExecuteLocalWEBVIEW_CONTROL_UITYPE(returnJSON, returnJSON, parsedObject);
}
break;
}
}
// Local Execute files
void ExecuteLocalREMOTE_WEBVIEW_UITYPE(char returnJSON[], char *buffer, currentObjectStructure *parsedObject)
{
#ifdef LOCALDEBUG
Serial.println("ExecuteREMOTE_WEBVIEW_UITYPE");
#endif
if (strcmp(parsedObject->ObjectServerID, "W-1") == 0)
{
if (strcmp(parsedObject->Validate, "YES") == 0)
{
// send validated response
returnJSONValidateResponse(returnJSON, returnJSON, parsedObject);
strcpy(returnJSON, buffer);
return;
}
returnJSONResponse(returnJSON, returnJSON, parsedObject, "OK Earl" );
strcpy(returnJSON, buffer);
return;
}
// Note that Local objects DO NOT RETURN an Invalid Response. That is done by the ExecuteJSONCommand function
// returnJSONInValidResponse(returnJSON, returnJSON, parsedObject);
}