11

I have created a cloud function using the Parse.com Javascript SDK and I am calling those functions from Arduino. Following is code for the hello function:

Parse.Cloud.define("hello", function(request, response) {
                response.success("This is hello function");         
}); //hello function Block

I am calling this function from the Arduino side using the following code:

void setup() {
  Bridge.begin();
  Serial.begin(9600);

  while (!Serial);

  Parse.begin("***zE0uUjQkMa7nj5D5BALvzegzfyVNSG22BD***", "***Ssggp5JgMFmSHfloewW5oixlM5ibt9LBSE***");
  //commented my keys with * here only

  // In this example, we associate this device with a pre-generated installation
  Parse.getInstallationId();
  Parse.startPushService();
}


void loop() {
  Serial.println("Start loop");
  demoBasic("meeting", 0);
}

void demoBasic(String functionname, int light) {
  char fnname[11];
  functionname.toCharArray(fnname, 11);

  Serial.print("In ");
  Serial.print(functionname);
  Serial.println(" Function");


  ParseCloudFunction cloudFunction;
  cloudFunction.setFunctionName(fnname);
  cloudFunction.add("light_sensor", light);
  cloudFunction.add("value", "Arduino Hello");//parameters

  ParseResponse response = cloudFunction.send();
  Serial.println(response.getJSONBody());
}

Problem is that I am getting response 8 times only. After that whole program flow gets blocked. What is the problem?

  • Not sure what your problem is, but I'd try a "delay" in loop after the call to demoBasic. I'd start with 100 ms. Maybe your code execute "too fast" then the js function gets blocked. – fabrosell Nov 24 '15 at 14:50
  • @fabrosell i tried doing that also but still there was problem.Can you suggest any othing thing which might solve issue. – Abhijeet Kulkarni Nov 25 '15 at 11:26
  • If you have any working code which continuously able to push data to Parse.com,can you share that ? – Abhijeet Kulkarni Nov 26 '15 at 11:40
  • I'm sorry, I do not have any. Either way, it's a very strange behavior if function gets called just 8 times and no more... – fabrosell Nov 27 '15 at 12:58
  • At what point in the code does the program flow "get blocked"? – Kingsley Sep 16 '18 at 23:42
1

Give this a shot, I really hate String, maybe that 8-times thing has to do with memory issues caused by it.

void loop() {

  char functionToCall[8] = "meeting";
  Serial.println("Start loop");
  demoBasicCharArray(functionToCall, 0);
}


void demoBasicCharArray(char *functionname, int light) {

  Serial.print("In ");
  for (byte i=0;i<sizeof(functionname);i++){
    Serial.print(functionname[i]);
  }
  Serial.println(" Function");

  ParseCloudFunction cloudFunction;
  cloudFunction.setFunctionName(functionname);
  cloudFunction.add("light_sensor", light);
  cloudFunction.add("value", "Arduino Hello");//parameters

  ParseResponse response = cloudFunction.send();
  Serial.println(response.getJSONBody());
}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.