YUN reading/getting REST values


hi,

i have 2 yun's , them communicate each other via rest:

here catch: i want second yun get/fetch value of temperature sensor first yun. don not want fist yun initiate transaction, must initiated second yun

i believe the  coding of first yun more or less standard followed above mentioned example - through browser can get/fetch value of temperature sensor

my question relates programing of second yun , how program get/fetch data first yun. how go doing ?

the best solution can think of using process.h library , execute curl command get/fetch data first yun. missing ? there better method of getting/fetching data ?

thanks
gregg


this have come with:
code: [select]

#include <bridge.h>
#include <process.h>
#include <console.h>

void setup() {
   serial.begin(9600);
 
   // bridge startup
   pinmode(13,output);
   digitalwrite(13, low);
   bridge.begin();
   digitalwrite(13, high);
 
   console.begin();
 
   while (!console){
       ; // wait console port connect.
   }
   
   console.println("console connected"); console.println("");
   digitalwrite(13, low);

}

void loop() {
   char result;
   string rest_temp;
   console.println("getting rest information...");
 
   process temp;
   temp.runshellcommand("curl http://x.x.x.x/arduino/rest_test");
   while(temp.running());
   console.print("receiving data... ");
 
   while (temp.available()>0) {
      char result = temp.read();
      console.print(result);
      rest_temp = rest_temp + result;
   }
 
   console.println("");
   console.print("temperature via rest: ");
   console.println(rest_temp);
 
   // ensure last bit of data sent.
   serial.flush();

   console.println("done!!!");
   console.println("");
 
   delay(2000); 
}



it works, best method ?


Arduino Forum > Products > Arduino Yún (Moderator: fabioc84) > YUN reading/getting REST values


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support