Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 831105b

Browse files
‘RFduino’‘RFduino’
‘RFduino’
authored and
‘RFduino’
committed
GZLL baseAddress enhancement
1 parent 808a6a9 commit 831105b

File tree

7 files changed

+146
-1
lines changed

7 files changed

+146
-1
lines changed

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
CHANGELOG
22

3+
v 2.2.3
4+
- GZLL baseAddress enhancement (thanks waynek/jetty840)
5+
- Check base address msb is not 0x55 or 0xaa
6+
- Updated libRFduinoGZLL keywords.txt
7+
- Added DeviceToHostSettings example GZLL sketch
8+
39
v 2.2.2
410
- Resolved race condition issue with analogRead.
511

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
This sketch demonstrates how to send data from a Device
3+
to a Host in a Gazell network.
4+
5+
When Button A on the Device is pressed and released,
6+
the green led on the host will toggle.
7+
*/
8+
9+
#include <RFduinoGZLL.h>
10+
11+
device_t role = DEVICE0;
12+
13+
// pin for Button A on the RGB Shield
14+
int button_a = 5;
15+
16+
// debounce time (in ms)
17+
int debounce_time = 10;
18+
19+
// maximum debounce timeout (in ms)
20+
int debounce_timeout = 100;
21+
22+
// starting state is off
23+
char state = 0;
24+
25+
void setup()
26+
{
27+
pinMode(button_a, INPUT);
28+
29+
// use the lowest power level
30+
RFduinoGZLL.txPowerLevel = -20;
31+
32+
// the host/device base address can be changed to create independent networks in the same area
33+
// (note: the msb cannot be 0x55 or 0xaa)
34+
RFduinoGZLL.hostBaseAddress = 0x12345678; // default host base address is 0x0D0A0704;
35+
RFduinoGZLL.deviceBaseAddress = 0x87654321; // default device base address is 0x0E0B0805;
36+
37+
// start the GZLL stack
38+
RFduinoGZLL.begin(role);
39+
}
40+
41+
int debounce(int button, int state)
42+
{
43+
int start = millis();
44+
int debounce_start = start;
45+
46+
while (millis() - start < debounce_timeout)
47+
if (digitalRead(button) == state)
48+
{
49+
if (millis() - debounce_start >= debounce_time)
50+
return 1;
51+
}
52+
else
53+
debounce_start = millis();
54+
55+
return 0;
56+
}
57+
58+
int delay_until_button(int button, int state)
59+
{
60+
while (! debounce(button, state))
61+
;
62+
}
63+
64+
void loop()
65+
{
66+
delay_until_button(button_a, HIGH);
67+
68+
// toggle state
69+
state = ! state;
70+
71+
// send state to Host
72+
RFduinoGZLL.sendToHost(state);
73+
74+
delay_until_button(button_a, LOW);
75+
}
76+
77+
void RFduinoGZLL_onReceive(device_t device, int rssi, char *data, int len)
78+
{
79+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
This sketch demonstrates how to send data from a Device
3+
to a Host in a Gazell network.
4+
5+
The host and upto 3 devices should have the RGB shield
6+
attached. When Button A on a Device is pressed, the
7+
associated led on the Host will toggle. Device1 is
8+
associated with the Red led, Device2 with the Green led
9+
and Device3 with the Blue led.
10+
11+
The Green led on the Device will blink to indicate
12+
that an acknowledgement from the Host was received.
13+
*/
14+
15+
#include <RFduinoGZLL.h>
16+
17+
device_t role = HOST;
18+
19+
// pin for the Green Led
20+
int green_led = 3;
21+
22+
void setup()
23+
{
24+
pinMode(green_led, OUTPUT);
25+
26+
// use the lowest power level
27+
RFduinoGZLL.txPowerLevel = -20;
28+
29+
// the host/device base address can be changed to create independent networks in the same area
30+
// (note: the msb cannot be 0x55 or 0xaa)
31+
RFduinoGZLL.hostBaseAddress = 0x12345678; // default host base address is 0x0D0A0704;
32+
RFduinoGZLL.deviceBaseAddress = 0x87654321; // default device base address is 0x0E0B0805;
33+
34+
// start the GZLL stack
35+
RFduinoGZLL.begin(role);
36+
}
37+
38+
void loop()
39+
{
40+
}
41+
42+
void RFduinoGZLL_onReceive(device_t device, int rssi, char *data, int len)
43+
{
44+
char state = data[0];
45+
46+
// this test is not needed for a single device
47+
if (device == DEVICE0)
48+
digitalWrite(green_led, state);
49+
50+
// no data to piggyback on the acknowledgement sent back to the Device
51+
// RFduinoGZLL.sendToDevice(device, "OK");
52+
}

libraries/RFduinoGZLL/keywords.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ RFduinoGZLL KEYWORD1
1212
# Methods and Functions (KEYWORD2)
1313
#######################################
1414
txPowerLevel KEYWORD2
15+
hostBaseAddress KEYWORD2
16+
deviceBaseAddress KEYWORD2
1517

1618
begin KEYWORD2
1719
end KEYWORD2

source/libRFduinoGZLL/build.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@echo off
22

3-
set arduino=C:\arduino-1.5.7
3+
set arduino=C:\arduino-1.5.8
44
set nordic="C:\Nordic Semiconductor\nRF51 SDK_v4.2.0.25053\Nordic\nrf51822"
55

66
if not exist %nordic% (

source/libRFduinoGZLL/libRFduinoGZLL.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,17 @@ int RFduinoGZLL_begin(device_t device)
8686
return 4;
8787

8888
if (RFduinoGZLL_host_base_address ) {
89+
uint8_t msb = RFduinoGZLL_host_base_address >> 24;
90+
if (msb == 0x55 || msb == 0xAA)
91+
return 5; // msb of base address should not be alternating 0s and 1s
8992
if ( !nrf_gzll_set_base_address_0(RFduinoGZLL_host_base_address) )
9093
return 5;
9194
}
9295

9396
if (RFduinoGZLL_device_base_address) {
97+
uint8_t msb = RFduinoGZLL_device_base_address >> 24;
98+
if (msb == 0x55 || msb == 0xAA)
99+
return 6; // msb of base address should not be alternating 0s and 1s
94100
if ( !nrf_gzll_set_base_address_1(RFduinoGZLL_device_base_address) )
95101
return 6;
96102
}

variants/RFduino/libRFduinoGZLL.a

4.71 KB
Binary file not shown.

0 commit comments

Comments
 (0)