forked from RFduino/RFduino
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRFduinoGZLL.cpp
More file actions
112 lines (88 loc) · 3.47 KB
/
RFduinoGZLL.cpp
File metadata and controls
112 lines (88 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
RFduinoGZLL.cpp
Copyright (c) 2014 OpenSourceRF.com. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
The Gazell protocol is a wireless communication protocol that is used
to setup a robust wireless link between a single host and up to eight
devices in a star network topology.
The Host in a Gazell network is always listening, and it is the Device
that always initiates a communication.
Each packet that a Device sends is required to be acknowledged by the
Host. Gazell auotmatically handle packet retransmission if necessary.
It is possible for the Host to send data to the Device by piggybacking
data to an acknowledgement (ACK) packet. Therefore a Host has to wait
for a packet from a Device before it can send any data to it.
Gazell utilizes channel hopping functionality that gives a high date
rate and reliable wireless link.
Gazell requires no connection packets to setup a link, and devices can
enter and exit from the network at any time.
*/
#include "Arduino.h"
#include "RFduinoGZLL.h"
RFduinoGZLLClass::RFduinoGZLLClass()
{
::RFduinoGZLL_used = 1;
txPowerLevel = +4;
hostBaseAddress = 0U;
deviceBaseAddress = 0U;
}
int RFduinoGZLLClass::begin(device_t device)
{
RFduinoGZLL_tx_power_level = txPowerLevel;
RFduinoGZLL_host_base_address = hostBaseAddress;
RFduinoGZLL_device_base_address = deviceBaseAddress;
return RFduinoGZLL_begin(device);
}
void RFduinoGZLLClass::end()
{
RFduinoGZLL_end();
NRF_RADIO->TASKS_RSSISTOP = 1;
}
bool RFduinoGZLLClass::sendToHost(const char *data, int len)
{
return RFduinoGZLL_send_to_host(data, len);
}
bool RFduinoGZLLClass::sendToDevice(device_t device, const char *data, int len)
{
return RFduinoGZLL_send_to_device(device, data, len);
}
bool RFduinoGZLLClass::sendToHost(const char *data)
{
return sendToHost(data, strlen(data));
}
bool RFduinoGZLLClass::sendToDevice(device_t device, const char *data)
{
return sendToDevice(device, data, strlen(data));
}
bool RFduinoGZLLClass::sendToHost(String &data)
{
char buf[32];
data.toCharArray(buf, sizeof(buf));
return sendToHost(buf);
}
bool RFduinoGZLLClass::sendToDevice(device_t device, String &data)
{
char buf[32];
data.toCharArray(buf, sizeof(buf));
return sendToDevice(device, buf);
}
RFduinoGZLLClass RFduinoGZLL;