KSduino 

 The Device Network
Your IP Address is: 54.161.130.145

DOCUMENTATION

KSduino Class Reference

Main Library Class. More...

#include <KSduino.h>

List of all members.

Public Member Functions

Configuration and initialization functions

These functions used to initialize KSduino library, it's necessary functions.

 KSduino (unsigned int devID, unsigned int devPwd, byte *serverAddr, unsigned int serverP)
 This Class constructor.
void begin (byte *mac, byte *ip, byte *dns, byte *gateway, unsigned int port)
 Initializes the ethernet library and network settings.
void begin (byte *mac, byte *ip, byte *dns, unsigned int port)
void begin (byte *mac, byte *ip, unsigned int port)
void begin (byte *mac, unsigned int port)
void begin (byte *mac, byte *ip, byte *dns, byte *gateway, byte *subnet, unsigned int port)
Send one parameter functions

These functions used to send one parameters to the KSduino server

void sendOne (const char *parameter, const char *value, const char *message=NULL, int checkAnswer=2)
 Send one parameter to server.
void sendOne (const char *parameter, byte value, const char *message=NULL, int checkAnswer=2)
void sendOne (const char *parameter, int value, const char *message=NULL, int checkAnswer=2)
void sendOne (const char *parameter, unsigned int value, const char *message=NULL, int checkAnswer=2)
void sendOne (const char *parameter, unsigned long value, const char *message=NULL, int checkAnswer=2)
void sendOne (const char *parameter, float value, const char *message=NULL, int checkAnswer=2)
Send parameters in text buffer or String functions

These functions used to send text buffer or String with parameters to the KSduino server

void sendBuffer (const char *userData, int checkAnswer=2)
 Send formated buffer to server.
void sendBuffer (String userData, int checkAnswer=2)
 Send formated String to server.
Send group of parameters functions

These functions used to send group of parameters to the KSduino server

void beginPacket (void)
 Starts a connection to write group of packets to the server.
void addParameter (const char *parameter, const char *value)
 Add parameter to send to server.
void addParameter (const char *parameter, byte value)
void addParameter (const char *parameter, int value)
void addParameter (const char *parameter, unsigned int value)
void addParameter (const char *parameter, unsigned long value)
void addParameter (const char *parameter, float value)
void addMessage (const char *message)
 Add message to send to server.
int endPacket (int checkAnswer=2)
 End of parameters packet.
Send to Other devices functions

These functions used to send parameter to other device

void sendToOther (int device_id, int device_passwd, const char *parameter, const char *value, const char *message=NULL, int checkAnswer=2)
 Send parameter and message to other device.
void sendToOther (int device_id, int device_passwd, const char *parameter, byte value, const char *message=NULL, int checkAnswer=2)
void sendToOther (int device_id, int device_passwd, const char *parameter, int value, const char *message=NULL, int checkAnswer=2)
void sendToOther (int device_id, int device_passwd, const char *parameter, unsigned int value, const char *message=NULL, int checkAnswer=2)
void sendToOther (int device_id, int device_passwd, const char *parameter, unsigned long value, const char *message=NULL, int checkAnswer=2)
void sendToOther (int device_id, int device_passwd, const char *parameter, float value, const char *message=NULL, int checkAnswer=2)
Get KSduino current status information functions

These functions return current status information from KSduino library

unsigned long getLostPackets (void)
 Get number of lost packets.
unsigned long getWrongAnswer (void)
 Get number of wrong packets.
unsigned long getTotalPackets (void)
 Get total number of sending packets.
unsigned long getLoopTime (void)
 Get last loop time.
int getBytesInQueue (void)
 Get current size of Reseive Queue buffer.
void setLostPacketCallback (ksdLostPacketCallback)
 Set lost packet callback function.
void setBeforeResetCallback (ksdBeforeReset beforeResetFunc)
 Set before reset callback function.
KSduino update and reception

These functions used to reseive parameters from server or other devices

void update (void)
 Get results from server.
void setReceptionCallback (ksdReceptionFunc receptionFunc)
 Set reception callback function.

Detailed Description

Main Library Class.

Author:
Kirill Scherba
Version:
0.0.1
Date:
2012

This is main KSduino Libray class. It used to connect controllers to KSduino Device Network.

Examples:
control_01.ino, send_to_other.ino, send_to_other_receiver.ino, send_to_other_sender.ino, simple_01.ino, simple_02.ino, simple_03.ino, simple_04.ino, simple_05.ino, and simple_06.ino.

Definition at line 134 of file KSduino.h.


Constructor & Destructor Documentation

KSduino::KSduino ( unsigned int  devID,
unsigned int  devPwd,
byte *  serverAddr,
unsigned int  serverP 
)

This Class constructor.

Parameters:
[in]devIDYour Device ID
[in]devPwdYour Device password
[in]serverAddrKSduino Server address
[in]serverPKSduino Server port

This function used to create KSduino class at the begining of sketch, before setup function.

See also:
simple_01.ino example for more information about using this function.

Definition at line 107 of file KSduino.cpp.


Member Function Documentation

void KSduino::addMessage ( const char *  message)

Add message to send to server.

Parameters:
[in]messageMessage

This function does not return any values.

This function is part of functions group: beginPacket addParameter addMessage endPacket. It should be called between beginPacket and endPacket functions. This function adds message to paket started with beginPacket function. This message sends to server with KSduino::endPacket functions and displays at the Device Parameter page.

See KSduino::beginPacket, KSduino::addParameter and KSduino::endPacket to get additional information.

See also:
simple_05.ino example which demonstrate of using this function.

Definition at line 540 of file KSduino.cpp.

void KSduino::addParameter ( const char *  parameter,
const char *  value 
)

Add parameter to send to server.

Parameters:
[in]parameterParameter
[in]valueValue of the parameter

This function does not return any values.

This function is part of functions group: KSduino::beginPacket KSduino::addParameter KSduino::endPacket. It should be called between KSduino::beginPacket and KSduino::endPacket functions. This function adds parameter and it value to paket started with KSduino::beginPacket function.

Variants of calling:

        void    addParameter (const char *parameter, const char *value)
        void    addParameter (const char *parameter, byte value)
        void    addParameter (const char *parameter, int value)
        void    addParameter (const char *parameter, unsigned int value)
        void    addParameter (const char *parameter, unsigned long value)
        void    addParameter (const char *parameter, float value)

These variants is for different parameters types.

See KSduino::beginPacket and KSduino::endPacket to get additional information.

See also:
simple_04.ino example which demonstrate of using this function.

Definition at line 462 of file KSduino.cpp.

Referenced by KSduinoParameter::addParameter().

void KSduino::begin ( byte *  mac,
byte *  ip,
byte *  dns,
byte *  gateway,
unsigned int  port 
)

Initializes the ethernet library and network settings.

Parameters:
[in]mac*Device mac address
[in]ipDevice IP addres
[in]dnsLocal Network DNS server
[in]gatewayLocal Network Gateway
[in]port*Device local port

This function does not return any values.

Setup Local network Ethernet parameters. Mac addreess and port are requerid parameters.

Variants of calling:

  void  begin (byte *mac, byte *ip, byte *dns, byte *gateway, unsigned int port);
  void  begin (byte *mac, byte *ip, byte *dns, unsigned int port);
  void  begin (byte *mac, byte *ip, unsigned int port);
  void  begin (byte *mac, unsigned int port);

This function called at the beginning of setup function to initialise ethernet controller. This function replace standard Arduino Ethernet::begin function.

The most used variant of calling this function is:

Precondition:
void begin (byte *mac, byte *ip, unsigned int port);

If you'll use variants without IP it takes 4K of your sketch size.

See also:
simple_01.ino example for more information about using this function.

Definition at line 185 of file KSduino.cpp.

void KSduino::beginPacket ( void  )

Starts a connection to write group of packets to the server.

This function starts process of transfering group of parameters to server. This process begins with this function and finishs after calling the KSduino::endPacket function. Between these functions you can send several parameters by using KSduino::addParameter function, and one packets message by using KSduino::addMessage function.

This is most handy method of sending group of parameters to the KSduino server.

This function does not return any values.

See also:
simple_04.ino example for more information about using this function.

KSduino::addParameter, KSduino::addMessage, KSduino::endPacket

Definition at line 406 of file KSduino.cpp.

int KSduino::endPacket ( int  checkAnswer = 2)

End of parameters packet.

Parameters:
[in]checkAnswer1,2 or 0; 2 is default value

checkAnswer values:

  • 1 - wait server for answer
  • 2 - not wait server for answer but check the answer in update function
  • 0 - do nothing, just send packet
Returns:
0 - if checkAnswer == 1 and server does not send answer, or return 1 in othee case

This function called after writing parameters with KSduino::addParameter function. It completes group of functions: beginPacket addParameter endPacket. This function sends packet with group of parameters to server.

See KSduino::peginPacket and KSduino::addParameter to get additional information.

See also:
simple_04.ino example which demonstrate of using this function.

Definition at line 613 of file KSduino.cpp.

int KSduino::getBytesInQueue ( void  )

Get current size of Reseive Queue buffer.

Returns:
current size of Reseive Queue buffer

Definition at line 1130 of file KSduino.cpp.

unsigned long KSduino::getLoopTime ( void  )

Get last loop time.

Returns:
last loop time in millisecond

Definition at line 1118 of file KSduino.cpp.

unsigned long KSduino::getLostPackets ( void  )

Get number of lost packets.

Returns:
number of lost packets - packets without answer from server

Definition at line 1082 of file KSduino.cpp.

unsigned long KSduino::getTotalPackets ( void  )

Get total number of sending packets.

Returns:
total number of sending packets

Definition at line 1106 of file KSduino.cpp.

unsigned long KSduino::getWrongAnswer ( void  )

Get number of wrong packets.

Returns:
number of wrong packets - packates which not waiting by KSduino library

Definition at line 1094 of file KSduino.cpp.

void KSduino::sendBuffer ( const char *  userData,
int  checkAnswer = 2 
)

Send formated buffer to server.

Parameters:
[in]userData*Text buffer with parameters & values
[in]checkAnswer1,2 or 0; 2 is default value

checkAnswer values:

  • 1 - wait server for answer
  • 2 - not wait server for answer but check the answer in update function
  • 0 - do nothing, just send packet

userData value:

  • before using this function, you have to create a text buffer containing all the parameters and their values in the following format: p1=v1[,p2=v2]... Here: p1 & p2 - parameters, it shoud be d1 & i1 for example, and v1 & v2 its values, 0 & 25 for example. I this case the result buffer should be: "d1=0,i1=25". To send packets message add message parameter and message to the buffer: msg=\"Hello World\", and you result buffer should be look like this: "d1=0,i1=25,msg=\"Hello World\""

This function does not return any values.

See also:
simple_02.ino example for more information about using this function.
Note:
This is most quickly and most save arduino resources KSduino function to send parameters to server. Perhaps this function is not very convenient for the programmer so there are other best samples to sent: KSduino::sendOne, KSduino::beginPacket ... KSduino::endPacket

Definition at line 256 of file KSduino.cpp.

void KSduino::sendBuffer ( String  userData,
int  checkAnswer = 2 
)

Send formated String to server.

Parameters:
[in]userData*String with parameters & values
[in]checkAnswer1,2 or 0; 2 is default value

checkAnswer values:

  • 1 - wait server for answer
  • 2 - not wait server for answer but check the answer in update function
  • 0 - do nothing, just send packet

userData value:

  • before using this function, you have to create a String object which will contain all the parameters and their values in the following format: p1=v1[,p2=v2]... Here: p1 & p2 - parameters, it shoud be d1 & i1 for example, and v1 & v2 its values, 0 & 25 for example. I this case the result buffer should be: "d1=0,i1=25". To send packets message add message parameter and message to the buffer: msg=\"Hello World\", and you result buffer should be look like this: "d1=0,i1=25,msg=\"Hello World\""

This function similar to:

 void     sendBuffer (const char *userData, int checkAnswer=2) 

but uses String instead of "const char * userData"

See also:
simple_03.ino example for more information about using this function.

Definition at line 292 of file KSduino.cpp.

void KSduino::sendOne ( const char *  parameter,
const char *  value,
const char *  message = NULL,
int  checkAnswer = 2 
)

Send one parameter to server.

Parameters:
[in]parameterName of Parameter
[in]valueParameters Value (any parameters type)
[in]messagePackets message or NULL if not used
[in]checkAnswer1,2 or 0; 2 is default value

checkAnswer values:

  • 1 - wait server for answer
  • 2 - not wait server for answer but check the answer in update function
  • 0 - do nothing, just send packet

This function does not return any values.

This function used to send one parameter to KSduino server. To send group of parameters use KSduino::sendBuffer or KSduino::beginPacket ... KSduino::endPacket functions.

See also:
simple_01.ino example for more information about using this function.

Definition at line 327 of file KSduino.cpp.

References addParameter().

void KSduino::sendToOther ( int  device_id,
int  device_passwd,
const char *  parameter,
const char *  value,
const char *  message = NULL,
int  checkAnswer = 2 
)

Send parameter and message to other device.

Parameters:
[in]device_idOther device ID
[in]device_passwdOther device password
[in]parameterParameter
[in]valueParameters value
[in]messagePackets message or NULL if not used
[in]checkAnswer1,2 or 0; 2 is default value

checkAnswer values:

  • 1 - wait server for answer
  • 2 - not wait server for answer but check the answer in update function
  • 0 - do nothing, just send packet

Variants of calling:

 void   sendToOther (int device_id, int device_passwd, const char *parameter, const char *value, const char *message=NULL, int checkAnswer=2)
 void   sendToOther (int device_id, int device_passwd, const char *parameter, byte value, const char *message=NULL, int checkAnswer=2)
 void   sendToOther (int device_id, int device_passwd, const char *parameter, int value, const char *message=NULL, int checkAnswer=2)
 void   sendToOther (int device_id, int device_passwd, const char *parameter, unsigned int value, const char *message=NULL, int checkAnswer=2)
 void   sendToOther (int device_id, int device_passwd, const char *parameter, unsigned long value, const char *message=NULL, int checkAnswer=2)
 void   sendToOther (int device_id, int device_passwd, const char *parameter, float value, const char *message=NULL, int checkAnswer=2)

These variants is for different parameters types.

This function does not return any values.

Definition at line 711 of file KSduino.cpp.

References addParameter().

Set before reset callback function.

Parameters:
[in]beforeResetFuncBefore reset function

Before reset function is callback function which will called before reset Arduino with W5100 Ethernet shield. This reset happend sometimes due to incorrect operation of W5100.

This function does not return any values.

Definition at line 1166 of file KSduino.cpp.

Set lost packet callback function.

Parameters:
[in]lostPacketCallbackLost packet function

Set callback function which will called when lost or wrong packets will detected.

This function does not return any values.

Definition at line 1183 of file KSduino.cpp.

Set reception callback function.

Parameters:
[in]receptionFuncReception callback function

Reception callback function calls when KSduino library get messages from web server or other devices

This function does not return any values.

Definition at line 1147 of file KSduino.cpp.

void KSduino::update ( void  )

Get results from server.

This is Loops End function to read answer & commands from server, get messages from other device and send ping command to server. This function is necessary. It should be placed at the end of arduinos loop function.

This function does not return any values.

See also:
simple_01.ino example for more information about using this function.

Definition at line 782 of file KSduino.cpp.


The documentation for this class was generated from the following files:
Created with KSNews

HOME | CONTACTS | INFORMER | SHORTENER | DOCUMENTATION | HELP

Copyright © 2012-2013, The KSduino Project