Created
November 20, 2014 04:36
-
-
Save SaraJo/57910a8cfc7a8a75d9fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This sketch demonstrates how to send data from a Device | |
to a Host in a Gazell network. | |
When Button A on the Device is pressed and released, | |
the green led on the host will toggle. | |
*/ | |
#include <RFduinoGZLL.h> | |
#include "Timer.h" | |
device_t role = DEVICE0; | |
Timer t; | |
// pin for Button A on the RGB Shield | |
int button_a = 5; | |
// debounce time (in ms) | |
int debounce_time = 10; | |
// maximum debounce timeout (in ms) | |
int debounce_timeout = 100; | |
// starting state is off | |
char state = 0; | |
void setup() | |
{ | |
// start the GZLL stack | |
RFduinoGZLL.begin(role); | |
t.every(1000, message); | |
} | |
void loop() | |
{ | |
RFduinoGZLL.sendToHost("Hi friend!!!"); | |
// send state to Host | |
} | |
void RFduinoGZLL_onReceive(device_t device, int rssi, char *data, int len) | |
{ | |
} | |
void message(){ | |
RFduinoGZLL.sendToHost("Hi friend!!!"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This sketch demonstrates how to send data from a Device | |
to a Host in a Gazell network. | |
The host and upto 3 devices should have the RGB shield | |
attached. When Button A on a Device is pressed, the | |
associated led on the Host will toggle. Device1 is | |
associated with the Red led, Device2 with the Green led | |
and Device3 with the Blue led. | |
The Green led on the Device will blink to indicate | |
that an acknowledgement from the Host was received. | |
*/ | |
#include <RFduinoGZLL.h> | |
device_t role = HOST; | |
// pin for the Green Led | |
int led = 3; | |
void setup() | |
{ | |
pinMode(led, OUTPUT); | |
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW | |
// start the GZLL stack | |
RFduinoGZLL.begin(role); | |
} | |
void loop() | |
{ | |
} | |
void RFduinoGZLL_onReceive(device_t device, int rssi, char *data, int len) | |
{ | |
// this test is not needed for a single device | |
if (device == DEVICE0) | |
{ | |
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) | |
delay(1000); // wait for a second | |
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW | |
delay(1000); // wait for a second | |
} | |
// no data to piggyback on the acknowledgement sent back to the Device | |
// RFduinoGZLL.sendToDevice(device, "OK"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment