Making variable accessible with JSON

(deleted)

Dawiinci:
How can I do this?

Write some code to parse the incoming HTTP request and extract the request parameters using the encoding scheme you’re proposing.

Write some code to perform the requested operation.

Write some code to send the results of the operation back to the client in the format that you’re proposing.

(deleted)

The below code is for a serial setup, but the same process can be used to parse data in a String from a server returning data to the arduino.

//zoomkat 11-12-13 String capture and parsing  
//from serial port input (via serial monitor)
//and print result out serial port
//copy test strings and use ctrl/v to paste in
//serial monitor if desired
// * is used as the data string delimiter
// , is used to delimit individual data 

String readString; //main captured String 
String angle; //data String
String fuel;
String speed1;
String altidude;

int ind1; // , locations
int ind2;
int ind3;
int ind4;

void setup() {
  Serial.begin(9600);
  Serial.println("serial delimit test 11-12-13"); // so I can keep track of what is loaded
}

void loop() {

  //expect a string like 90,low,15.6,125*
  //or 130,hi,7.2,389*

  if (Serial.available())  {
    char c = Serial.read();  //gets one byte from serial buffer
    if (c == '*') {
      //do stuff
      
      Serial.println();
      Serial.print("captured String is : "); 
      Serial.println(readString); //prints string to serial port out
      
      ind1 = readString.indexOf(',');  //finds location of first ,
      angle = readString.substring(0, ind1);   //captures first data String
      ind2 = readString.indexOf(',', ind1+1 );   //finds location of second ,
      fuel = readString.substring(ind1+1, ind2+1);   //captures second data String
      ind3 = readString.indexOf(',', ind2+1 );
      speed1 = readString.substring(ind2+1, ind3+1);
      ind4 = readString.indexOf(',', ind3+1 );
      altidude = readString.substring(ind3+1); //captures remain part of data after last ,

      Serial.print("angle = ");
      Serial.println(angle); 
      Serial.print("fuel = ");
      Serial.println(fuel);
      Serial.print("speed = ");
      Serial.println(speed1);
      Serial.print("altidude = ");
      Serial.println(altidude);
      Serial.println();
      Serial.println();
      
      readString=""; //clears variable for new input
      angle="";
      fuel="";
      speed1="";
      altidude="";
    }  
    else {     
      readString += c; //makes the string readString
    }
  }
}

(deleted)

Are you going to run the web server on the Linux processor? If so, I guess it will need to use the bridge library to communicate with the AVR processor which does the I/O. Presumably there are YUN examples which show how to achieve that communication.

Perhaps the below web site has some useful info.

http://startingelectronics.com/tutorials/arduino/ethernet-shield-web-server-tutorial/

(deleted)

Dawiinci: The webserver already runs. I just don't know how to make variables accessible.

Below are some json tutorials that might help you develop a web page that includes json functions.

https://www.google.com/search?num=100&lr=&as_qdr=all&q=json+tutorial&spell=1&sa=X&ei=ja8tU8npKqXq0QH9vIGADw&ved=0CCYQvwUoAA&biw=1108&bih=628

(deleted)

So do you want the arduino or the webbrowser to parse the json ? The browser can use JavaScript to parse and you have to write something for the arduino to parse the string.

Dawiinci: I guess there has to be an easy way doing this.

I would guess so too. You'd need to look at the web server implementation and understand how it obtains the data it currently publishes, and then extend that implementation to publish the extra data you want.

Dawiinci: It's not about making a website, I only want variable int x to be available over http. The Arduino Yun ALREADY delivers this functionality with all inputs, so I guess there has to be an easy way doing this.

The "I only want variable int x to be available over http" is easy. The variable can be returned from a server that has the variable available for sending back to a client, or a variable can be sent by a client as a GET or POST request to a server. The rest of your request is some what "soup sandwich" as to what you actually want and is not easily understood.