KSduino 

 The Device Network
Your IP Address is: 54.161.130.145

DOCUMENTATION

send_to_other_receiver.ino
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
/*
 * KSduino Send to Other Receiver Example Sketch
 *
 * send_to_other.ino
 *  
 * KSduino Send to Other Receiver is KSduino-library example sketch
 * This example is a part of KSduino Libray for Arduino
 *
 * Copyright (C) Kirill Scherba 2012 <kirill@scherba.ru>
 * 
 * KSduino library & examples is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * ksduino-server is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

// Includes -------------------------------------------------------------

#include <SPI.h>
#include <EthernetUdp.h>

#include <KSduino.h>

// User definition -----------------------------------------------------

// Change this values to yours

// Your Arduinos ID & Password
unsigned int deviceID = 0000;
unsigned int devicePwd = 0000;

// Your Arduinos MAC, IP & port used in your local network
byte mac[] = { 0xDE, 0xAD, 0xBE, 0x55, 0xAE, 0x0D };
byte ip[] = { 192, 168, 0, 222 };
unsigned int port = 59978;

// Server definition -----------------------------------------------------

// Do not change this values

// KSduino Server address & port
byte serverIp[] = { 178,63,53,233 };
unsigned int serverPort = 9930;

// ----------------------------------------------------------------------------

// Create KSduino class
KSduino ksd (deviceID, devicePwd, serverIp, serverPort);

// ----------------------------------------------------------------------------

void setup()
{
  
  // Start KSduino at the beginning of setup
  ksd.begin (mac, ip, port);    
  ksd.setReceptionCallback (receptionFunc);
  
  Serial.begin(115200); 
  
  Serial.println ("KSduino Send to Other test (Receiver) ver 0.0.1\n");
}

void loop()
{
  
  // KSduino update should be at the end of loop
  ksd.update ();    

  // Do delay
  delay (100);  
}

// Get data received from server or orther devices
int receptionFunc (int device_id, char param, int num, void *value, char *message)
{
  int *val; 
  val = (int*) value;
  
  // Resend received value to B2 parameter to show it on web site 
  if (param == 'b' && num == 2) ksd.sendOne ("b2", *val, message);

  // Display messages to serial
  Serial.print ("Device ID: ");
  Serial.print (device_id);
  
  Serial.print (", ");
  Serial.print (param);
  Serial.print (num);
  Serial.print (" = ");
  Serial.print(*val);

  if (message)
  {
    Serial.print (", message = \"");
    Serial.print (message);  
    Serial.print ("\"");
  }
  
  Serial.println ();  
  
  return 0;
}


Created with KSNews

HOME | CONTACTS | INFORMER | SHORTENER | DOCUMENTATION | HELP

Copyright © 2012-2013, The KSduino Project