Internet Shield acts as Arduino Shield via 1Sheeld

Buy 1Sheeld
Arduino - 1Sheeld internet shield functions as Wifi/Ethernet shields

The Internet shield brings the power of IOT with the simplicity of 1Sheeld and Arduino to your door, so now you can handle Http requests, access certain REST API’s “even with JSON format” and get their responses then take a certain action using the Hardware experience. Learn more from the examples page.

This shield is one of the communication shields.

Communication shields allow you to use your smartphone as a gateway between Arduino and other phones, they make it easier to communicate with your Arduino board by sending and receiving data to or from another phone. Learn more from the communication shields tutorial.

Internet library will allow your arduino to  handle Http requests easily, and access certain REST api’s “even with JSON format” and get their responses and take certain actions.

Adding #define CUSTOM_SETTINGS along with #define INCLUDE_INTERNET_SHIELD is a key that will let you unlock the Internet shield only amongst all shields and prevent 1Sheeld library from eating your memory specially for UNO board.

“There are permissions to be granted by Android M users before they can use the Internet shield please make sure to grant the permissions or else it may affect the application’s performance.”

Important Notes:

-It’s preferable creating requests globally “above setup function” avoiding losing data, and be careful  not to create requests in local functions unless you are not going to use them again in your sketch life.

-Maximum number of unique requests per sketch is 20 requests.

– Maximum depth chain in Json requests is 8 Keys per chain.

– Response is sent page by page each time 64bytes/page (this is a default value and can be changed) until the whole response is finished on the application and disposing requests clears the unwanted responses in application.

-Make sure to use each shield key to prevent consuming lot of memory, specially if you are using an Arduino UNO board.

Dependable Classes:

 

1-HttpRequest class:

This class deals with all the request that will be handled and processed by the application on your smartphone.

Each object created using Http will have a sequential ID which will be dealt with your whole sketch and even at the application with Maximum 20 unique requests.

 

2-HttpResponse class:

This class deals with the response returned by each performed request, you can use it to query the json response, get a certain amount of bytes, get headers, or get the response status code.

3-JsonKeyChain class:

This class brings the ease of dealing with API’s using the power of JSON and has certain 

operators to deal with chaining keys and checking json responses with 8 Keys Maximum.

[ ] operator for chaining keys.

!= to check inequality of json chains.

== to check equality of json chains.

Internet:

 

 

HttpRequest:

 

 

HttpResponse:

 

 

JsonKeyChain:

bool performGet(HttpRequest &)

Performs a Get request.

SYNTAX

Internet.performGet(request);

RETURNS

A Yes ‘1’ or No ‘0’ if request is Added internally in a list with maximum 20 unique requests.

PARAMETERS

Takes an object of HttpRequest class that has a certain url to be processed.

USAGE

HttpRequest oneSheeld(“url”);
Internet.performGet(oneSheeld);

bool performPost(HttpRequest &)

Performs a Post request.

SYNTAX

Internet.performPost(request);

RETURNS

A Yes ‘1’ or No ‘0’ if request is Added internally in a list with maximum 20 requests.

PARAMETERS

Takes an object of HttpRequest class that has a certain url to be processed.

USAGE

HttpRequest oneSheeld(“http://www.google.com”);
Internet.performPost(oneSheeld);

bool performPut(HttpRequest &)

Performs a Put request.

SYNTAX

Internet.performPut(request);

RETURNS

A Yes ‘1’ or No ‘0’ if request is Added internally in a list with maximum 20 requests.

PARAMETERS

Takes an object of HttpRequest class that has a certain url to be processed.

USAGE

HttpRequest oneSheeld(“http://www.google.com”);
Internet.performPut(oneSheeld);

bool performDelete(HttpRequest &)

Performs a Delete request.

SYNTAX

Internet.performDelete(request);

RETURNS

A Yes ‘1’ or No ‘0’ if request is Added internally in a list with maximum 20 requests.

PARAMETERS

Takes an object of HttpRequest class that has a certain url to be processed.

USAGE

HttpRequest oneSheeld(“http://www.google.com”);
Internet.performDelete(oneSheeld);

void cancelAllRequests(void)

Cancel all requests performed on the application.

SYNTAX

Internet.cancelAllRequests();

RETURNS

None.

PARAMETERS

None.

USAGE

Internet.cancelAllRequests();

void ignoreResponse(HttpRequest &)

Ignores the response of the given request.

SYNTAX

Internet.ignoreResponse(request);

RETURNS

None.

PARAMETERS

Takes an object of HttpRequest class that has a certain url to be processed.

USAGE

HttpRequest oneSheeld(“url”);
Internet.ignoreResponse(oneSheeld);

void setBasicAuthentication(const char * ,const char *)

Sets authentication to access the content.

SYNTAX

Internet.setBasicAuthentication(“username”,”password”);

RETURNS

None.

PARAMETERS

Takes username and password.

USAGE

Internet.setBasicAuthentication(“oneSheeld”,”123456”);

void clearBasicAuthentication(void)

Clears authentication.

SYNTAX

Internet.clearBasicAuthentication( );

RETURNS

None.

PARAMETERS

None.

USAGE

Internet.clearBasicAuthentication( );

void setIntialResponseMaxBytesCount(int )

Sets initial incoming bytes of response to a certain number (default = 64bytes).

SYNTAX

Internet.setInitialResponseMaxBytesCount(numberofBytes);

RETURNS

None.

PARAMETERS

Takes number of bytes to be sent by the application.

USAGE

Internet.setInitialResponseMaxBytesCount(100);

void setOnError(void (*userFunction)(int,int));

sets a certain individual function written by the user in the sketch to be called and runs its functionality once an error occured.

Types of Errors:

REQUEST_CAN_NOT_BE_FOUND = 0

NOT_CONNECTED_TO_NETWORK = 1

URL_IS_NOT_FOUND =2

ALREADY_EXECUTING_REQUEST =3

URL_IS_WRONG =4

SYNTAX

Internet.setOnError(&userFunctionName);

RETURNS

None.

PARAMETERS

&userFunctionName: takes the physical address of the userFunction in the memory and jump to it once called to execute it’s functionality.

USAGE

Internet.setOnError(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked if an error occurred in the internet functionality . */
void myFunction (int requestId  , int errorNumber)
{
  Terminal.print("Request id:");
  Terminal.println(requestId);
  Terminal.print("Internet error:");

  switch(errorNumber)
  {
  case REQUEST_CAN_NOT_BE_FOUND: 
    Terminal.println("REQUEST_CAN_NOT_BE_FOUND");
    break;

  case NOT_CONNECTED_TO_NETWORK: 
    Terminal.println("NOT_CONNECTED_TO_NETWORK");
    break;

  case URL_IS_NOT_FOUND: 
    Terminal.println("URL_IS_NOT_FOUND");
    break;

  case ALREADY_EXECUTING_REQUEST: 
    Terminal.println("ALREADY_EXECUTING_REQUEST");
    break;

  case URL_IS_WRONG: 
    Terminal.println("URL_IS_WRONG");
    break;
  }
}

HttpRequest(const char *)

Creates a request and save it in an internal list with maximum of 20 requests.

SYNTAX

HttpRequest request1(“https://xxxxxxxxxxxxxxxxxxxx”);

RETURNS

None.

PARAMETERS

Takes request url.

USAGE

HttpRequest oneSheeldRequest(“http://1sheeld.com/”);

void setUrl(const char *)

Sets url for a the request.

SYNTAX

createdRequest.setUrl(url);

RETURNS

None.

PARAMETERS

Takes url to be set  by the application.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setUrl(“http://arduino.cc/”);

void addHeader(const char * ,const char *)

Add header for request.

SYNTAX

createdRequest.addHeader(key,value);

RETURNS

None.

PARAMETERS

Takes Key and values of Header. 

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.addHeader(“Content-Type”,”application/json”);

void addParameter(const char * ,const char *)

Add parameter for request.

SYNTAX

createdRequest.addParameter(key,value);

RETURNS

None.

PARAMETERS

Takes Key and values of Parameter.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.addParameter(“ParameterKey”,”ParameterValue”);

void addRawData(const char *)

Add raw data to request instead of the parameters in case the request is post or put.

SYNTAX

createdRequest.addRawData(data);

RETURNS

None.

PARAMETERS

Takes data to be updated.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.addRawData(“data will be updated on the cloud”);

void addLastImageAsParameter( const char *,byte , byte)

Upload your last taken image as a parameter to your request.

LITERALS:

RAW “default”

BASE64

FROM_ONESHEELD_FOLDER

FROM_CAMERA_FOLDER

SYNTAX

createdRequest.addLastImageAsParameter(requestParameter,fromOneSheeldFolder,imageType);

RETURNS

None.

PARAMETERS

1st Request parameter where the API states.

2nd Upload picture from OneSheeld folder “default by 0” or Camera folder “1”.

3rd Upload image as Raw or in Base64.

USAGE

HttpRequest oneSheeld("https://api.imgur.com/3/upload");
oneSheeld.addLastImageAsParameter("image");
or
HttpRequest oneSheeld("https://api.imgur.com/3/upload");
oneSheeld.addLastImageAsParameter("image",FROM_CAMERA_FOLDER,BASE64);

void addLastImageAsRawEntity(byte)

Upload your last taken image as raw entity to your request.

SYNTAX

createdRequest.addLastImageAsRawEntity(fromOneSheeldFolder);

RETURNS

None.

PARAMETERS

1st Upload picture from OneSheeld folder “default by 0” or Camera folder “1”.

USAGE

HttpRequest oneSheeld("https://content.dropboxapi.com/2/files/upload");
oneSheeld.addLastImageAsRawEntity();
or
HttpRequest oneSheeld("https://content.dropboxapi.com/2/files/upload");
oneSheeld.addLastImageAsRawEntity(FORM_CAMERA_FOLDER);

int getId(void)

Get ID of the request.

SYNTAX

createdRequest.getId( );

RETURNS

returns back ID of request in integer.

PARAMETERS

None.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
int requestId = oneSheeld.getId( );

void deleteHeaders(void)

Delete Headers of request.

SYNTAX

createdRequest.deleteHeaders( );

RETURNS

None.

PARAMETERS

None.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.deleteHeaders( );

void deleteParameters(void)

Delete Parameters of request.

SYNTAX

createdRequest.deleteParameters( );

RETURNS

None.

PARAMETERS

None.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.deleteParameters( );

void deleteCallBacks(void)

Delete all subscribed call backs set .

SYNTAX

createdRequest.deleteCallBacks( );

RETURNS

None.

PARAMETERS

None.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.deleteCallBacks( );

void setContentType(const char * )

Set content type for request.

SYNTAX

createdRequest.setContentType(Type);

RETURNS

None.

PARAMETERS

Takes type as like JSON etc.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setContentType("application/json" );

void setParametersContentEncoding(const char * )

Set encoding  parameters content.

SYNTAX

createdRequest.setParametersContentEncoding(EncodingType);

RETURNS

None.

PARAMETERS

Takes type as like UTF-8, UTF16  etc.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setContentType("UTF-8" );

void ignoreResponse(void)

Ignores request response.

SYNTAX

createdRequest.ignoreResponse( );

RETURNS

None.

PARAMETERS

None.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.ignoreResponse(  );

void setOnSuccess(void (*userFunction)(HttpResponse&))

Sets a certain individual function coded by the user in the sketch to be called and runs its functionality once an the request is a success.

SYNTAX

createdRequest.setOnSuccess(&userFunctionName);

RETURNS

None.

PARAMETERS

&userFunctionName: takes the physical address of the userFunction in the memory and jump to it once called to execute it’s functionality.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setOnSuccess(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked when the request is processed successfully at the application and returns the first 64 bytes of the reponse . */
void myFunction (HttpResponse & returnedResponse)
{
  /* Print out success status code and total bytes of response. */
  Terminal.println(returnedResponse.getStatusCode( ));
  Terminal.println(returnedResponse.getTotalBytesCount( ));
}

void setOnFailure(void (*userFunction)(HttpResponse&))

Sets a certain individual function coded by the user in the sketch to be called and runs its functionality once an the request is failed.

SYNTAX

createdRequest.setOnFailure(&userFunctionName);

RETURNS

None.

PARAMETERS

&userFunctionName: takes the physical address of the userFunction in the memory and jump to it once called to execute it’s functionality.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setOnFailure(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked when the request is failed at the application and returns a certain type of error. */
void myFunction (HttpResponse & returnedResponse)
{
  /* Print out failure status code and total bytes of response. */
  Terminal.println(returnedResponse.getStatusCode( ));
  Terminal.println(returnedResponse.getTotalBytesCount( ));
}

void setOnStart(void (*userFunction)(void))

Sets a certain individual function coded by the user in the sketch to be called and runs its functionality once an the request process is started.

SYNTAX

createdRequest.setOnStart(&userFunctionName);

RETURNS

None.

PARAMETERS

&userFunctionName: takes the physical address of the userFunction in the memory and jump to it once called to execute it’s functionality.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setOnStart(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked when the request is started at the application.*/
void myFunction ( )
{
  /* Print out request is started. */
  Terminal.println(“request is started”);
}

void setOnFinish(void (*userFunction)(void))

Sets a certain individual function coded by the user in the sketch to be called and runs its functionality once an the request process is finished.

SYNTAX

createdRequest.setOnFinish(&userFunctionName);

RETURNS

None.

PARAMETERS

&userFunctionName: takes the physical address of the userFunction in the memory and jump to it once called to execute it’s functionality.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setOnFinish(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked when the request is processing finished at the application.*/
void myFunction ( )
{
  /* Print out request is finished. */
  Terminal.println(“request is finished”);
}

HttpResponse & getResponse(void)

Returns a certain response created.

SYNTAX

createdRequest.getResponse( );

RETURNS

A response object.

PARAMETERS

None.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
/* Returns back a certain request response. */
HttpResponse myResponse = oneSheeld.getResponse( );

bool isSentFully(void)

Checks if the response is sent fully and we’ve iterated on all the request .

SYNTAX

returnedResponse.isSentFully( );

RETURNS

A Yes ‘1’ or No ‘0’.

PARAMETERS

None.

USAGE

HttpRequest createdRequest(“http://1sheeld.com”);
HttpResponse & oneSheeldResponse=createdRequest.getResponse();
/* Checks if the reponse is sent fully */
if(oneSheeldResponse.isSentFully( ) )
{
  /* Print out response is sent. */
  Terminal.println(“Response is sent”);
}

bool isDisposed(void)

Checks if the response is disposed.

SYNTAX

returnedResponse.isDisposed( );

RETURNS

A Yes ‘1’ or No ‘0’.

PARAMETERS

None.

USAGE

HttpRequest createdRequest(“http://1sheeld.com”);
HttpResponse & oneSheeldResponse=createdRequest.getResponse();
/* Checks if the reponse is disposed*/
if(oneSheeldResponse.isDisposed( ) )
{
  /* Print out response is sent. */
  Terminal.println(“Response is disposed”);
}

void setOnNextResponseBytesUpdate(void (*userFunction)(HttpResponse&))

Sets a certain individual function coded by the user in the sketch to be called and runs its functionality once getNextBytes() or getTheseBytes() are called.

SYNTAX

returnedResponse.setOnNextResponseBytesUpdate(&userFunctionName);

RETURNS

None.

PARAMETERS

&userFunctionName: takes the physical address of the userFunction in the memory and jump to it once called to execute it’s functionality.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setOnSuccess(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked when the request is processed successfully at the application and returns the first 64 bytes of the reponse . */
void myFunction (HttpResponse & response)
{
  /* Subscribe to function to be invoked each time response bytes is updated. */
  response.setOnNextResponseBytesUpdate(&responseFunction);
  response.getNextBytes();
}

void responseFunction(HttpResponse & response)
{
  /* Print out updated bytes. */
  Terminal.println(response.getBytes( ) );
}

void setOnError(void (*userFunction)(int ))

Sets a certain individual function written by the user in the sketch to be called and runs its functionality once an error has occured.

Types of Error:

INDEX_OUT_OF_BOUNDS = 0
RESPONSE_CAN_NOT_BE_FOUND = 1
HEADER_CAN_NOT_BE_FOUND = 2
NO_ENOUGH_BYTES = 3
REQUEST_HAS_NO_RESPONSE = 4
SIZE_OF_REQUEST_CAN_NOT_BE_ZERO = 5
UNSUPPORTED_HTTP_ENTITY = 6
JSON_KEYCHAIN_IS_WRONG = 7

SYNTAX

returnedResponse.setOnError(&userFunctionName);

RETURNS

None.

PARAMETERS

&userFunctionName: takes the physical address of the userFunction in the memory and jump to it once called to execute it’s functionality.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setOnFailure(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked when the request is failed. */
void myFunction (HttpResponse & response)
{
  /* Subscribe to function to be invoked each time response bytes is updated. */
  response.setOnError(&responseFunction);
}

void responseFunction(int errorNumber)
{
  /* Print out error Number.*/
  Terminal.print("Response error:");
  switch(errorNumber)
  {
  case INDEX_OUT_OF_BOUNDS: Terminal.println("INDEX_OUT_OF_BOUNDS");break;
  
  case RESPONSE_CAN_NOT_BE_FOUND: Terminal.println("RESPONSE_CAN_NOT_BE_FOUND");break;
  
  case HEADER_CAN_NOT_BE_FOUND: Terminal.println("HEADER_CAN_NOT_BE_FOUND");break;
  
  case NO_ENOUGH_BYTES: Terminal.println("NO_ENOUGH_BYTES");break;
  
  case REQUEST_HAS_NO_RESPONSE: Terminal.println("REQUEST_HAS_NO_RESPONSE");break;
  
  case SIZE_OF_REQUEST_CAN_NOT_BE_ZERO: Terminal.println("SIZE_OF_REQUEST_CAN_NOT_BE_ZERO");break;
  
  case UNSUPPORTED_HTTP_ENTITY: Terminal.println("UNSUPPORTED_HTTP_ENTITY");break;
  
  case JSON_KEYCHAIN_IS_WRONG: Terminal.println("JSON_KEYCHAIN_IS_WRONG");break;
  }
}

void setOnJsonResponse(void (*userFunction)(JsonKeyChain & ,char []))

Sets a certain individual function coded by the user in the sketch to be called and runs its functionality once you call query() on response.

SYNTAX

returnedResponse.setOnJsonResponse(&userFunctionName);

RETURNS

None.

PARAMETERS

&userFunctionName: takes the physical address of the userFunction in the memory and jump to it once called to execute it’s functionality.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.getResponse.setOnJsonResponse(&myFunction);
oneSheeld.getResponse[“Json”][“chaining”][“example”].query( );
/* myFunction exists under the loop function. */
/* This function will be invoked when the Json request is processed successfully at the application and returns back the chain and the value. */
void myFunction (JsonKeyChain chain , char value [ ] )
{
  /*Print out the returned value of the json chain response. */
  Terminal.println(value);
}

void setOnJsonArrayLengthResponse(void (*userFunction)(JsonKeyChain & ,unsigned long))

Sets a certain individual function coded by the user in the sketch to be called and runs its functionality once you call queryArrayLength() on response.

SYNTAX

returnedResponse.setOnJsonArrayLengthResponse(&userFunctionName);

RETURNS

None.

PARAMETERS

&userFunctionName: takes the physical address of the userFunction in the memory and jump to it once called to execute it’s functionality.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.getResponse.setOnJsonArrayLengthResponse(&myFunction);
oneSheeld.getResponse[“Json”][“chaining”][“example”].query();
/* myFunction exists under the loop function. */
/* This function will be invoked when the Json request is processed successfully at the application and returns back the chain and required jsons array length. */
void myFunction (JsonKeyChain chain , unsigned long arrayLength )
{
  /*Print out the returned json array length. */
  Terminal.println(arrayLength);
}

void dispose(void)

Sends to dispose the response to the application.

SYNTAX

returnedResponse.dispose( );

RETURNS

None.

PARAMETERS

None.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setOnFailure(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked when the request is failed. */
void myFunction (HttpResponse & response)
{
  /* Subscribe to function to be invoked each time response bytes is updated. */
  response.dispose( );
}

void resetIndex(unsigned long= 0)

Resets the responses index to a certain value “default is zero”.

SYNTAX

returnedResponse.resetIndex(requiredIndexNumber);

RETURNS

None.

PARAMETERS

A certain indexing number to start on with next time.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setOnSuccess(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked when the request is processed successfully at the application and returns the first 64 bytes of the reponse . */
void myFunction (HttpResponse & returnedResponse)
{
  /* Reset Inde.*/
  response.resetIndex( );
}

void getNextBytes(int=64)

Asks for next bytes with certain length “default length= 64”.

SYNTAX

returnedResponse.getNextBytes(requiredlength);

RETURNS

None.

PARAMETERS

Takes a certain response length to be returned back with.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setOnSuccess(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked when the request is processed successfully at the application and returns the first 64 bytes of the reponse . */
void myFunction (HttpResponse & returnedResponse)
{
  /* Asks for more than 64 bytes next time.*/
  response.getNextBytes(100);
}

void getTheseBytes(unsigned long ,int)

Asks for certain number of bytes with a certain index and length.

SYNTAX

returnedResponse.getTheseBytes(indexNumber , requiredlength);

RETURNS

None.

PARAMETERS

Takes a start and certain response length to be returned back with.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setOnSuccess(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked when the request is processed successfully at the application and returns the first 64 bytes of the reponse . */
void myFunction (HttpResponse & returnedResponse)
{
  /* Asks for more than 64 bytes next time.*/
  response.getTheseBytes(100 , 255);
}

void getHeader(const char * , void (*userFunction)(char [],char []))

Get a certain Header key and value and return it back in a certain userFunction.

SYNTAX

returnedResponse.getHeader(headerName,&userFunctionName);

RETURNS

None.

PARAMETERS

Takes header name and a userfunction to be invoked once the response is returned. 

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setOnSuccess(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked when the request is processed successfully. */
void myFunction (HttpResponse & returnedResponse)
{
  /* Asks for more than 64 bytes next time.*/
  response.getHeader(“headerName” ,&myFunction2);
}

void myFunction2 (char headerName [ ] , char headerValue [ ] )
{
  /*Print put both header name and value. */
  Terminal.println(headerName);
  Terminal.println(headerValue);
}

int getStatusCode(void)

Get the status code of the response.

SYNTAX

returnedResponse.getStatusCode( );

RETURNS

An Integer type status code number.

PARAMETERS

None.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setOnSuccess(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked when the request is processed successfully at the application and returns the first 64 bytes of the reponse . */
void myFunction (HttpResponse & returnedResponse)
{
  /* Print out number of status code.*/
  Terminal.println(returnedResponse.getStatusCode( ) );
}

int getBytesCount(void)

Get number of bytes within the response.

SYNTAX

returnedResponse.getBytesCount( );

RETURNS

An Integer type byte counts number.

PARAMETERS

None.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setOnSuccess(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked when the request is processed successfully at the application and returns the first 64 bytes of the reponse . */
void myFunction (HttpResponse & returnedResponse)
{
  /* Print out bytes number returned in response.*/
  Terminal.println(returnedResponse.getByteCount( ) );
}

unsigned long getTotalBytesCount(void)

Get total bytes length of the whole response.

SYNTAX

returnedResponse.getTotalBytesCount( );

RETURNS

An unsigned long type total byte counts number.

PARAMETERS

None. 

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setOnSuccess(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked when the request is processed successfully at the application and returns the first 64 bytes of the reponse . */
void myFunction (HttpResponse & returnedResponse)
{
  /* Print out total bytes number in response.*/
  Terminal.println(returnedResponse.getTotalByteCount( ) );
}

unsigned long getCurrentIndex(void)

Get current index number at which the last response stopped.

SYNTAX

returnedResponse.getCurrentIndex( );

RETURNS

An unsigned long type Index number.

PARAMETERS

None.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setOnSuccess(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked when the request is processed successfully at the application and returns the first 64 bytes of the reponse . */
void myFunction (HttpResponse & returnedResponse)
{
  /* Print out current index.*/
  Terminal.println(returnedResponse.getCurrentIndex( ) );
}

char * getBytes(void)

Get response byte “data”.

SYNTAX

returnedResponse.getBytes( );

RETURNS

An array of characters which is the response data.

PARAMETERS

None.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.setOnSuccess(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked when the request is processed successfully at the application and returns the first 64 bytes of the reponse . */
void myFunction (HttpResponse & returnedResponse)
{
  /* Print out response data.*/
  Terminal.println(returnedResponse.getBytes( ) );
}

void query(void)

Query a certain json key chain to return it’s value.

SYNTAX

jsonChain[“chaining”][“key”][“names”].query( );

RETURNS

None.

PARAMETERS

Takes chaining keys to be parsed on the application.

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.getResponse.setOnJsonResponse(&myFunction);
oneSheeld.getResponse[“Json”][“chaining”][“example”].query( );
/* myFunction exists under the loop function. */
/* This function will be invoked when the Json request is processed successfully at the application and returns back the chain and the value. */
void myFunction (JsonKeyChain chain , char value [ ] )
{
  /*Print out the returned value of the json chain response. */
  Terminal.println(value);
}

void queryArrayLength(void)

Query a certain json key chain length to return it’s value.

SYNTAX

jsonChain[“chainingArrayName”].queryArrayLength( );

RETURNS

None.

PARAMETERS

Takes chaining keys to be parsed on the application. 

USAGE

HttpRequest oneSheeld(“http://1sheeld.com/”);
oneSheeld.getResponse.setOnJsonResponse(&myFunction);
oneSheeld.getResponse[“Json”][“chaining”][“example”].queryArrayLength( );
/* myFunction exists under the loop function. */
/* This function will be invoked when the Json request is processed successfully at the application and returns back the chain and the value. */
void myFunction (JsonKeyChain chain , unsignned long arrayLength[ ] )
{
  /*Print out the returned arary length value of the json chain response. */
  Terminal.println(arrayLength);
}