Пример #1
0
// Call a Temboo Choreo
void runGetTemperature(TembooSession* session) {

  printf("\nRunning GetTemperature\n");

  // Initialize Choreo data structure
  TembooChoreo choreo;
  const char choreoName[] = "/Library/Yahoo/Weather/GetTemperature";
  initChoreo(&choreo, choreoName);

  // Set profile
  const char profileName[] = "newone2";
  setChoreoProfile(&choreo, profileName);

  // Set Choreo inputs
  ChoreoInput AddressIn;
  AddressIn.name = "Address";
  AddressIn.value = "Bakersfield, CA 93304";
  addChoreoInput(&choreo, &AddressIn);

  int returnCode = runChoreo(&choreo, session, CHOREO_TIMEOUT);
  if (returnCode != 0) {
    printf("runChoreo failed.  Error: %d\n", returnCode);
  }

  // Print the response received from Temboo
  while (tembooClientAvailable(session->connectionData)) {
    char name[64];
    char value[64];
    memset(name, 0, sizeof(name));
    memset(value, 0, sizeof(value));

    choreoResultReadStringUntil(session->connectionData, name, sizeof(name), '\x1F');

    if (0 == strcmp(name, "Temperature")) {
      if (choreoResultReadStringUntil(session->connectionData, value, sizeof(value), '\x1E') == -1) {
        printf("Error: char array is not large enough to store the string\n");
      } else {
        if (atoi(value) > 55) {
          digitalWrite(outputPin, LOW);
        }
      }
    }
    else {
      choreoResultFind(session->connectionData, "\x1E");
    }
  }

  // When we're done, close the connection
  tembooClientStop(session->connectionData);
}
  // Initialize Choreo data structure
  TembooChoreo choreo;
  const char choreoName[] = "/Library/RunKeeper/FitnessActivities/RetrieveActivites";
  initChoreo(&choreo, choreoName);

  // Set profile
  const char profileName[] = "monica";
  setChoreoProfile(&choreo, profileName);

  // Set Choreo inputs
  ChoreoInput PageSizeIn;
  PageSizeIn.name = "PageSize";
  PageSizeIn.value = "4";
  addChoreoInput(&choreo, &PageSizeIn);

  int returnCode = runChoreo(&choreo, session, CHOREO_TIMEOUT);
  if (returnCode != 0) {
    printf("runChoreo failed.  Error: %d\n", returnCode);
  }

    // add an output filter to extract the current distance
  ChoreoOutput distanceOut;
  distanceOut.name = "distance";
  distanceOut.xpath = "//items/total_distance";
  distanceOut.variable = "Response";
  addChoreoOutput(&choreo, &distanceOut);

  // add an output filter to extract the date and time of the last report.
  ChoreoOutput dateOut;
  dateOut.name = "date";
  dateOut.xpath = "//items/start_time";