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?

5
  • 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. Commented Nov 24, 2015 at 14:50
  • @fabrosell i tried doing that also but still there was problem.Can you suggest any othing thing which might solve issue. Commented Nov 25, 2015 at 11:26
  • If you have any working code which continuously able to push data to Parse.com,can you share that ? Commented Nov 26, 2015 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... Commented Nov 27, 2015 at 12:58
  • At what point in the code does the program flow "get blocked"? Commented Sep 16, 2018 at 23:42

1 Answer 1

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());
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.