├── .gitattributes
├── .idea
├── LoRaArduino.iml
├── inspectionProfiles
│ ├── Project_Default.xml
│ └── profiles_settings.xml
├── misc.xml
├── modules.xml
└── workspace.xml
├── README.md
├── SX_01a_TX_LoRa
└── SX_01a_TX_LoRa.ino
├── hoperf_lora_tx
└── hoperf_lora_tx.ino
├── images
├── gateway.jpg
├── gateway2.jpg
├── nodes.jpg
├── nodes2.jpg
├── slack.png
└── slack2.png
├── libraries
├── HopeRFLib
│ ├── HopeDuino_Buzz.cpp
│ ├── HopeDuino_Buzz.h
│ ├── HopeDuino_CMT211xA.cpp
│ ├── HopeDuino_CMT211xA.h
│ ├── HopeDuino_CMT2219A.cpp
│ ├── HopeDuino_CMT2219A.h
│ ├── HopeDuino_CMT221xA.cpp
│ ├── HopeDuino_CMT221xA.h
│ ├── HopeDuino_IIC.cpp
│ ├── HopeDuino_IIC.h
│ ├── HopeDuino_LoRa.cpp
│ ├── HopeDuino_LoRa.h
│ ├── HopeDuino_RFM66.cpp
│ ├── HopeDuino_RFM66.h
│ ├── HopeDuino_RFM69.cpp
│ ├── HopeDuino_RFM69.h
│ ├── HopeDuino_SPI.cpp
│ ├── HopeDuino_SPI.h
│ ├── HopeDuino_SPI3.cpp
│ ├── HopeDuino_SPI3.h
│ ├── HopeDuino_TWI.cpp
│ ├── HopeDuino_TWI.h
│ ├── HopeDuino_UART.cpp
│ ├── HopeDuino_UART.h
│ ├── HopeHp203b_IIC.cpp
│ ├── HopeHp203b_IIC.h
│ ├── HopeHp206c_IIC.cpp
│ ├── HopeHp206c_IIC.h
│ ├── HopeTh06_IIC.cpp
│ ├── HopeTh06_IIC.h
│ └── example
│ │ ├── SensorMoudle
│ │ └── SensorMoudle.ino
│ │ ├── lora_Rx
│ │ └── lora_rx.ino
│ │ ├── lora_Tx
│ │ └── lora_tx.ino
│ │ ├── rfm119_Tx
│ │ └── rfm119_Tx.ino
│ │ ├── rfm11x_Tx
│ │ └── rfm11x_Tx.ino
│ │ ├── rfm219_Rx
│ │ └── rfm219_Rx.ino
│ │ ├── rfm219_Rx_1920
│ │ └── rfm219_Rx_1920.ino
│ │ ├── rfm21x_Rx
│ │ └── rfm21x_Rx.ino
│ │ ├── rfm21x_Rx_1527
│ │ └── rfm21x_Rx_1527.ino
│ │ ├── rfm66_Rx
│ │ └── rfm66_rx.ino
│ │ ├── rfm66_Tx
│ │ └── rfm66_tx.ino
│ │ ├── rfm69_Rx
│ │ └── rfm69_rx.ino
│ │ └── rfm69_Tx
│ │ └── rfm69_tx.ino
├── RadioHead
│ ├── LICENSE
│ ├── MANIFEST
│ ├── RHCRC.cpp
│ ├── RHCRC.h
│ ├── RHDatagram.cpp
│ ├── RHDatagram.h
│ ├── RHGenericDriver.cpp
│ ├── RHGenericDriver.h
│ ├── RHGenericSPI.cpp
│ ├── RHGenericSPI.h
│ ├── RHHardwareSPI.cpp
│ ├── RHHardwareSPI.h
│ ├── RHMesh.cpp
│ ├── RHMesh.h
│ ├── RHNRFSPIDriver.cpp
│ ├── RHNRFSPIDriver.h
│ ├── RHReliableDatagram.cpp
│ ├── RHReliableDatagram.h
│ ├── RHRouter.cpp
│ ├── RHRouter.h
│ ├── RHSPIDriver.cpp
│ ├── RHSPIDriver.h
│ ├── RHSoftwareSPI.cpp
│ ├── RHSoftwareSPI.h
│ ├── RHTcpProtocol.h
│ ├── RH_ASK.cpp
│ ├── RH_ASK.h
│ ├── RH_CC110.cpp
│ ├── RH_CC110.h
│ ├── RH_MRF89.cpp
│ ├── RH_MRF89.h
│ ├── RH_NRF24.cpp
│ ├── RH_NRF24.h
│ ├── RH_NRF51.cpp
│ ├── RH_NRF51.h
│ ├── RH_NRF905.cpp
│ ├── RH_NRF905.h
│ ├── RH_RF22.cpp
│ ├── RH_RF22.h
│ ├── RH_RF24.cpp
│ ├── RH_RF24.h
│ ├── RH_RF69.cpp
│ ├── RH_RF69.h
│ ├── RH_RF95.cpp
│ ├── RH_RF95.h
│ ├── RH_Serial.cpp
│ ├── RH_Serial.h
│ ├── RH_TCP.cpp
│ ├── RH_TCP.h
│ ├── RHutil
│ │ ├── HardwareSerial.cpp
│ │ ├── HardwareSerial.h
│ │ ├── RasPi.cpp
│ │ ├── RasPi.h
│ │ ├── atomic.h
│ │ └── simulator.h
│ ├── RadioHead.h
│ ├── STM32ArduinoCompat
│ │ ├── HardwareSPI.cpp
│ │ ├── HardwareSPI.h
│ │ ├── HardwareSerial.cpp
│ │ ├── HardwareSerial.h
│ │ ├── README
│ │ ├── wirish.cpp
│ │ └── wirish.h
│ ├── examples
│ │ ├── ask
│ │ │ ├── ask_receiver
│ │ │ │ └── ask_receiver.pde
│ │ │ ├── ask_reliable_datagram_client
│ │ │ │ └── ask_reliable_datagram_client.pde
│ │ │ ├── ask_reliable_datagram_server
│ │ │ │ └── ask_reliable_datagram_server.pde
│ │ │ └── ask_transmitter
│ │ │ │ └── ask_transmitter.pde
│ │ ├── cc110
│ │ │ ├── cc110_client
│ │ │ │ └── cc110_client.pde
│ │ │ └── cc110_server
│ │ │ │ └── cc110_server.pde
│ │ ├── mrf89
│ │ │ ├── mrf89_client
│ │ │ │ └── mrf89_client.pde
│ │ │ └── mrf89_server
│ │ │ │ └── mrf89_server.pde
│ │ ├── nrf24
│ │ │ ├── nrf24_client
│ │ │ │ └── nrf24_client.pde
│ │ │ ├── nrf24_reliable_datagram_client
│ │ │ │ └── nrf24_reliable_datagram_client.pde
│ │ │ ├── nrf24_reliable_datagram_server
│ │ │ │ └── nrf24_reliable_datagram_server.pde
│ │ │ └── nrf24_server
│ │ │ │ └── nrf24_server.pde
│ │ ├── nrf51
│ │ │ ├── nrf51_audio_rx
│ │ │ │ └── nrf51_audio_rx.pde
│ │ │ ├── nrf51_audio_tx
│ │ │ │ ├── nrf51_audio.pdf
│ │ │ │ └── nrf51_audio_tx.pde
│ │ │ ├── nrf51_client
│ │ │ │ └── nrf51_client.pde
│ │ │ ├── nrf51_reliable_datagram_client
│ │ │ │ └── nrf51_reliable_datagram_client.pde
│ │ │ ├── nrf51_reliable_datagram_server
│ │ │ │ └── nrf51_reliable_datagram_server.pde
│ │ │ └── nrf51_server
│ │ │ │ └── nrf51_server.pde
│ │ ├── nrf905
│ │ │ ├── nrf905_client
│ │ │ │ └── nrf905_client.pde
│ │ │ ├── nrf905_reliable_datagram_client
│ │ │ │ └── nrf905_reliable_datagram_client.pde
│ │ │ ├── nrf905_reliable_datagram_server
│ │ │ │ └── nrf905_reliable_datagram_server.pde
│ │ │ └── nrf905_server
│ │ │ │ └── nrf905_server.pde
│ │ ├── raspi
│ │ │ ├── Makefile
│ │ │ └── RasPiRH.cpp
│ │ ├── rf22
│ │ │ ├── rf22_client
│ │ │ │ └── rf22_client.pde
│ │ │ ├── rf22_mesh_client
│ │ │ │ └── rf22_mesh_client.pde
│ │ │ ├── rf22_mesh_server1
│ │ │ │ └── rf22_mesh_server1.pde
│ │ │ ├── rf22_mesh_server2
│ │ │ │ └── rf22_mesh_server2.pde
│ │ │ ├── rf22_mesh_server3
│ │ │ │ └── rf22_mesh_server3.pde
│ │ │ ├── rf22_reliable_datagram_client
│ │ │ │ └── rf22_reliable_datagram_client.pde
│ │ │ ├── rf22_reliable_datagram_server
│ │ │ │ └── rf22_reliable_datagram_server.pde
│ │ │ ├── rf22_router_client
│ │ │ │ └── rf22_router_client.pde
│ │ │ ├── rf22_router_server1
│ │ │ │ └── rf22_router_server1.pde
│ │ │ ├── rf22_router_server2
│ │ │ │ └── rf22_router_server2.pde
│ │ │ ├── rf22_router_server3
│ │ │ │ └── rf22_router_server3.pde
│ │ │ ├── rf22_router_test
│ │ │ │ └── rf22_router_test.pde
│ │ │ └── rf22_server
│ │ │ │ └── rf22_server.pde
│ │ ├── rf24
│ │ │ ├── rf24_client
│ │ │ │ └── rf24_client.pde
│ │ │ ├── rf24_reliable_datagram_client
│ │ │ │ └── rf24_reliable_datagram_client.pde
│ │ │ ├── rf24_reliable_datagram_server
│ │ │ │ └── rf24_reliable_datagram_server.pde
│ │ │ └── rf24_server
│ │ │ │ └── rf24_server.pde
│ │ ├── rf69
│ │ │ ├── rf69_client
│ │ │ │ └── rf69_client.pde
│ │ │ ├── rf69_reliable_datagram_client
│ │ │ │ └── rf69_reliable_datagram_client.pde
│ │ │ ├── rf69_reliable_datagram_server
│ │ │ │ └── rf69_reliable_datagram_server.pde
│ │ │ └── rf69_server
│ │ │ │ └── rf69_server.pde
│ │ ├── rf95
│ │ │ ├── rf95_client
│ │ │ │ └── rf95_client.pde
│ │ │ ├── rf95_reliable_datagram_client
│ │ │ │ └── rf95_reliable_datagram_client.pde
│ │ │ ├── rf95_reliable_datagram_server
│ │ │ │ └── rf95_reliable_datagram_server.pde
│ │ │ └── rf95_server
│ │ │ │ └── rf95_server.pde
│ │ ├── serial
│ │ │ ├── serial_reliable_datagram_client
│ │ │ │ └── serial_reliable_datagram_client.pde
│ │ │ └── serial_reliable_datagram_server
│ │ │ │ └── serial_reliable_datagram_server.pde
│ │ └── simulator
│ │ │ ├── simulator_reliable_datagram_client
│ │ │ └── simulator_reliable_datagram_client.pde
│ │ │ └── simulator_reliable_datagram_server
│ │ │ └── simulator_reliable_datagram_server.pde
│ ├── project.cfg
│ ├── radio_config_Si4460.h
│ └── tools
│ │ ├── chain.conf
│ │ ├── etherSimulator.pl
│ │ ├── simBuild
│ │ └── simMain.cpp
├── arduino-api
│ ├── arduinoClasses.h
│ ├── arduinoMultiprotocol.cpp
│ ├── arduinoMultiprotocol.h
│ ├── arduinoUART.cpp
│ ├── arduinoUART.h
│ ├── arduinoUtils.cpp
│ ├── arduinoUtils.h
│ └── keywords.txt
├── arduino-lmic
│ ├── README.md
│ ├── doc
│ │ ├── LMiC-v1.5.pdf
│ │ ├── README.txt
│ │ └── release-notes.txt
│ ├── examples
│ │ ├── raw
│ │ │ └── raw.ino
│ │ └── ttn
│ │ │ └── ttn.ino
│ ├── library.properties
│ └── src
│ │ ├── hal
│ │ ├── hal.cpp
│ │ └── hal.h
│ │ ├── lmic.h
│ │ └── lmic
│ │ ├── aes.c
│ │ ├── config.h
│ │ ├── hal.h
│ │ ├── lmic.c
│ │ ├── lmic.h
│ │ ├── lorabase.h
│ │ ├── oslmic.c
│ │ ├── oslmic.h
│ │ └── radio.c
├── arduinoLoRa
│ ├── arduinoLoRa.cpp
│ ├── arduinoLoRa.h
│ ├── examples
│ │ ├── SX_00_CONFIG_LoRa
│ │ │ └── SX_00_CONFIG_LoRa.pde
│ │ ├── SX_01a_TX_LoRa
│ │ │ └── SX_01a_TX_LoRa.pde
│ │ ├── SX_01b_RX_LoRa
│ │ │ └── SX_01b_RX_LoRa.pde
│ │ ├── SX_02a_TX_LoRa_ACK
│ │ │ └── SX_02a_TX_LoRa_ACK.pde
│ │ ├── SX_02b_RX_LoRa_ACK
│ │ │ └── SX_02b_RX_LoRa_ACK.pde
│ │ ├── SX_03a_TX_LoRa_ACKwRetries
│ │ │ └── SX_03a_TX_LoRa_ACKwRetries.pde
│ │ └── SX_03b_RX_LoRa_ACKwRetries
│ │ │ └── SX_03b_RX_LoRa_ACKwRetries.pde
│ └── keywords.txt
└── readme.txt
├── lmic_raw
└── lmic_raw.ino
├── rf95_client
└── rf95_client.ino
└── send_receive_sensor_data
└── send_receive_sensor_data.ino
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text eol=lf
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.idea/LoRaArduino.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | Spelling
15 |
16 |
17 |
18 |
19 | Spelling
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/hoperf_lora_tx/hoperf_lora_tx.ino:
--------------------------------------------------------------------------------
1 | // Based on http://www.hoperf.com/demo_tools/419.html
2 | /*
3 | * THE FOLLOWING FIRMWARE IS PROVIDED:
4 | * (1) "AS IS" WITH NO WARRANTY;
5 | * (2) TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
6 | * CONSEQUENTLY, HopeRF SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
7 | * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
8 | * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
9 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
10 | *
11 | * Copyright (C) HopeRF
12 | * website: www.HopeRF.com
13 | * www.HopeRF.cn
14 | *
15 | */
16 |
17 | /*!
18 | * file lora_tx.ino
19 | * hardware HopeDuino
20 | * software send message via HopeRF's LoRa COB
21 | * note can talk to HopeRF's EVB or DK demo
22 | *
23 | * version 1.0
24 | * date Jun 10 2014
25 | * author QY Ruan
26 | */
27 |
28 | #include
29 |
30 |
31 | loraClass radio;
32 |
33 | byte str[21] = {'H','o','p','e','R','F',' ','R','F','M',' ','C','O','B','R','F','M','9','8','S'};
34 |
35 | void setup()
36 | {
37 | radio.Modulation = LORA;
38 | ////radio.COB = RFM98;
39 | radio.COB = RFM96; //// TP-IoT: RFM96
40 |
41 | // Set center frequency
42 | ////uint32_t freq = 868100000; // in Mhz! (868.1)
43 | //// TP-IoT: uint32_t LORA_CH_10_868 = CH_10_868; // 0xD84CCC; // channel 10, central freq = 865.20MHz //// Lup Yuen
44 |
45 | ////radio.Frequency = 434000;
46 | radio.Frequency = 865200; //// TP-IoT: 865.20 MHz
47 | radio.OutputPower = 17; //17dBm OutputPower
48 | ////radio.PreambleLength = 16; //16Byte preamble
49 | radio.PreambleLength = 8; // TP-IoT: 8 Byte preamble
50 | radio.FixedPktLength = false; //explicit header mode for LoRa
51 | radio.PayloadLength = 21;
52 | radio.CrcDisable = true;
53 | for (int i = 0; i < 8; i++)
54 | radio.SyncWord[i] = 0x12; //// TP-IoT
55 |
56 | //// Mode 1 is max range but does NOT work with Dragino shield and Hope RF96 chip.
57 | //// TP-IoT Gateway runs on:
58 | //// case 1: setCR(CR_5); // CR = 4/5
59 | //// setSF(SF_12); // SF = 12
60 | //// setBW(BW_125); // BW = 125 KHz
61 | // TP-IoT Mode 1: Bw125Cr45Sf4096
62 | ////radio.SFSel = SF9;
63 | ////radio.BWSel = BW125K;
64 | ////radio.CRSel = CR4_5;
65 | radio.SFSel = SF12;
66 | radio.BWSel = BW125K;
67 | radio.CRSel = CR4_5;
68 |
69 | radio.vInitialize();
70 | radio.vGoStandby();
71 | }
72 |
73 | void loop()
74 | {
75 | radio.bSendMessage(str, 21);
76 | delay(1000);
77 | }
78 |
79 |
--------------------------------------------------------------------------------
/images/gateway.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lupyuen/LoRaArduino/f9318ff8f464b020654658e8616bd3790a121743/images/gateway.jpg
--------------------------------------------------------------------------------
/images/gateway2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lupyuen/LoRaArduino/f9318ff8f464b020654658e8616bd3790a121743/images/gateway2.jpg
--------------------------------------------------------------------------------
/images/nodes.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lupyuen/LoRaArduino/f9318ff8f464b020654658e8616bd3790a121743/images/nodes.jpg
--------------------------------------------------------------------------------
/images/nodes2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lupyuen/LoRaArduino/f9318ff8f464b020654658e8616bd3790a121743/images/nodes2.jpg
--------------------------------------------------------------------------------
/images/slack.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lupyuen/LoRaArduino/f9318ff8f464b020654658e8616bd3790a121743/images/slack.png
--------------------------------------------------------------------------------
/images/slack2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lupyuen/LoRaArduino/f9318ff8f464b020654658e8616bd3790a121743/images/slack2.png
--------------------------------------------------------------------------------
/libraries/HopeRFLib/HopeDuino_Buzz.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * THE FOLLOWING FIRMWARE IS PROVIDED:
3 | * (1) "AS IS" WITH NO WARRANTY;
4 | * (2) TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
5 | * CONSEQUENTLY, HopeRF SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
6 | * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
7 | * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
8 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
9 | *
10 | * Copyright (C) HopeRF
11 | *
12 | * website: www.HopeRF.com
13 | * www.HopeRF.cn
14 | */
15 |
16 | /*!
17 | * file HopeDuino_Buzz.cpp
18 | * brief
19 | * hardware HopeRF's EVB & LcdShiled
20 | *
21 | *
22 | * version 1.0
23 | * date Feb 15 2016
24 | * author QY Ruan
25 | */
26 |
27 | #include "HopeDuino_Buzz.h"
28 |
29 | /**********************************************************
30 | **Name: vBuzzInit
31 | **Function: Buzzer Init.
32 | **Input:
33 | **Output: none
34 | **********************************************************/
35 | void buzzClass::vBuzzInit(void)
36 | {
37 | DDRD |= 0x08; //PD3 for output
38 | ASSR = 0x00;
39 | TIMSK2 &= (~OCIE2B);
40 | TIFR2 &= (~OCF2B);
41 | OCR2A = 0x00;
42 | OCR2B = 0x00;
43 | TCCR2A &= 0xC0;
44 | TCCR2A |= 0x02; //OC2B output toggle
45 | TCCR2B = 0x05;
46 | }
47 |
48 | /**********************************************************
49 | **Name: vBuzzPlay
50 | **Function: paly music
51 | **Input: ptr
52 | **Output: none
53 | **********************************************************/
54 | void buzzClass::vBuzzPlay(byte ptr[], byte length)
55 | {
56 | byte i, j;
57 |
58 | for(i=0;i
43 | #include
44 |
45 | #define SL_1 236
46 | #define SL_1H 223
47 | #define SL_2 214
48 | #define SL_2H 198
49 | #define SL_3 187
50 | #define SL_4 177
51 | #define SL_4H 167
52 | #define SL_5 157
53 | #define SL_5H 149
54 | #define SL_6 140
55 | #define SL_6H 132
56 | #define SL_7 125
57 |
58 | #define SM_1 118
59 | #define SM_1H 111
60 | #define SM_2 105
61 | #define SM_2H 99
62 | #define SM_3 94
63 | #define SM_4 88
64 | #define SM_4H 83
65 | #define SM_5 79
66 | #define SM_5H 74
67 | #define SM_6 70
68 | #define SM_6H 66
69 | #define SM_7 62
70 |
71 | #define SH_1 59
72 | #define SH_1H 56
73 | #define SH_2 53
74 | #define SH_2H 50
75 | #define SH_3 47
76 | #define SH_4 44
77 | #define SH_4H 42
78 | #define SH_5 39
79 | #define SH_5H 37
80 | #define SH_6 35
81 | #define SH_6H 33
82 | #define SH_7 31
83 |
84 | class buzzClass
85 | {
86 | public:
87 | void vBuzzInit(void);
88 | void vBuzzPlay(byte ptr[], byte length);
89 |
90 | };
91 | #else
92 | #warning "RFduino_Buzz.h have been defined!"
93 |
94 | #endif
95 |
--------------------------------------------------------------------------------
/libraries/HopeRFLib/HopeDuino_CMT211xA.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lupyuen/LoRaArduino/f9318ff8f464b020654658e8616bd3790a121743/libraries/HopeRFLib/HopeDuino_CMT211xA.cpp
--------------------------------------------------------------------------------
/libraries/HopeRFLib/HopeDuino_CMT211xA.h:
--------------------------------------------------------------------------------
1 | /*
2 | * THE FOLLOWING FIRMWARE IS PROVIDED:
3 | * (1) "AS IS" WITH NO WARRANTY;
4 | * (2) TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
5 | * CONSEQUENTLY, HopeRF SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
6 | * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
7 | * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
8 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
9 | *
10 | * Copyright (C) HopeRF
11 | *
12 | * website: www.HopeRF.com
13 | * www.HopeRF.cn
14 | */
15 |
16 | /*!
17 | * file HopeDuino_CMT211xA.h
18 | * brief show how to use CMT211xA
19 | * hardware HopeDuino
20 | *
21 | *
22 | * version 1.0
23 | * date Feb 18 2016
24 | * author QY Ruan
25 | */
26 |
27 | #ifndef HopeDuino_CMT211XA_h
28 | #define HopeDuino_CMT211XA_h
29 |
30 | #include "HopeDuino_TWI.h"
31 |
32 |
33 | enum chipsetType {CMT2110A, CMT2113A, CMT2117A, CMT2119A};
34 | enum encodeType {ENRZ, E527, E201};
35 |
36 | class cmt211xaClass
37 | {
38 | public:
39 | chipsetType Chipset; //Chipset part number
40 | word SymbolTime; //unit: us Range: 10 - 4000
41 |
42 |
43 | void vCMT211xAInit(void);
44 | void vCMT2119AInit(word para[], byte length);
45 | void vCMT211xASleep(void);
46 | void vCMT2119ASleep(void);
47 | void vEncode(byte ptr[], byte length, encodeType etype);
48 | void vTxPacket(void);
49 |
50 | private:
51 | twiClass Twi;
52 | byte TxBuf[64]; //Tx Buffer
53 | byte TxBufLength; //Tx Buffer active length
54 |
55 | void vOpenLdoAndOsc(void);
56 | void vCloseLdoAndOsc(void);
57 | void vActiveRegsister(void);
58 | void vEnableRegMode(void);
59 | void vWriteReg(byte adr, word wrPara);
60 | word wReadReg(byte adr);
61 | void vSoftReset(void);
62 | void vTwiReset(void);
63 | void vTwiOff(void);
64 | };
65 | #else
66 | #warning "HopeDuino_CMT211xA.h have been defined!"
67 |
68 | #endif
--------------------------------------------------------------------------------
/libraries/HopeRFLib/HopeDuino_CMT2219A.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lupyuen/LoRaArduino/f9318ff8f464b020654658e8616bd3790a121743/libraries/HopeRFLib/HopeDuino_CMT2219A.cpp
--------------------------------------------------------------------------------
/libraries/HopeRFLib/HopeDuino_CMT2219A.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lupyuen/LoRaArduino/f9318ff8f464b020654658e8616bd3790a121743/libraries/HopeRFLib/HopeDuino_CMT2219A.h
--------------------------------------------------------------------------------
/libraries/HopeRFLib/HopeDuino_CMT221xA.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lupyuen/LoRaArduino/f9318ff8f464b020654658e8616bd3790a121743/libraries/HopeRFLib/HopeDuino_CMT221xA.cpp
--------------------------------------------------------------------------------
/libraries/HopeRFLib/HopeDuino_CMT221xA.h:
--------------------------------------------------------------------------------
1 | /*
2 | * THE FOLLOWING FIRMWARE IS PROVIDED:
3 | * (1) "AS IS" WITH NO WARRANTY;
4 | * (2) TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
5 | * CONSEQUENTLY, HopeRF SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
6 | * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
7 | * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
8 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
9 | *
10 | * Copyright (C) HopeRF
11 | *
12 | * website: www.HopeRF.com
13 | * www.HopeRF.cn
14 | */
15 |
16 | /*!
17 | * file HopeDuino_CMT221xA.h
18 | * brief show how to use CMT221xA
19 | * hardware HopeDuino with RFM21x
20 | *
21 | *
22 | * version 1.0
23 | * date Feb 18 2016
24 | * author QY Ruan
25 | */
26 |
27 | #ifndef HopeDuino_CMT221XA_h
28 | #define HopeDuino_CMT221XA_h
29 |
30 | #ifndef F_CPU
31 | #define F_CPU 16000000UL //HopeDuino use 16MHz Xo
32 | #endif
33 |
34 | #ifndef byte
35 | typedef unsigned char byte;
36 | #endif
37 |
38 | #ifndef word
39 | typedef unsigned int word;
40 | #endif
41 |
42 | #include
43 | #include
44 |
45 | /** Hardware brief **/
46 | //PORTD //DDRx PORTx PINx
47 | #define _SCLK 0x10 // 1 0 0
48 | #define _SDAT 0x20 // 1 1 0
49 | #define _DATA 0x40 // 0 0 0
50 | #define _CSB 0x80 // 1 1 0
51 |
52 | #define SetCSB() (PORTD |= _CSB)
53 | #define ClrCSB() (PORTD &= (~_CSB))
54 |
55 | #define SetSCLK() (PORTD |= _SCLK)
56 | #define ClrSCLK() (PORTD &= (~_SCLK))
57 |
58 | #define SetSDAT() (PORTD |= _SDAT)
59 | #define ClrSDAT() (PORTD &= (~_SDAT))
60 |
61 | #define InputSDAT() (DDRD &= (~_SDAT))
62 | #define OutputSDAT() (DDRD |= (_SDAT))
63 |
64 | #define SDAT_H() (PIND&_SDAT)
65 | #define SDAT_L() ((PIND&_SDAT)==0)
66 |
67 | #define DATA_H() (PIND&_DATA)
68 | #define DATA_L() ((PIND&_DATA)==0)
69 |
70 |
71 | enum chipsetType {CMT2210A, CMT2213A, CMT2217A};
72 | enum decodeType {E527, E201};
73 |
74 | class cmt221xaClass
75 | {
76 | public:
77 | chipsetType Chipset; //Chipset part number
78 | decodeType Decode;
79 | word SymbolTime; //unit: us Range: 10 - 4000
80 |
81 | void vCMT221xAInit(void);
82 | byte bReadRssi(void);
83 | byte bGetMessage(byte msg[], byte pklen);
84 |
85 | private:
86 | void vSpi3Init(void);
87 | void vSpi3WriteByte(byte dat);
88 | byte bSpi3ReadByte(void);
89 | void vSpi3Write(word dat);
90 | byte bSpi3Read(byte addr);
91 | void vDelayUs(byte delay); //limit 0~16, unit: us
92 |
93 | };
94 | #else
95 | #warning "HopeDuino_CMT221xA.h have been defined!"
96 |
97 | #endif
98 |
--------------------------------------------------------------------------------
/libraries/HopeRFLib/HopeDuino_LoRa.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lupyuen/LoRaArduino/f9318ff8f464b020654658e8616bd3790a121743/libraries/HopeRFLib/HopeDuino_LoRa.cpp
--------------------------------------------------------------------------------
/libraries/HopeRFLib/HopeDuino_RFM66.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lupyuen/LoRaArduino/f9318ff8f464b020654658e8616bd3790a121743/libraries/HopeRFLib/HopeDuino_RFM66.cpp
--------------------------------------------------------------------------------
/libraries/HopeRFLib/HopeDuino_RFM66.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lupyuen/LoRaArduino/f9318ff8f464b020654658e8616bd3790a121743/libraries/HopeRFLib/HopeDuino_RFM66.h
--------------------------------------------------------------------------------
/libraries/HopeRFLib/HopeDuino_RFM69.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lupyuen/LoRaArduino/f9318ff8f464b020654658e8616bd3790a121743/libraries/HopeRFLib/HopeDuino_RFM69.cpp
--------------------------------------------------------------------------------
/libraries/HopeRFLib/HopeDuino_RFM69.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lupyuen/LoRaArduino/f9318ff8f464b020654658e8616bd3790a121743/libraries/HopeRFLib/HopeDuino_RFM69.h
--------------------------------------------------------------------------------
/libraries/HopeRFLib/HopeDuino_SPI.h:
--------------------------------------------------------------------------------
1 | /*
2 | * THE FOLLOWING FIRMWARE IS PROVIDED:
3 | * (1) "AS IS" WITH NO WARRANTY;
4 | * (2) TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
5 | * CONSEQUENTLY, HopeRF SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
6 | * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
7 | * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
8 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
9 | *
10 | * Copyright (C) HopeRF
11 | *
12 | * website: www.HopeRF.com
13 | * www.HopeRF.cn
14 | */
15 |
16 | /*!
17 | * file HopeDuino_SPI.cpp
18 | * brief for HopeRF's EVB to use Hardware SPI
19 | * hardware HopeRF's EVB
20 | *
21 | *
22 | * version 1.1
23 | * date Jan 15 2015
24 | * author QY Ruan
25 | */
26 |
27 |
28 | #ifndef HopeDuino_SPI_h
29 | #define HopeDuino_SPI_h
30 | #include
31 |
32 | // TP-IoT Pin mapping
33 | /*
34 | const lmic_pinmap lmic_pins = {
35 | .nss = 10,// Connected to pin D10
36 | .rxtx = LMIC_UNUSED_PIN,// For placeholder only, Do not connected on RFM92/RFM95
37 | .rst = 9,// Needed on RFM92/RFM95? (probably not)
38 | .dio = {2, 6, 7},// Specify pin numbers for DIO0, 1, 2 connected to D2, D6, D7
39 | };
40 | */
41 | #define nSS_Value 10
42 | #define nSS_Port PORTB
43 | #define nSS_Dir DDRB
44 |
45 | #ifndef nSS_Value
46 | #warning "Does not define nSS_Value/nSS_Port/nSS_Dir! Default setting PortB_4 for nSS."
47 | #define nSS_Value 0x04
48 | #define nSS_Port PORTB
49 | #define nSS_Dir DDRB
50 | #endif
51 |
52 | #ifndef byte
53 | typedef unsigned char byte;
54 | #endif
55 |
56 | #ifndef word
57 | typedef unsigned int word;
58 | #endif
59 |
60 | /** Hardware brief **/
61 | //PORTB //DDRx PORTx PINx
62 | //#define _SDI 0x08 // 1 1 0
63 | //#define _SDO 0x10 // 0 0 1
64 | //#define _SCK 0x20 // 1 0 0
65 | //// TP-IoT: .dio = {2, 6, 7},// Specify pin numbers for DIO0, 1, 2 connected to D2, D6, D7
66 | #define _SDI 2
67 | #define _SDO 6
68 | #define _SCK 7
69 |
70 | #define SetnSS() (nSS_Port |= nSS_Value)
71 | #define ClrnSS() (nSS_Port &= (~nSS_Value))
72 |
73 | class spiClass
74 | {
75 | public:
76 | void vSpiInit(void); /** initialize hardware SPI config, SPI_CLK = Fcpu/4 **/
77 | void vSpiWrite(word dat); /** SPI send one word **/
78 | byte bSpiRead(byte addr); /** SPI read one byte **/
79 | void vSpiBurstWrite(byte addr, byte ptr[], byte length); /** SPI burst send N byte **/
80 | void vSpiBurstRead(byte addr, byte ptr[], byte length); /** SPI burst rend N byte **/
81 | private:
82 | byte bSpiTransfer(byte dat); /** SPI send/read one byte **/
83 | };
84 |
85 | #else
86 | #warning "HopeDuino_SPI.h have been defined!"
87 |
88 | #endif
--------------------------------------------------------------------------------
/libraries/HopeRFLib/HopeDuino_SPI3.h:
--------------------------------------------------------------------------------
1 | /*
2 | * THE FOLLOWING FIRMWARE IS PROVIDED:
3 | * (1) "AS IS" WITH NO WARRANTY;
4 | * (2) TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
5 | * CONSEQUENTLY, HopeRF SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
6 | * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
7 | * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
8 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
9 | *
10 | * Copyright (C) HopeRF
11 | *
12 | * website: www.HopeRF.com
13 | * www.HopeRF.cn
14 | */
15 |
16 | /*!
17 | * file HopeDuino_SPI.cpp
18 | * brief for HopeRF's EVB to use Hardware SPI
19 | * hardware HopeRF's EVB
20 | *
21 | *
22 | * version 1.1
23 | * date Jan 15 2015
24 | * author QY Ruan
25 | */
26 |
27 |
28 | #ifndef HopeDuino_SPI3_h
29 | #define HopeDuino_SPI3_h
30 |
31 | #ifndef F_CPU
32 | #define F_CPU 16000000UL //HopeDuino use 16MHz Xo
33 | #endif
34 |
35 | #define SPI3_SPEED 2 //the bigger the slow
36 |
37 | #include
38 | #include
39 |
40 | #ifndef byte
41 | typedef unsigned char byte;
42 | #endif
43 |
44 | #ifndef word
45 | typedef unsigned int word;
46 | #endif
47 |
48 | /** Hardware brief **/
49 | //PORTB //DDRx PORTx PINx
50 | #define _CSB 0x04 // 1 1 0
51 | #define _SDIO 0x08 // 1 1 0
52 | #define _FCSB 0x10 // 1 1 0
53 | #define _SDCK 0x20 // 1 0 0
54 |
55 | #define SetCSB() (PORTB |= _CSB)
56 | #define ClrCSB() (PORTB &= (~_CSB))
57 |
58 | #define SetFCSB() (PORTB |= _FCSB)
59 | #define ClrFCSB() (PORTB &= (~_FCSB))
60 |
61 | #define SetSDCK() (PORTB |= _SDCK)
62 | #define ClrSDCK() (PORTB &= (~_SDCK))
63 |
64 | #define SetSDIO() (PORTB |= _SDIO)
65 | #define ClrSDIO() (PORTB &= (~_SDIO))
66 |
67 | #define InputSDIO() (DDRB &= (~_SDIO))
68 | #define OutputSDIO() (DDRB |= (_SDIO))
69 |
70 | #define SDIO_H() (PINB&_SDIO)
71 | #define SDIO_L() ((PINB&_SDIO)==0)
72 |
73 |
74 |
75 | class spi3Class
76 | {
77 | public:
78 | void vSpi3Init(void); /** initialize software SPI-3 **/
79 | void vSpi3Write(word dat); /** SPI-3 send one word **/
80 | byte bSpi3Read(byte addr); /** SPI-3 read one byte **/
81 |
82 | void vSpi3WriteFIFO(byte dat); /** SPI-3 send one byte to FIFO **/
83 | byte bSpi3ReadFIFO(void); /** SPI-3 read one byte from FIFO **/
84 | void vSpi3BurstWriteFIFO(byte ptr[], byte length); /** SPI-3 burst send N byte to FIFO**/
85 | void vSpi3BurstReadFIFO(byte ptr[], byte length); /** SPI-3 burst read N byte to FIFO**/
86 | private:
87 | void vSpi3WriteByte(byte dat); /** SPI-3 send one byte **/
88 | byte bSpi3ReadByte(void); /** SPI-3 read one byte **/
89 |
90 | };
91 |
92 | #else
93 | #warning "HopeDuino_SPI3.h have been defined!"
94 |
95 | #endif
--------------------------------------------------------------------------------
/libraries/HopeRFLib/HopeDuino_TWI.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lupyuen/LoRaArduino/f9318ff8f464b020654658e8616bd3790a121743/libraries/HopeRFLib/HopeDuino_TWI.cpp
--------------------------------------------------------------------------------
/libraries/HopeRFLib/HopeDuino_TWI.h:
--------------------------------------------------------------------------------
1 | /*
2 | * THE FOLLOWING FIRMWARE IS PROVIDED:
3 | * (1) "AS IS" WITH NO WARRANTY;
4 | * (2) TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
5 | * CONSEQUENTLY, HopeRF SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
6 | * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
7 | * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
8 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
9 | *
10 | * Copyright (C) HopeRF
11 | *
12 | * website: www.HopeRF.com
13 | * www.HopeRF.cn
14 | */
15 |
16 | /*!
17 | * file HopeDuino_TWI.cpp
18 | * brief for HopeRF's EVB to use config soft TWI port
19 | * hardware HopeRF's EVB
20 | *
21 | *
22 | * version 1.1
23 | * date Jan 15 2015
24 | * author QY Ruan
25 | */
26 |
27 |
28 |
29 | #ifndef HopeDuino_TWI_h
30 | #define HopeDuino_TWI_h
31 |
32 | #ifndef F_CPU
33 | #define F_CPU 16000000UL //HopeDuino use 16MHz Xo
34 | #endif
35 |
36 | #define TWI_SPEED 2 //the bigger the slow
37 |
38 | #ifndef byte
39 | typedef unsigned char byte;
40 | #endif
41 |
42 | #ifndef word
43 | typedef unsigned int word;
44 | #endif
45 |
46 | #ifndef lword
47 | typedef unsigned long lword;
48 | #endif
49 |
50 | #include
51 | #include
52 |
53 | /** Hardware brief **/
54 |
55 | /** Hardware brief **/
56 | //PORTB //DDRx PORTx PINx
57 | #define _TCLK 0x10 // 1 1 0
58 |
59 | //PORTD
60 | #define _TDAT 0x40 // 1 0
61 |
62 | #define SetTCLK() (PORTB |= _TCLK)
63 | #define ClrTCLK() (PORTB &= (~_TCLK))
64 |
65 | #define InputTDAT() (DDRD &= (~_TDAT))
66 | #define OutputTDAT() (DDRD |= _TDAT)
67 |
68 | #define SetTDAT() (PORTD |= _TDAT)
69 | #define ClrTDAT() (PORTD &= (~_TDAT))
70 |
71 | #define TDAT_H() (PIND&_TDAT)
72 | #define TDAT_L() ((PIND&_TDAT)==0)
73 |
74 | class twiClass
75 | {
76 | public:
77 | void vTWIInit(void); /** initialize TWI port **/
78 | void vTWIWrite(byte adr, byte dat);
79 | byte bTWIRead(byte adr);
80 | void vTWIReset(void);
81 |
82 | private:
83 | void vTWIWriteByte(byte dat);
84 | byte bTWIReadByte(void);
85 | };
86 |
87 | #else
88 | #warning "HopeDuino_TWI.h have been defined!"
89 |
90 | #endif
--------------------------------------------------------------------------------
/libraries/HopeRFLib/example/lora_Rx/lora_rx.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * THE FOLLOWING FIRMWARE IS PROVIDED:
3 | * (1) "AS IS" WITH NO WARRANTY;
4 | * (2) TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
5 | * CONSEQUENTLY, HopeRF SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
6 | * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
7 | * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
8 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
9 | *
10 | * Copyright (C) HopeRF
11 | * website: www.HopeRF.com
12 | * www.HopeRF.cn
13 | *
14 | */
15 |
16 | /*!
17 | * file lora_rx.ino
18 | * hardware HopeDuino
19 | * software get message via HopeRF's LoRa COB, & send message to uart
20 | * note can talk to HopeRF's EVB or DK demo
21 | *
22 | * version 1.0
23 | * date Jun 10 2014
24 | * author QY Ruan
25 | */
26 |
27 | #include
28 | #include
29 |
30 | loraClass radio;
31 | uartClass uart;
32 |
33 | byte getstr[21];
34 |
35 | void setup()
36 | {
37 | radio.Modulation = LORA;
38 | radio.COB = RFM98;
39 | radio.Frequency = 434000;
40 | radio.OutputPower = 17; //17dBm OutputPower
41 | radio.PreambleLength = 16; //16Byte preamble
42 | radio.FixedPktLength = false; //explicit header mode for LoRa
43 | radio.PayloadLength = 21;
44 | radio.CrcDisable = false;
45 |
46 | radio.SFSel = SF9;
47 | radio.BWSel = BW125K;
48 | radio.CRSel = CR4_5;
49 |
50 | radio.vInitialize();
51 | radio.vGoRx();
52 | uart.vUartInit(9600, _8N1);
53 | }
54 |
55 | void loop()
56 | {
57 | if(radio.bGetMessage(getstr)!=0)
58 | {
59 | uart.vUartPutNByte(getstr, 21);
60 | uart.vUartNewLine();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/libraries/HopeRFLib/example/lora_Tx/lora_tx.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * THE FOLLOWING FIRMWARE IS PROVIDED:
3 | * (1) "AS IS" WITH NO WARRANTY;
4 | * (2) TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
5 | * CONSEQUENTLY, HopeRF SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
6 | * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
7 | * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
8 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
9 | *
10 | * Copyright (C) HopeRF
11 | * website: www.HopeRF.com
12 | * www.HopeRF.cn
13 | *
14 | */
15 |
16 | /*!
17 | * file lora_tx.ino
18 | * hardware HopeDuino
19 | * software send message via HopeRF's LoRa COB
20 | * note can talk to HopeRF's EVB or DK demo
21 | *
22 | * version 1.0
23 | * date Jun 10 2014
24 | * author QY Ruan
25 | */
26 |
27 | #include
28 |
29 |
30 | loraClass radio;
31 |
32 | byte str[21] = {'H','o','p','e','R','F',' ','R','F','M',' ','C','O','B','R','F','M','9','8','S'};
33 |
34 | void setup()
35 | {
36 | radio.Modulation = LORA;
37 | radio.COB = RFM98;
38 | radio.Frequency = 434000;
39 | radio.OutputPower = 17; //17dBm OutputPower
40 | radio.PreambleLength = 16; //16Byte preamble
41 | radio.FixedPktLength = false; //explicit header mode for LoRa
42 | radio.PayloadLength = 21;
43 | radio.CrcDisable = true;
44 |
45 | radio.SFSel = SF9;
46 | radio.BWSel = BW125K;
47 | radio.CRSel = CR4_5;
48 |
49 | radio.vInitialize();
50 | radio.vGoStandby();
51 | }
52 |
53 | void loop()
54 | {
55 | radio.bSendMessage(str, 21);
56 | delay(1000);
57 | }
58 |
--------------------------------------------------------------------------------
/libraries/HopeRFLib/example/rfm119_Tx/rfm119_Tx.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * THE FOLLOWING FIRMWARE IS PROVIDED:
3 | * (1) "AS IS" WITH NO WARRANTY;
4 | * (2) TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
5 | * CONSEQUENTLY, HopeRF SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
6 | * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
7 | * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
8 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
9 | *
10 | * Copyright (C) HopeRF
11 | * website: www.HopeRF.com
12 | * www.HopeRF.cn
13 | *
14 | */
15 |
16 | /*!
17 | * file rfm119_Tx.ino
18 | * hardware HopeDuino
19 | * software send message via rfm119
20 | * note
21 | *
22 | * version 1.0
23 | * date Feb 19 2016
24 | * author QY Ruan
25 | */
26 |
27 | #include
28 |
29 | cmt211xaClass radio;
30 |
31 | byte str[31] = {
32 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0x2D, 0xD4,
33 | 'H', 'o', 'p', 'e', 'R', 'F', ' ', 'R', 'F', 'M',
34 | ' ', 'C', 'O', 'B', 'R', 'F', 'M', '1', '1', '9',
35 | 'S',
36 | };
37 |
38 | word CfgTbl[21] = {
39 | 0x007F, // Mode = Advanced
40 | 0x1400, // Part Number = CMT2119A
41 | 0x0000, // Frequency = 434 MHz
42 | 0x0000, // Modulation = FSK
43 | 0x0000, // Symbol Rate = 0.5-100.0 ksps
44 | 0xF000, // Tx Power = +14 dBm
45 | 0x0000, // Deviation = 35.0 kHz
46 | 0xC4EC, // PA Ramping Time = NA
47 | 0x4208, // Xtal Cload = 15.00 pF
48 | 0x0160, // Data Representation = 0:F-low,1:F-high
49 | 0x2400, // Tx Start by = DATA Pin Falling Edge
50 | 0x0081, // Tx Stop by = DATA Pin Holding Low For 20 ms
51 | 0x8000, // Increase XO Current = No
52 | 0x0000, // FILE CRC = D150
53 | 0xFFFF,
54 | 0x0020,
55 | 0x5FE8,
56 | 0xA2D6,
57 | 0x0E13,
58 | 0x0019,
59 | 0x0000
60 | };
61 |
62 | void setup()
63 | {
64 | radio.Chipset = CMT2119A;
65 | radio.SymbolTime = 416;
66 | radio.vCMT2119AInit(CfgTbl, 21);
67 | radio.vEncode(str, 31, ENRZ);
68 | }
69 |
70 | void loop()
71 | {
72 | radio.vTxPacket();
73 | _delay_ms(100);
74 | }
75 |
--------------------------------------------------------------------------------
/libraries/HopeRFLib/example/rfm11x_Tx/rfm11x_Tx.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * THE FOLLOWING FIRMWARE IS PROVIDED:
3 | * (1) "AS IS" WITH NO WARRANTY;
4 | * (2) TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
5 | * CONSEQUENTLY, HopeRF SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
6 | * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
7 | * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
8 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
9 | *
10 | * Copyright (C) HopeRF
11 | * website: www.HopeRF.com
12 | * www.HopeRF.cn
13 | *
14 | */
15 |
16 | /*!
17 | * file rfm11x_tx.ino
18 | * hardware HopeDuino
19 | * software send message via rfm11x
20 | * note
21 | *
22 | * version 1.0
23 | * date Feb 19 2016
24 | * author QY Ruan
25 | */
26 |
27 | #include
28 |
29 | cmt211xaClass radio;
30 |
31 | byte str[7] = {'C', 'M', 'O', 'S', 'T', 'E', 'K'};
32 |
33 | void setup()
34 | {
35 | radio.Chipset = CMT2110A;
36 | radio.SymbolTime = 416;
37 | radio.vCMT211xAInit();
38 | radio.vEncode(str, 7, E527);
39 | }
40 |
41 | void loop()
42 | {
43 | radio.vTxPacket();
44 | _delay_ms(100);
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/libraries/HopeRFLib/example/rfm21x_Rx/rfm21x_Rx.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * THE FOLLOWING FIRMWARE IS PROVIDED:
3 | * (1) "AS IS" WITH NO WARRANTY;
4 | * (2) TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
5 | * CONSEQUENTLY, HopeRF SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
6 | * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
7 | * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
8 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
9 | *
10 | * Copyright (C) HopeRF
11 | * website: www.HopeRF.com
12 | * www.HopeRF.cn
13 | *
14 | */
15 |
16 | /*!
17 | * file rfm21x_rx.ino
18 | * hardware HopeDuino with RFM21x
19 | * software get message via rfm21x
20 | * note
21 | *
22 | * version 1.0
23 | * date Feb 19 2016
24 | * author QY Ruan
25 | */
26 |
27 | #include
28 | #include
29 |
30 | cmt221xaClass radio;
31 | uartClass uart;
32 |
33 | byte getstr[21];
34 | void setup()
35 | {
36 | radio.Chipset = CMT2210A;
37 | radio.SymbolTime = 416;
38 | radio.Decode = E527;
39 | radio.vCMT221xAInit();
40 | uart.vUartInit(9600, _8N1);
41 | }
42 |
43 | void loop()
44 | {
45 | byte i;
46 | if(radio.bGetMessage(getstr, 7)!=0)
47 | {
48 | uart.vUartPutNByte(getstr, 7);
49 | uart.vUartNewLine();
50 | for(i=0; i<7; i++)
51 | getstr[i] = 0x00;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/libraries/HopeRFLib/example/rfm21x_Rx_1527/rfm21x_Rx_1527.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * THE FOLLOWING FIRMWARE IS PROVIDED:
3 | * (1) "AS IS" WITH NO WARRANTY;
4 | * (2) TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
5 | * CONSEQUENTLY, HopeRF SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
6 | * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
7 | * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
8 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
9 | *
10 | * Copyright (C) HopeRF
11 | * website: www.HopeRF.com
12 | * www.HopeRF.cn
13 | *
14 | */
15 |
16 | /*!
17 | * file rfm21x_rx_1527.ino
18 | * hardware HopeDuino with RFM21x & CMOSTEK CMT2150A-EM
19 | * software get message via rfm21x
20 | * note
21 | *
22 | * version 1.0
23 | * date Mar 25 2016
24 | * author QY Ruan
25 | */
26 |
27 | #include
28 | #include
29 |
30 | cmt221xaClass radio;
31 | uartClass uart;
32 |
33 | byte getstr[3];
34 | byte sendstr[32];
35 | byte length;
36 | void setup()
37 | {
38 | radio.Chipset = CMT2210A;
39 | radio.SymbolTime = 416;
40 | radio.Decode = E527;
41 | radio.vCMT221xAInit();
42 | uart.vUartInit(9600, _8N1);
43 | }
44 |
45 | void loop()
46 | {
47 | byte i;
48 | if(radio.bGetMessage(getstr, 3)!=0)
49 | {
50 | for(i=0; i<3; i++)
51 | getstr[i] = bInverseByte(getstr[i]);
52 | vAnalysisMsg(getstr, sendstr);
53 | uart.vUartPutNByte(sendstr, length);
54 | uart.vUartNewLine();
55 | for(i=0; i<3; i++)
56 | getstr[i] = 0x00;
57 | }
58 | }
59 |
60 | void vAnalysisMsg(byte inptr[], byte outptr[]) //Analysis 1527 Code, assemble uart message
61 | {
62 | byte i, j;
63 | i = 0;
64 | outptr[i++] = 'I';
65 | outptr[i++] = 'D';
66 | outptr[i++] = ':';
67 | outptr[i++] = '0';
68 | outptr[i++] = 'x';
69 | for(j=0; j<2; j++)
70 | {
71 | outptr[i++] = bChangeToAscii(inptr[j]);
72 | outptr[i++] = bChangeToAscii((inptr[j]>>4));
73 | }
74 | outptr[i++] = bChangeToAscii(inptr[j]);
75 | outptr[i++] = ' ';
76 | outptr[i++] = 'K';
77 | outptr[i++] = 'E';
78 | outptr[i++] = 'Y';
79 | outptr[i++] = ':';
80 | outptr[i++] = '0';
81 | outptr[i++] = 'x';
82 | outptr[i++] = bChangeToAscii((inptr[j]>>4));
83 | length = i;
84 | }
85 |
86 | byte bInverseByte(byte inver) //Inverse buffer, just like 0x01 to 0x80
87 | {
88 | byte i, j, z;
89 | z = 0;
90 | j = 0x80;
91 | for(i=0x01;i!=0;i<<=1)
92 | {
93 | if(inver&i)
94 | z |= j;
95 | j >>= 1;
96 | }
97 | return(z);
98 | }
99 |
100 |
101 | byte bChangeToAscii(byte ch) //Change buffer to ASCII
102 | {
103 | ch &= 0x0F;
104 | if(ch<0x0A)
105 | ch += '0';
106 | else
107 | {
108 | ch -= 0x0A;
109 | ch += 'A';
110 | }
111 | return(ch);
112 | }
113 |
114 |
--------------------------------------------------------------------------------
/libraries/HopeRFLib/example/rfm66_Rx/rfm66_rx.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * THE FOLLOWING FIRMWARE IS PROVIDED:
3 | * (1) "AS IS" WITH NO WARRANTY;
4 | * (2) TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
5 | * CONSEQUENTLY, HopeRF SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
6 | * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
7 | * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
8 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
9 | *
10 | * Copyright (C) HopeRF
11 | * website: www.HopeRF.com
12 | * www.HopeRF.cn
13 | *
14 | */
15 |
16 | /*!
17 | * file rfm66_rx.ino
18 | * hardware HopeDuino
19 | * software get message via rfm66, & send message to uart
20 | * note can talk to HopeRF's EVB or DK demo
21 | *
22 | * version 1.0
23 | * date Jun 10 2014
24 | * author QY Ruan
25 | */
26 |
27 | #include
28 | #include
29 |
30 | rf66Class radio;
31 | uartClass uart;
32 |
33 | byte getstr[21];
34 | void setup()
35 | {
36 | radio.Modulation = FSK;
37 | radio.Frequency = 868000; //note: rfm66 only for 868MHz or 915MHz
38 | radio.OutputPower = 15; //10dBm OutputPower
39 | radio.PreambleLength = 16; //16Byte preamble
40 | radio.FixedPktLength = true; //packet length didn't in message which need to be send
41 | radio.PayloadLength = 21;
42 | radio.CrcDisable = true;
43 |
44 | radio.SymbolTime = 416000; //2.4Kbps
45 | radio.Devation = 35; //35KHz for devation
46 | radio.BandWidth = 100; //100KHz for bandwidth
47 | radio.SyncLength = 3; //
48 | radio.SyncWord[0] = 0xAA;
49 | radio.SyncWord[1] = 0x2D;
50 | radio.SyncWord[2] = 0xD4;
51 | radio.vInitialize();
52 | radio.vGoRx();
53 | uart.vUartInit(9600, _8N1);
54 | }
55 |
56 | void loop()
57 | {
58 | if(radio.bGetMessage(getstr)!=0)
59 | {
60 | uart.vUartPutNByte(getstr, 21);
61 | uart.vUartNewLine();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/libraries/HopeRFLib/example/rfm66_Tx/rfm66_tx.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * THE FOLLOWING FIRMWARE IS PROVIDED:
3 | * (1) "AS IS" WITH NO WARRANTY;
4 | * (2) TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
5 | * CONSEQUENTLY, HopeRF SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
6 | * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
7 | * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
8 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
9 | *
10 | * Copyright (C) HopeRF
11 | * website: www.HopeRF.com
12 | * www.HopeRF.cn
13 | *
14 | */
15 |
16 | /*!
17 | * file rfm66_tx.ino
18 | * hardware HopeDuino
19 | * software send message via rfm66
20 | * note can talk to HopeRF's EVB or DK demo
21 | *
22 | * version 1.0
23 | * date Jun 10 2014
24 | * author QY Ruan
25 | */
26 |
27 | #include
28 |
29 | rf66Class radio;
30 |
31 | byte str[21] = {'H','o','p','e','R','F',' ','R','F','M',' ','C','O','B','R','F','M','6','6','S'};
32 |
33 | void setup()
34 | {
35 | radio.Modulation = FSK;
36 | radio.Frequency = 868000; //note: rfm66 only for 868MHz or 915MHz
37 | radio.OutputPower = 15; //15dBm OutputPower
38 | radio.PreambleLength = 16; //16Byte preamble
39 | radio.FixedPktLength = true; //packet length didn't in message which need to be send
40 | radio.PayloadLength = 21;
41 | radio.CrcDisable = true;
42 |
43 | radio.SymbolTime = 416000; //2.4Kbps
44 | radio.Devation = 35; //35KHz for devation
45 | radio.BandWidth = 100; //100KHz for bandwidth
46 | radio.SyncLength = 3; //
47 | radio.SyncWord[0] = 0xAA;
48 | radio.SyncWord[1] = 0x2D;
49 | radio.SyncWord[2] = 0xD4;
50 | radio.vInitialize();
51 | radio.vGoStandby();
52 | }
53 |
54 | void loop()
55 | {
56 | radio.bSendMessage(str, 21);
57 | delay(1000);
58 | }
59 |
--------------------------------------------------------------------------------
/libraries/HopeRFLib/example/rfm69_Rx/rfm69_rx.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * THE FOLLOWING FIRMWARE IS PROVIDED:
3 | * (1) "AS IS" WITH NO WARRANTY;
4 | * (2) TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
5 | * CONSEQUENTLY, HopeRF SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
6 | * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
7 | * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
8 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
9 | *
10 | * Copyright (C) HopeRF
11 | * website: www.HopeRF.com
12 | * www.HopeRF.cn
13 | *
14 | */
15 |
16 | /*!
17 | * file rfm69_rx.ino
18 | * hardware HopeRF's RFduino TRx
19 | * software get message via rfm69, & send message to uart
20 | * note can talk to HopeRF's EVB or DK demo
21 | *
22 | * version 1.0
23 | * date Jun 10 2014
24 | * author QY Ruan
25 | */
26 |
27 | #include
28 | #include
29 |
30 | rf69Class radio;
31 | uartClass uart;
32 |
33 | byte getstr[21];
34 | void setup()
35 | {
36 | radio.Modulation = FSK;
37 | radio.COB = RFM69;
38 | radio.Frequency = 434000;
39 | radio.OutputPower = 10+18; //10dBm OutputPower
40 | radio.PreambleLength = 16; //16Byte preamble
41 | radio.FixedPktLength = true; //packet length didn't in message which need to be send
42 | radio.PayloadLength = 21;
43 | radio.CrcDisable = true;
44 | radio.AesOn = false;
45 |
46 | radio.SymbolTime = 416000; //2.4Kbps
47 | radio.Devation = 35; //35KHz for devation
48 | radio.BandWidth = 100; //100KHz for bandwidth
49 | radio.SyncLength = 3; //
50 | radio.SyncWord[0] = 0xAA;
51 | radio.SyncWord[1] = 0x2D;
52 | radio.SyncWord[2] = 0xD4;
53 | radio.vInitialize();
54 | radio.vGoRx();
55 | uart.vUartInit(9600, _8N1);
56 | }
57 |
58 | void loop()
59 | {
60 | if(radio.bGetMessage(getstr)!=0)
61 | {
62 | uart.vUartPutNByte(getstr, 21);
63 | uart.vUartNewLine();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/libraries/HopeRFLib/example/rfm69_Tx/rfm69_tx.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * THE FOLLOWING FIRMWARE IS PROVIDED:
3 | * (1) "AS IS" WITH NO WARRANTY;
4 | * (2) TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
5 | * CONSEQUENTLY, HopeRF SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
6 | * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
7 | * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
8 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
9 | *
10 | * Copyright (C) HopeRF
11 | * website: www.HopeRF.com
12 | * www.HopeRF.cn
13 | *
14 | */
15 |
16 | /*!
17 | * file rfm69_tx.ino
18 | * hardware HopeDuino
19 | * software send message via rfm69
20 | * note can talk to HopeRF's EVB or DK demo
21 | *
22 | * version 1.0
23 | * date Jun 10 2014
24 | * author QY Ruan
25 | */
26 |
27 | #include
28 |
29 | rf69Class radio;
30 |
31 | byte str[21] = {'H','o','p','e','R','F',' ','R','F','M',' ','C','O','B','R','F','M','6','9','S'};
32 |
33 | void setup()
34 | {
35 | radio.Modulation = FSK;
36 | radio.COB = RFM69;
37 | radio.Frequency = 434000;
38 | radio.OutputPower = 10+18; //10dBm OutputPower
39 | radio.PreambleLength = 16; //16Byte preamble
40 | radio.FixedPktLength = true; //packet length didn't in message which need to be send
41 | radio.PayloadLength = 21;
42 | radio.CrcDisable = true;
43 | radio.AesOn = false;
44 |
45 | radio.SymbolTime = 416000; //2.4Kbps
46 | radio.Devation = 35; //35KHz for devation
47 | radio.BandWidth = 100; //100KHz for bandwidth
48 | radio.SyncLength = 3; //
49 | radio.SyncWord[0] = 0xAA;
50 | radio.SyncWord[1] = 0x2D;
51 | radio.SyncWord[2] = 0xD4;
52 | radio.vInitialize();
53 | radio.vGoStandby();
54 | }
55 |
56 | void loop()
57 | {
58 | radio.bSendMessage(str, 21);
59 | delay(1000);
60 | }
61 |
--------------------------------------------------------------------------------
/libraries/RadioHead/LICENSE:
--------------------------------------------------------------------------------
1 | This software is Copyright (C) 2008 Mike McCauley. Use is subject to license
2 | conditions. The main licensing options available are GPL V2 or Commercial:
3 |
4 | Open Source Licensing GPL V2
5 |
6 | This is the appropriate option if you want to share the source code of your
7 | application with everyone you distribute it to, and you also want to give them
8 | the right to share who uses it. If you wish to use this software under Open
9 | Source Licensing, you must contribute all your source code to the open source
10 | community in accordance with the GPL Version 2 when your application is
11 | distributed. See http://www.gnu.org/copyleft/gpl.html
12 |
13 | Commercial Licensing
14 |
15 | This is the appropriate option if you are creating proprietary applications
16 | and you are not prepared to distribute and share the source code of your
17 | application. Contact info@open.com.au for details.
18 |
--------------------------------------------------------------------------------
/libraries/RadioHead/RHCRC.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2002, 2003, 2004 Marek Michalkiewicz
2 | Copyright (c) 2005, 2007 Joerg Wunsch
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | * Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 |
11 | * Redistributions in binary form must reproduce the above copyright
12 | notice, this list of conditions and the following disclaimer in
13 | the documentation and/or other materials provided with the
14 | distribution.
15 |
16 | * Neither the name of the copyright holders nor the names of
17 | contributors may be used to endorse or promote products derived
18 | from this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 | POSSIBILITY OF SUCH DAMAGE. */
31 |
32 | // Port to Energia / MPS430 by Yannick DEVOS XV4Y - (c) 2013
33 | // http://xv4y.radioclub.asia/
34 | //
35 |
36 | // Adapted to RadioHead use by Mike McCauley 2014
37 | // This is to prevent name collisions with other similar library functions
38 | // and to provide a consistent API amonng all processors
39 | //
40 |
41 | /* $Id: RHCRC.cpp,v 1.1 2014/06/24 02:40:12 mikem Exp $ */
42 |
43 | #include
44 |
45 | #define lo8(x) ((x)&0xff)
46 | #define hi8(x) ((x)>>8)
47 |
48 | uint16_t RHcrc16_update(uint16_t crc, uint8_t a)
49 | {
50 | int i;
51 |
52 | crc ^= a;
53 | for (i = 0; i < 8; ++i)
54 | {
55 | if (crc & 1)
56 | crc = (crc >> 1) ^ 0xA001;
57 | else
58 | crc = (crc >> 1);
59 | }
60 | return crc;
61 | }
62 |
63 | uint16_t RHcrc_xmodem_update (uint16_t crc, uint8_t data)
64 | {
65 | int i;
66 |
67 | crc = crc ^ ((uint16_t)data << 8);
68 | for (i=0; i<8; i++)
69 | {
70 | if (crc & 0x8000)
71 | crc = (crc << 1) ^ 0x1021;
72 | else
73 | crc <<= 1;
74 | }
75 |
76 | return crc;
77 | }
78 |
79 | uint16_t RHcrc_ccitt_update (uint16_t crc, uint8_t data)
80 | {
81 | data ^= lo8 (crc);
82 | data ^= data << 4;
83 |
84 | return ((((uint16_t)data << 8) | hi8 (crc)) ^ (uint8_t)(data >> 4)
85 | ^ ((uint16_t)data << 3));
86 | }
87 |
88 | uint8_t RHcrc_ibutton_update(uint8_t crc, uint8_t data)
89 | {
90 | uint8_t i;
91 |
92 | crc = crc ^ data;
93 | for (i = 0; i < 8; i++)
94 | {
95 | if (crc & 0x01)
96 | crc = (crc >> 1) ^ 0x8C;
97 | else
98 | crc >>= 1;
99 | }
100 |
101 | return crc;
102 | }
103 |
104 |
105 |
--------------------------------------------------------------------------------
/libraries/RadioHead/RHCRC.h:
--------------------------------------------------------------------------------
1 | // RHCRC.h
2 | //
3 | // Definitions for RadioHead compatible CRC outines.
4 | //
5 | // These routines originally derived from Arduino source code. See RHCRC.cpp
6 | // for copyright information
7 | // $Id: RHCRC.h,v 1.1 2014/06/24 02:40:12 mikem Exp $
8 |
9 | #ifndef RHCRC_h
10 | #define RHCRC_h
11 |
12 | #include
13 |
14 | extern uint16_t RHcrc16_update(uint16_t crc, uint8_t a);
15 | extern uint16_t RHcrc_xmodem_update (uint16_t crc, uint8_t data);
16 | extern uint16_t RHcrc_ccitt_update (uint16_t crc, uint8_t data);
17 | extern uint8_t RHcrc_ibutton_update(uint8_t crc, uint8_t data);
18 |
19 | #endif
20 |
--------------------------------------------------------------------------------
/libraries/RadioHead/RHDatagram.cpp:
--------------------------------------------------------------------------------
1 | // RHDatagram.cpp
2 | //
3 | // Copyright (C) 2011 Mike McCauley
4 | // $Id: RHDatagram.cpp,v 1.6 2014/05/23 02:20:17 mikem Exp $
5 |
6 | #include
7 |
8 | RHDatagram::RHDatagram(RHGenericDriver& driver, uint8_t thisAddress)
9 | :
10 | _driver(driver),
11 | _thisAddress(thisAddress)
12 | {
13 | }
14 |
15 | ////////////////////////////////////////////////////////////////////
16 | // Public methods
17 | bool RHDatagram::init()
18 | {
19 | bool ret = _driver.init();
20 | if (ret)
21 | setThisAddress(_thisAddress);
22 | return ret;
23 | }
24 |
25 | void RHDatagram::setThisAddress(uint8_t thisAddress)
26 | {
27 | _driver.setThisAddress(thisAddress);
28 | // Use this address in the transmitted FROM header
29 | setHeaderFrom(thisAddress);
30 | _thisAddress = thisAddress;
31 | }
32 |
33 | bool RHDatagram::sendto(uint8_t* buf, uint8_t len, uint8_t address)
34 | {
35 | setHeaderTo(address);
36 | return _driver.send(buf, len);
37 | }
38 |
39 | bool RHDatagram::recvfrom(uint8_t* buf, uint8_t* len, uint8_t* from, uint8_t* to, uint8_t* id, uint8_t* flags)
40 | {
41 | if (_driver.recv(buf, len))
42 | {
43 | if (from) *from = headerFrom();
44 | if (to) *to = headerTo();
45 | if (id) *id = headerId();
46 | if (flags) *flags = headerFlags();
47 | return true;
48 | }
49 | return false;
50 | }
51 |
52 | bool RHDatagram::available()
53 | {
54 | return _driver.available();
55 | }
56 |
57 | void RHDatagram::waitAvailable()
58 | {
59 | _driver.waitAvailable();
60 | }
61 |
62 | bool RHDatagram::waitPacketSent()
63 | {
64 | return _driver.waitPacketSent();
65 | }
66 |
67 | bool RHDatagram::waitPacketSent(uint16_t timeout)
68 | {
69 | return _driver.waitPacketSent(timeout);
70 | }
71 |
72 | bool RHDatagram::waitAvailableTimeout(uint16_t timeout)
73 | {
74 | return _driver.waitAvailableTimeout(timeout);
75 | }
76 |
77 | uint8_t RHDatagram::thisAddress()
78 | {
79 | return _thisAddress;
80 | }
81 |
82 | void RHDatagram::setHeaderTo(uint8_t to)
83 | {
84 | _driver.setHeaderTo(to);
85 | }
86 |
87 | void RHDatagram::setHeaderFrom(uint8_t from)
88 | {
89 | _driver.setHeaderFrom(from);
90 | }
91 |
92 | void RHDatagram::setHeaderId(uint8_t id)
93 | {
94 | _driver.setHeaderId(id);
95 | }
96 |
97 | void RHDatagram::setHeaderFlags(uint8_t set, uint8_t clear)
98 | {
99 | _driver.setHeaderFlags(set, clear);
100 | }
101 |
102 | uint8_t RHDatagram::headerTo()
103 | {
104 | return _driver.headerTo();
105 | }
106 |
107 | uint8_t RHDatagram::headerFrom()
108 | {
109 | return _driver.headerFrom();
110 | }
111 |
112 | uint8_t RHDatagram::headerId()
113 | {
114 | return _driver.headerId();
115 | }
116 |
117 | uint8_t RHDatagram::headerFlags()
118 | {
119 | return _driver.headerFlags();
120 | }
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/libraries/RadioHead/RHGenericSPI.cpp:
--------------------------------------------------------------------------------
1 | // RHGenericSPI.cpp
2 | // Author: Mike McCauley (mikem@airspayce.com)
3 | // Copyright (C) 2011 Mike McCauley
4 | // Contributed by Joanna Rutkowska
5 | // $Id: RHGenericSPI.cpp,v 1.2 2014/04/12 05:26:05 mikem Exp $
6 |
7 | #include
8 |
9 | RHGenericSPI::RHGenericSPI(Frequency frequency, BitOrder bitOrder, DataMode dataMode)
10 | :
11 | _frequency(frequency),
12 | _bitOrder(bitOrder),
13 | _dataMode(dataMode)
14 | {
15 | }
16 |
17 | void RHGenericSPI::setBitOrder(BitOrder bitOrder)
18 | {
19 | _bitOrder = bitOrder;
20 | }
21 |
22 | void RHGenericSPI::setDataMode(DataMode dataMode)
23 | {
24 | _dataMode = dataMode;
25 | }
26 |
27 | void RHGenericSPI::setFrequency(Frequency frequency)
28 | {
29 | _frequency = frequency;
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/libraries/RadioHead/RHHardwareSPI.h:
--------------------------------------------------------------------------------
1 | // RHHardwareSPI.h
2 | // Author: Mike McCauley (mikem@airspayce.com)
3 | // Copyright (C) 2011 Mike McCauley
4 | // Contributed by Joanna Rutkowska
5 | // $Id: RHHardwareSPI.h,v 1.9 2014/08/12 00:54:52 mikem Exp $
6 |
7 | #ifndef RHHardwareSPI_h
8 | #define RHHardwareSPI_h
9 |
10 | #include
11 |
12 | /////////////////////////////////////////////////////////////////////
13 | /// \class RHHardwareSPI RHHardwareSPI.h
14 | /// \brief Encapsulate a hardware SPI bus interface
15 | ///
16 | /// This concrete subclass of GenericSPIClass encapsulates the standard Arduino hardware and other
17 | /// hardware SPI interfaces.
18 | class RHHardwareSPI : public RHGenericSPI
19 | {
20 | #ifdef RH_HAVE_HARDWARE_SPI
21 | public:
22 | /// Constructor
23 | /// Creates an instance of a hardware SPI interface, using whatever SPI hardware is available on
24 | /// your processor platform. On Arduino and Uno32, uses SPI. On Maple, uses HardwareSPI.
25 | /// \param[in] frequency One of RHGenericSPI::Frequency to select the SPI bus frequency. The frequency
26 | /// is mapped to the closest available bus frequency on the platform.
27 | /// \param[in] bitOrder Select the SPI bus bit order, one of RHGenericSPI::BitOrderMSBFirst or
28 | /// RHGenericSPI::BitOrderLSBFirst.
29 | /// \param[in] dataMode Selects the SPI bus data mode. One of RHGenericSPI::DataMode
30 | RHHardwareSPI(Frequency frequency = Frequency1MHz, BitOrder bitOrder = BitOrderMSBFirst, DataMode dataMode = DataMode0);
31 |
32 | /// Transfer a single octet to and from the SPI interface
33 | /// \param[in] data The octet to send
34 | /// \return The octet read from SPI while the data octet was sent
35 | uint8_t transfer(uint8_t data);
36 |
37 | // SPI Configuration methods
38 | /// Enable SPI interrupts
39 | /// This can be used in an SPI slave to indicate when an SPI message has been received
40 | /// It will cause the SPI_STC_vect interrupt vectr to be executed
41 | void attachInterrupt();
42 |
43 | /// Disable SPI interrupts
44 | /// This can be used to diable the SPI interrupt in slaves where that is supported.
45 | void detachInterrupt();
46 |
47 | /// Initialise the SPI library
48 | /// Call this after configuring the SPI interface and before using it to transfer data.
49 | /// Initializes the SPI bus by setting SCK, MOSI, and SS to outputs, pulling SCK and MOSI low, and SS high.
50 | void begin();
51 |
52 | /// Disables the SPI bus (leaving pin modes unchanged).
53 | /// Call this after you have finished using the SPI interface.
54 | void end();
55 | #else
56 | // not supported on ATTiny etc
57 | uint8_t transfer(uint8_t data) {return 0;}
58 | void begin(){}
59 | void end(){}
60 |
61 | #endif
62 | };
63 |
64 | // Built in default instance
65 | extern RHHardwareSPI hardware_spi;
66 |
67 | #endif
68 |
--------------------------------------------------------------------------------
/libraries/RadioHead/RHNRFSPIDriver.cpp:
--------------------------------------------------------------------------------
1 | // RHNRFSPIDriver.cpp
2 | //
3 | // Copyright (C) 2014 Mike McCauley
4 | // $Id: RHNRFSPIDriver.cpp,v 1.3 2015/12/16 04:55:33 mikem Exp $
5 |
6 | #include
7 |
8 | RHNRFSPIDriver::RHNRFSPIDriver(uint8_t slaveSelectPin, RHGenericSPI& spi)
9 | :
10 | _spi(spi),
11 | _slaveSelectPin(slaveSelectPin)
12 | {
13 | }
14 |
15 | bool RHNRFSPIDriver::init()
16 | {
17 | // start the SPI library with the default speeds etc:
18 | // On Arduino Due this defaults to SPI1 on the central group of 6 SPI pins
19 | _spi.begin();
20 |
21 | // Initialise the slave select pin
22 | // On Maple, this must be _after_ spi.begin
23 | pinMode(_slaveSelectPin, OUTPUT);
24 | digitalWrite(_slaveSelectPin, HIGH);
25 |
26 | delay(100);
27 | return true;
28 | }
29 |
30 | // Low level commands for interfacing with the device
31 | uint8_t RHNRFSPIDriver::spiCommand(uint8_t command)
32 | {
33 | uint8_t status;
34 | ATOMIC_BLOCK_START;
35 | digitalWrite(_slaveSelectPin, LOW);
36 | status = _spi.transfer(command);
37 | digitalWrite(_slaveSelectPin, HIGH);
38 | ATOMIC_BLOCK_END;
39 | return status;
40 | }
41 |
42 | uint8_t RHNRFSPIDriver::spiRead(uint8_t reg)
43 | {
44 | uint8_t val;
45 | ATOMIC_BLOCK_START;
46 | digitalWrite(_slaveSelectPin, LOW);
47 | _spi.transfer(reg); // Send the address, discard the status
48 | val = _spi.transfer(0); // The written value is ignored, reg value is read
49 | digitalWrite(_slaveSelectPin, HIGH);
50 | ATOMIC_BLOCK_END;
51 | return val;
52 | }
53 |
54 | uint8_t RHNRFSPIDriver::spiWrite(uint8_t reg, uint8_t val)
55 | {
56 | uint8_t status = 0;
57 | ATOMIC_BLOCK_START;
58 | digitalWrite(_slaveSelectPin, LOW);
59 | status = _spi.transfer(reg); // Send the address
60 | _spi.transfer(val); // New value follows
61 | #if (RH_PLATFORM == RH_PLATFORM_ARDUINO) && defined(__arm__) && defined(CORE_TEENSY)
62 | // Sigh: some devices, such as MRF89XA dont work properly on Teensy 3.1:
63 | // At 1MHz, the clock returns low _after_ slave select goes high, which prevents SPI
64 | // write working. This delay gixes time for the clock to return low.
65 | delayMicroseconds(5);
66 | #endif
67 | digitalWrite(_slaveSelectPin, HIGH);
68 | ATOMIC_BLOCK_END;
69 | return status;
70 | }
71 |
72 | uint8_t RHNRFSPIDriver::spiBurstRead(uint8_t reg, uint8_t* dest, uint8_t len)
73 | {
74 | uint8_t status = 0;
75 | ATOMIC_BLOCK_START;
76 | digitalWrite(_slaveSelectPin, LOW);
77 | status = _spi.transfer(reg); // Send the start address
78 | while (len--)
79 | *dest++ = _spi.transfer(0);
80 | digitalWrite(_slaveSelectPin, HIGH);
81 | ATOMIC_BLOCK_END;
82 | return status;
83 | }
84 |
85 | uint8_t RHNRFSPIDriver::spiBurstWrite(uint8_t reg, const uint8_t* src, uint8_t len)
86 | {
87 | uint8_t status = 0;
88 | ATOMIC_BLOCK_START;
89 | digitalWrite(_slaveSelectPin, LOW);
90 | status = _spi.transfer(reg); // Send the start address
91 | while (len--)
92 | _spi.transfer(*src++);
93 | digitalWrite(_slaveSelectPin, HIGH);
94 | ATOMIC_BLOCK_END;
95 | return status;
96 | }
97 |
98 | void RHNRFSPIDriver::setSlaveSelectPin(uint8_t slaveSelectPin)
99 | {
100 | _slaveSelectPin = slaveSelectPin;
101 | }
102 |
103 |
104 |
--------------------------------------------------------------------------------
/libraries/RadioHead/RHSPIDriver.cpp:
--------------------------------------------------------------------------------
1 | // RHSPIDriver.cpp
2 | //
3 | // Copyright (C) 2014 Mike McCauley
4 | // $Id: RHSPIDriver.cpp,v 1.10 2015/12/16 04:55:33 mikem Exp $
5 |
6 | #include
7 |
8 | RHSPIDriver::RHSPIDriver(uint8_t slaveSelectPin, RHGenericSPI& spi)
9 | :
10 | _spi(spi),
11 | _slaveSelectPin(slaveSelectPin)
12 | {
13 | }
14 |
15 | bool RHSPIDriver::init()
16 | {
17 | // start the SPI library with the default speeds etc:
18 | // On Arduino Due this defaults to SPI1 on the central group of 6 SPI pins
19 | _spi.begin();
20 |
21 | // Initialise the slave select pin
22 | // On Maple, this must be _after_ spi.begin
23 | pinMode(_slaveSelectPin, OUTPUT);
24 | digitalWrite(_slaveSelectPin, HIGH);
25 |
26 | delay(100);
27 | return true;
28 | }
29 |
30 | uint8_t RHSPIDriver::spiRead(uint8_t reg)
31 | {
32 | uint8_t val;
33 | ATOMIC_BLOCK_START;
34 | digitalWrite(_slaveSelectPin, LOW);
35 | _spi.transfer(reg & ~RH_SPI_WRITE_MASK); // Send the address with the write mask off
36 | val = _spi.transfer(0); // The written value is ignored, reg value is read
37 | digitalWrite(_slaveSelectPin, HIGH);
38 | ATOMIC_BLOCK_END;
39 | return val;
40 | }
41 |
42 | uint8_t RHSPIDriver::spiWrite(uint8_t reg, uint8_t val)
43 | {
44 | uint8_t status = 0;
45 | ATOMIC_BLOCK_START;
46 | digitalWrite(_slaveSelectPin, LOW);
47 | status = _spi.transfer(reg | RH_SPI_WRITE_MASK); // Send the address with the write mask on
48 | _spi.transfer(val); // New value follows
49 | digitalWrite(_slaveSelectPin, HIGH);
50 | ATOMIC_BLOCK_END;
51 | return status;
52 | }
53 |
54 | uint8_t RHSPIDriver::spiBurstRead(uint8_t reg, uint8_t* dest, uint8_t len)
55 | {
56 | uint8_t status = 0;
57 | ATOMIC_BLOCK_START;
58 | digitalWrite(_slaveSelectPin, LOW);
59 | status = _spi.transfer(reg & ~RH_SPI_WRITE_MASK); // Send the start address with the write mask off
60 | while (len--)
61 | *dest++ = _spi.transfer(0);
62 | digitalWrite(_slaveSelectPin, HIGH);
63 | ATOMIC_BLOCK_END;
64 | return status;
65 | }
66 |
67 | uint8_t RHSPIDriver::spiBurstWrite(uint8_t reg, const uint8_t* src, uint8_t len)
68 | {
69 | uint8_t status = 0;
70 | ATOMIC_BLOCK_START;
71 | digitalWrite(_slaveSelectPin, LOW);
72 | status = _spi.transfer(reg | RH_SPI_WRITE_MASK); // Send the start address with the write mask on
73 | while (len--)
74 | _spi.transfer(*src++);
75 | digitalWrite(_slaveSelectPin, HIGH);
76 | ATOMIC_BLOCK_END;
77 | return status;
78 | }
79 |
80 | void RHSPIDriver::setSlaveSelectPin(uint8_t slaveSelectPin)
81 | {
82 | _slaveSelectPin = slaveSelectPin;
83 | }
84 |
--------------------------------------------------------------------------------
/libraries/RadioHead/RHTcpProtocol.h:
--------------------------------------------------------------------------------
1 | // RH_TcpProtocol.h
2 | // Author: Mike McCauley (mikem@aierspayce.com)
3 | // Definition of protocol messages sent and received by RH_TCP
4 | // Copyright (C) 2014 Mike McCauley
5 | // $Id: RHTcpProtocol.h,v 1.3 2014/05/22 06:07:09 mikem Exp $
6 |
7 | /// This file contains the definitions of message structures passed between
8 | /// RH_TCP and the etherSimulator
9 | #ifndef RH_TcpProtocol_h
10 | #define RH_TcpProtocol_h
11 |
12 | #define RH_TCP_MESSAGE_TYPE_NOP 0
13 | #define RH_TCP_MESSAGE_TYPE_THISADDRESS 1
14 | #define RH_TCP_MESSAGE_TYPE_PACKET 2
15 |
16 | // Maximum message length (including the headers) we are willing to support
17 | #define RH_TCP_MAX_PAYLOAD_LEN 255
18 |
19 | // The length of the headers we add.
20 | // The headers are inside the RF69's payload and are therefore encrypted if encryption is enabled
21 | #define RH_TCP_HEADER_LEN 4
22 |
23 |
24 | // This is the maximum message length that can be supported by this protocol.
25 | #define RH_TCP_MAX_MESSAGE_LEN (RH_TCP_MAX_PAYLOAD_LEN - RH_TCP_HEADER_LEN)
26 |
27 | #pragma pack(push, 1) // No padding
28 |
29 | /// \brief Generic RH_TCP simulator message structure
30 | typedef struct
31 | {
32 | uint32_t length; ///< Number of octets following, in network byte order
33 | uint8_t payload[RH_TCP_MAX_PAYLOAD_LEN + 1]; ///< Payload
34 | } RHTcpMessage;
35 |
36 | /// \brief Generic RH_TCP message structure with message type
37 | typedef struct
38 | {
39 | uint32_t length; ///< Number of octets following, in network byte order
40 | uint8_t type; ///< One of RH_TCP_MESSAGE_TYPE_*
41 | uint8_t payload[RH_TCP_MAX_PAYLOAD_LEN]; ///< Payload
42 | } RHTcpTypeMessage;
43 |
44 | /// \brief RH_TCP message Notifies the server of thisAddress of this client
45 | typedef struct
46 | {
47 | uint32_t length; ///< Number of octets following, in network byte order
48 | uint8_t type; ///< == RH_TCP_MESSAGE_TYPE_THISADDRESS
49 | uint8_t thisAddress; ///< Node address
50 | } RHTcpThisAddress;
51 |
52 | /// \brief RH_TCP radio message passed to or from the simulator
53 | typedef struct
54 | {
55 | uint32_t length; ///< Number of octets following, in network byte order
56 | uint8_t type; ///< == RH_TCP_MESSAGE_TYPE_PACKET
57 | uint8_t to; ///< Node address of the recipient
58 | uint8_t from; ///< Node address of the sender
59 | uint8_t id; ///< Message sequence number
60 | uint8_t flags; ///< Message flags
61 | uint8_t payload[RH_TCP_MAX_MESSAGE_LEN]; ///< 0 or more, length deduced from length above
62 | } RHTcpPacket;
63 |
64 | #pragma pack(pop)
65 |
66 | #endif
67 |
--------------------------------------------------------------------------------
/libraries/RadioHead/RHutil/RasPi.h:
--------------------------------------------------------------------------------
1 | // RasPi.h
2 | //
3 | // Routines for implementing RadioHead on Raspberry Pi
4 | // using BCM2835 library for GPIO
5 | // Contributed by Mike Poublon and used with permission
6 |
7 | #ifndef RASPI_h
8 | #define RASPI_h
9 |
10 | #include
11 |
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 | typedef unsigned char byte;
18 |
19 | #ifndef NULL
20 | #define NULL 0
21 | #endif
22 |
23 | #ifndef OUTPUT
24 | #define OUTPUT BCM2835_GPIO_FSEL_OUTP
25 | #endif
26 |
27 | class SPIClass
28 | {
29 | public:
30 | static byte transfer(byte _data);
31 | // SPI Configuration methods
32 | static void begin(); // Default
33 | static void begin(uint16_t, uint8_t, uint8_t);
34 | static void end();
35 | static void setBitOrder(uint8_t);
36 | static void setDataMode(uint8_t);
37 | static void setClockDivider(uint16_t);
38 | };
39 |
40 | extern SPIClass SPI;
41 |
42 | class SerialSimulator
43 | {
44 | public:
45 | #define DEC 10
46 | #define HEX 16
47 | #define OCT 8
48 | #define BIN 2
49 |
50 | // TODO: move these from being inlined
51 | static void begin(int baud);
52 | static size_t println(const char* s);
53 | static size_t print(const char* s);
54 | static size_t print(unsigned int n, int base = DEC);
55 | static size_t print(char ch);
56 | static size_t println(char ch);
57 | static size_t print(unsigned char ch, int base = DEC);
58 | static size_t println(unsigned char ch, int base = DEC);
59 | };
60 |
61 | extern SerialSimulator Serial;
62 |
63 | void RasPiSetup();
64 |
65 | void pinMode(unsigned char pin, unsigned char mode);
66 |
67 | void digitalWrite(unsigned char pin, unsigned char value);
68 |
69 | unsigned long millis();
70 |
71 | void delay (unsigned long delay);
72 |
73 | long random(long min, long max);
74 |
75 | #endif
76 |
--------------------------------------------------------------------------------
/libraries/RadioHead/RHutil/atomic.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This is port of Dean Camera's ATOMIC_BLOCK macros for AVR to ARM Cortex M3
3 | * v1.0
4 | * Mark Pendrith, Nov 27, 2012.
5 | *
6 | * From Mark:
7 | * >When I ported the macros I emailed Dean to ask what attribution would be
8 | * >appropriate, and here is his response:
9 | * >
10 | * >>Mark,
11 | * >>I think it's great that you've ported the macros; consider them
12 | * >>public domain, to do with whatever you wish. I hope you find them >useful .
13 | * >>
14 | * >>Cheers!
15 | * >>- Dean
16 | */
17 |
18 | #ifdef __arm__
19 | #ifndef _CORTEX_M3_ATOMIC_H_
20 | #define _CORTEX_M3_ATOMIC_H_
21 |
22 | static __inline__ uint32_t __get_primask(void) \
23 | { uint32_t primask = 0; \
24 | __asm__ volatile ("MRS %[result], PRIMASK\n\t":[result]"=r"(primask)::); \
25 | return primask; } // returns 0 if interrupts enabled, 1 if disabled
26 |
27 | static __inline__ void __set_primask(uint32_t setval) \
28 | { __asm__ volatile ("MSR PRIMASK, %[value]\n\t""dmb\n\t""dsb\n\t""isb\n\t"::[value]"r"(setval):);
29 | __asm__ volatile ("" ::: "memory");}
30 |
31 | static __inline__ uint32_t __iSeiRetVal(void) \
32 | { __asm__ volatile ("CPSIE i\n\t""dmb\n\t""dsb\n\t""isb\n\t"); \
33 | __asm__ volatile ("" ::: "memory"); return 1; }
34 |
35 | static __inline__ uint32_t __iCliRetVal(void) \
36 | { __asm__ volatile ("CPSID i\n\t""dmb\n\t""dsb\n\t""isb\n\t"); \
37 | __asm__ volatile ("" ::: "memory"); return 1; }
38 |
39 | static __inline__ void __iSeiParam(const uint32_t *__s) \
40 | { __asm__ volatile ("CPSIE i\n\t""dmb\n\t""dsb\n\t""isb\n\t"); \
41 | __asm__ volatile ("" ::: "memory"); (void)__s; }
42 |
43 | static __inline__ void __iCliParam(const uint32_t *__s) \
44 | { __asm__ volatile ("CPSID i\n\t""dmb\n\t""dsb\n\t""isb\n\t"); \
45 | __asm__ volatile ("" ::: "memory"); (void)__s; }
46 |
47 | static __inline__ void __iRestore(const uint32_t *__s) \
48 | { __set_primask(*__s); __asm__ volatile ("dmb\n\t""dsb\n\t""isb\n\t"); \
49 | __asm__ volatile ("" ::: "memory"); }
50 |
51 |
52 | #define ATOMIC_BLOCK(type) \
53 | for ( type, __ToDo = __iCliRetVal(); __ToDo ; __ToDo = 0 )
54 |
55 | #define ATOMIC_RESTORESTATE \
56 | uint32_t primask_save __attribute__((__cleanup__(__iRestore))) = __get_primask()
57 |
58 | #define ATOMIC_FORCEON \
59 | uint32_t primask_save __attribute__((__cleanup__(__iSeiParam))) = 0
60 |
61 | #define NONATOMIC_BLOCK(type) \
62 | for ( type, __ToDo = __iSeiRetVal(); __ToDo ; __ToDo = 0 )
63 |
64 | #define NONATOMIC_RESTORESTATE \
65 | uint32_t primask_save __attribute__((__cleanup__(__iRestore))) = __get_primask()
66 |
67 | #define NONATOMIC_FORCEOFF \
68 | uint32_t primask_save __attribute__((__cleanup__(__iCliParam))) = 0
69 |
70 | #endif
71 | #endif
72 |
--------------------------------------------------------------------------------
/libraries/RadioHead/RHutil/simulator.h:
--------------------------------------------------------------------------------
1 | // simulator.h
2 | // Lets Arduino RadioHead sketches run within a simulator on Linux as a single process
3 | // Copyright (C) 2014 Mike McCauley
4 | // $Id: simulator.h,v 1.4 2015/08/13 02:45:47 mikem Exp mikem $
5 |
6 | #ifndef simulator_h
7 | #define simulator_h
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | // Equivalent types for common Arduino types like uint8_t are in stdint.h
15 |
16 | // Access to some globals
17 | // Command line args passed to the process.
18 | extern int _simulator_argc;
19 | extern char** _simulator_argv;
20 |
21 | // Definitions for various Arduino functions
22 | extern void delay(unsigned long ms);
23 | extern unsigned long millis();
24 | extern long random(long to);
25 | extern long random(long from, long to);
26 |
27 | // Equavalent to HardwareSerial in Arduino
28 | // but outputs to stdout
29 | class SerialSimulator
30 | {
31 | public:
32 | #define DEC 10
33 | #define HEX 16
34 | #define OCT 8
35 | #define BIN 2
36 |
37 | // TODO: move these from being inlined
38 | void begin(int baud) {}
39 |
40 | size_t println(const char* s)
41 | {
42 | print(s);
43 | return printf("\n");
44 | }
45 | size_t print(const char* s)
46 | {
47 | return printf("%s", s); // This style prevent warnings from [-Wformat-security]
48 | }
49 | size_t print(unsigned int n, int base = DEC)
50 | {
51 | if (base == DEC)
52 | return printf("%d", n);
53 | else if (base == HEX)
54 | return printf("%02x", n);
55 | else if (base == OCT)
56 | return printf("%o", n);
57 | // TODO: BIN
58 | else
59 | return 0;
60 | }
61 | size_t print(char ch)
62 | {
63 | return printf("%c", ch);
64 | }
65 | size_t println(char ch)
66 | {
67 | return printf("%c\n", ch);
68 | }
69 | size_t print(unsigned char ch, int base = DEC)
70 | {
71 | return print((unsigned int)ch, base);
72 | }
73 | size_t println(unsigned char ch, int base = DEC)
74 | {
75 | print((unsigned int)ch, base);
76 | return printf("\n");
77 | }
78 |
79 | };
80 |
81 | // Global instance of the Serial output
82 | extern SerialSimulator Serial;
83 |
84 | #endif
85 |
--------------------------------------------------------------------------------
/libraries/RadioHead/STM32ArduinoCompat/HardwareSPI.h:
--------------------------------------------------------------------------------
1 | // ArduinoCompat/HardwareSPI.h
2 | // STM32 implementattion of Arduino compatible SPI class
3 |
4 | #ifndef _HardwareSPI_h
5 | #define _HardwareSPI_h
6 |
7 | #include
8 |
9 | typedef enum SPIFrequency {
10 | SPI_21_0MHZ = 0, /**< 21 MHz */
11 | SPI_10_5MHZ = 1, /**< 10.5 MHz */
12 | SPI_5_25MHZ = 2, /**< 5.25 MHz */
13 | SPI_2_625MHZ = 3, /**< 2.625 MHz */
14 | SPI_1_3125MHZ = 4, /**< 1.3125 MHz */
15 | SPI_656_25KHZ = 5, /**< 656.25 KHz */
16 | SPI_328_125KHZ = 6, /**< 328.125 KHz */
17 | } SPIFrequency;
18 |
19 | #define SPI_MODE0 0x00
20 | #define SPI_MODE1 0x04
21 | #define SPI_MODE2 0x08
22 | #define SPI_MODE3 0x0C
23 |
24 | class HardwareSPI
25 | {
26 | public:
27 | HardwareSPI(uint32_t spiPortNumber); // Only port SPI1 is currently supported
28 | void begin(SPIFrequency frequency, uint32_t bitOrder, uint32_t mode);
29 | void end(void);
30 | uint8_t transfer(uint8_t data);
31 |
32 | private:
33 | uint32_t _spiPortNumber; // Not used yet.
34 | };
35 | extern HardwareSPI SPI;
36 |
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/libraries/RadioHead/STM32ArduinoCompat/HardwareSerial.h:
--------------------------------------------------------------------------------
1 | // ArduinoCompat/HardwareSerial.h
2 | // STM32 implementation of Arduino compatible serial class
3 |
4 | #include
5 | #if (RH_PLATFORM == RH_PLATFORM_STM32STD)
6 | #ifndef _HardwareSerial_h
7 | #define _HardwareSerial_h
8 |
9 | #include
10 | #include
11 | #include
12 |
13 | #ifndef ARDUINO_RINGBUFFER_SIZE
14 | #define ARDUINO_RINGBUFFER_SIZE 64
15 | #endif
16 |
17 | class RingBuffer
18 | {
19 | public:
20 | RingBuffer();
21 | bool isEmpty();
22 | bool isFull();
23 | bool write(uint8_t ch);
24 | uint8_t read();
25 |
26 | private:
27 | uint8_t _buffer[ARDUINO_RINGBUFFER_SIZE]; // In fact we can hold up to ARDUINO_RINGBUFFER_SIZE-1 bytes
28 | uint16_t _head; // Index of next write
29 | uint16_t _tail; // Index of next read
30 | uint32_t _overruns; // Write attempted when buffer full
31 | uint32_t _underruns; // Read attempted when buffer empty
32 | };
33 |
34 | // Mostly compatible wuith Arduino HardwareSerial
35 | // Theres just enough here to support RadioHead RH_Serial
36 | class HardwareSerial
37 | {
38 | public:
39 | HardwareSerial(USART_TypeDef* usart);
40 | void begin(unsigned long baud);
41 | void end();
42 | virtual int available(void);
43 | virtual int read(void);
44 | virtual size_t write(uint8_t);
45 | inline size_t write(unsigned long n) { return write((uint8_t)n); }
46 | inline size_t write(long n) { return write((uint8_t)n); }
47 | inline size_t write(unsigned int n) { return write((uint8_t)n); }
48 | inline size_t write(int n) { return write((uint8_t)n); }
49 |
50 | // These need to be public so the IRQ handler can read and write to them:
51 | RingBuffer _rxRingBuffer;
52 | RingBuffer _txRingBuffer;
53 |
54 | private:
55 | USART_TypeDef* _usart;
56 |
57 | };
58 |
59 | // Predefined serial ports are configured so:
60 | // Serial STM32 UART RX pin Tx Pin Comments
61 | // Serial1 USART1 PA10 PA9 TX Conflicts with GREEN LED on Discovery
62 | // Serial2 USART2 PA3 PA2
63 | // Serial3 USART3 PD9 PD10
64 | // Serial4 UART4 PA1 PA0 TX conflicts with USER button on Discovery
65 | // Serial5 UART5 PD2 PC12 TX conflicts with CS43L22 SDIN on Discovery
66 | // Serial6 USART6 PC7 PC6 RX conflicts with CS43L22 MCLK on Discovery
67 | //
68 | // All ports are idle HIGH, LSB first, 8 bits, No parity, 1 stop bit
69 | extern HardwareSerial Serial1;
70 | extern HardwareSerial Serial2;
71 | extern HardwareSerial Serial3;
72 | extern HardwareSerial Serial4;
73 | extern HardwareSerial Serial5;
74 | extern HardwareSerial Serial6;
75 |
76 | #endif
77 |
78 | #endif
79 |
--------------------------------------------------------------------------------
/libraries/RadioHead/STM32ArduinoCompat/README:
--------------------------------------------------------------------------------
1 | This directory contains some files to allow RadioHead to be built on STM32F4
2 | Discovery boards, using the native STM Firmware libraries, in order to support
3 | Codec2WalkieTalkie and other projects.
4 |
5 | The files provide just enough Arduino compatibility to allow RadioHead to
6 | build in that environment.
7 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/ask/ask_receiver/ask_receiver.pde:
--------------------------------------------------------------------------------
1 | // ask_receiver.pde
2 | // -*- mode: C++ -*-
3 | // Simple example of how to use RadioHead to receive messages
4 | // with a simple ASK transmitter in a very simple way.
5 | // Implements a simplex (one-way) receiver with an Rx-B1 module
6 |
7 | #include
8 | #include // Not actualy used but needed to compile
9 |
10 | RH_ASK driver;
11 | // RH_ASK driver(2000, 2, 4, 5); // ESP8266: do not use pin 11
12 |
13 | void setup()
14 | {
15 | Serial.begin(9600); // Debugging only
16 | if (!driver.init())
17 | Serial.println("init failed");
18 | }
19 |
20 | void loop()
21 | {
22 | uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
23 | uint8_t buflen = sizeof(buf);
24 |
25 | if (driver.recv(buf, &buflen)) // Non-blocking
26 | {
27 | int i;
28 |
29 | // Message with a good checksum received, dump it.
30 | driver.printBuffer("Got:", buf, buflen);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/ask/ask_reliable_datagram_client/ask_reliable_datagram_client.pde:
--------------------------------------------------------------------------------
1 | // ask_reliable_datagram_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging client
4 | // with the RHReliableDatagram class, using the RH_ASK driver to control a ASK radio.
5 | // It is designed to work with the other example ask_reliable_datagram_server
6 | // Tested on Arduino Mega, Duemilanova, Uno, Due, Teensy
7 |
8 | #include
9 | #include
10 | #include
11 |
12 | #define CLIENT_ADDRESS 1
13 | #define SERVER_ADDRESS 2
14 |
15 | // Singleton instance of the radio driver
16 | RH_ASK driver;
17 | // RH_ASK driver(2000, 2, 4, 5); // ESP8266: do not use pin 11
18 |
19 | // Class to manage message delivery and receipt, using the driver declared above
20 | RHReliableDatagram manager(driver, CLIENT_ADDRESS);
21 |
22 | void setup()
23 | {
24 | Serial.begin(9600);
25 | if (!manager.init())
26 | Serial.println("init failed");
27 | }
28 |
29 | uint8_t data[] = "Hello World!";
30 | // Dont put this on the stack:
31 | uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
32 |
33 | void loop()
34 | {
35 | Serial.println("Sending to ask_reliable_datagram_server");
36 |
37 | // Send a message to manager_server
38 | if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
39 | {
40 | // Now wait for a reply from the server
41 | uint8_t len = sizeof(buf);
42 | uint8_t from;
43 | if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
44 | {
45 | Serial.print("got reply from : 0x");
46 | Serial.print(from, HEX);
47 | Serial.print(": ");
48 | Serial.println((char*)buf);
49 | }
50 | else
51 | {
52 | Serial.println("No reply, is ask_reliable_datagram_server running?");
53 | }
54 | }
55 | else
56 | Serial.println("sendtoWait failed");
57 | delay(500);
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/ask/ask_reliable_datagram_server/ask_reliable_datagram_server.pde:
--------------------------------------------------------------------------------
1 | // ask_reliable_datagram_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging server
4 | // with the RHReliableDatagram class, using the RH_ASK driver to control a ASK radio.
5 | // It is designed to work with the other example ask_reliable_datagram_client
6 | // Tested on Arduino Mega, Duemilanova, Uno, Due, Teensy
7 |
8 | #include
9 | #include
10 | #include
11 |
12 | #define CLIENT_ADDRESS 1
13 | #define SERVER_ADDRESS 2
14 |
15 | // Singleton instance of the radio driver
16 | RH_ASK driver;
17 | // RH_ASK driver(2000, 2, 4, 5); // ESP8266: do not use pin 11
18 |
19 | // Class to manage message delivery and receipt, using the driver declared above
20 | RHReliableDatagram manager(driver, SERVER_ADDRESS);
21 |
22 | void setup()
23 | {
24 | Serial.begin(9600);
25 | if (!manager.init())
26 | Serial.println("init failed");
27 | }
28 |
29 | uint8_t data[] = "And hello back to you";
30 | // Dont put this on the stack:
31 | uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
32 |
33 | void loop()
34 | {
35 | if (manager.available())
36 | {
37 | // Wait for a message addressed to us from the client
38 | uint8_t len = sizeof(buf);
39 | uint8_t from;
40 | if (manager.recvfromAck(buf, &len, &from))
41 | {
42 | Serial.print("got request from : 0x");
43 | Serial.print(from, HEX);
44 | Serial.print(": ");
45 | Serial.println((char*)buf);
46 |
47 | // Send a reply back to the originator client
48 | if (!manager.sendtoWait(data, sizeof(data), from))
49 | Serial.println("sendtoWait failed");
50 | }
51 | }
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/ask/ask_transmitter/ask_transmitter.pde:
--------------------------------------------------------------------------------
1 | // ask_transmitter.pde
2 | // -*- mode: C++ -*-
3 | // Simple example of how to use RadioHead to transmit messages
4 | // with a simple ASK transmitter in a very simple way.
5 | // Implements a simplex (one-way) transmitter with an TX-C1 module
6 |
7 | #include
8 | #include // Not actually used but needed to compile
9 |
10 | RH_ASK driver;
11 | // RH_ASK driver(2000, 2, 4, 5); // ESP8266: do not use pin 11
12 |
13 | void setup()
14 | {
15 | Serial.begin(9600); // Debugging only
16 | if (!driver.init())
17 | Serial.println("init failed");
18 | }
19 |
20 | void loop()
21 | {
22 | const char *msg = "hello";
23 |
24 | driver.send((uint8_t *)msg, strlen(msg));
25 | driver.waitPacketSent();
26 | delay(200);
27 | }
28 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/cc110/cc110_client/cc110_client.pde:
--------------------------------------------------------------------------------
1 | // cc110_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple messageing client
4 | // with the RH_CC110 class. RH_CC110 class does not provide for addressing or
5 | // reliability, so you should only use RH_CC110 if you do not need the higher
6 | // level messaging abilities.
7 | // It is designed to work with the other example cc110_server
8 | // Tested with Teensy 3.1 and Anaren 430BOOST-CC110L
9 |
10 | #include
11 | #include
12 |
13 | // Singleton instance of the radio driver
14 | RH_CC110 cc110;
15 |
16 | void setup()
17 | {
18 | Serial.begin(9600);
19 | while (!Serial)
20 | ; // wait for serial port to connect. Needed for native USB
21 |
22 | // CC110L may be equipped with either 26 or 27MHz crystals. You MUST
23 | // tell the driver if a 27MHz crystal is installed for the correct configuration to
24 | // occur. Failure to correctly set this flag will cause incorrect frequency and modulation
25 | // characteristics to be used. You can call this function, or pass it to the constructor
26 | cc110.setIs27MHz(true); // Anaren 430BOOST-CC110L Air BoosterPack test boards have 27MHz
27 | if (!cc110.init())
28 | Serial.println("init failed");
29 | // After init(), the following default values apply:
30 | // TxPower: TransmitPower5dBm
31 | // Frequency: 915.0
32 | // Modulation: GFSK_Rb1_2Fd5_2 (GFSK, Data Rate: 1.2kBaud, Dev: 5.2kHz, RX BW 58kHz, optimised for sensitivity)
33 | // Sync Words: 0xd3, 0x91
34 | // But you can change them:
35 | // cc110.setTxPower(RH_CC110::TransmitPowerM30dBm);
36 | // cc110.setModemConfig(RH_CC110::GFSK_Rb250Fd127);
37 | //cc110.setFrequency(928.0);
38 | }
39 |
40 | void loop()
41 | {
42 | Serial.println("Sending to cc110_server");
43 | // Send a message to cc110_server
44 | uint8_t data[] = "Hello World!";
45 | cc110.send(data, sizeof(data));
46 |
47 | cc110.waitPacketSent();
48 | // Now wait for a reply
49 | uint8_t buf[RH_CC110_MAX_MESSAGE_LEN];
50 | uint8_t len = sizeof(buf);
51 |
52 | if (cc110.waitAvailableTimeout(3000))
53 | {
54 | // Should be a reply message for us now
55 | if (cc110.recv(buf, &len))
56 | {
57 | Serial.print("got reply: ");
58 | Serial.println((char*)buf);
59 | // Serial.print("RSSI: ");
60 | // Serial.println(cc110.lastRssi(), DEC);
61 | }
62 | else
63 | {
64 | Serial.println("recv failed");
65 | }
66 | }
67 | else
68 | {
69 | Serial.println("No reply, is cc110_server running?");
70 | }
71 |
72 | delay(400);
73 | }
74 |
75 |
76 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/cc110/cc110_server/cc110_server.pde:
--------------------------------------------------------------------------------
1 | // cc110_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple messageing server
4 | // with the RH_CC110 class. RH_CC110 class does not provide for addressing or
5 | // reliability, so you should only use RH_CC110 if you do not need the higher
6 | // level messaging abilities.
7 | // It is designed to work with the other example cc110_client
8 | // Tested with Teensy 3.1 and Anaren 430BOOST-CC110L
9 |
10 |
11 | #include
12 | #include
13 |
14 | // Singleton instance of the radio driver
15 | RH_CC110 cc110;
16 |
17 | void setup()
18 | {
19 | Serial.begin(9600);
20 | while (!Serial)
21 | ; // wait for serial port to connect. Needed for native USB
22 |
23 | // CC110L may be equipped with either 26 or 27MHz crystals. You MUST
24 | // tell the driver if a 27MHz crystal is installed for the correct configuration to
25 | // occur. Failure to correctly set this flag will cause incorrect frequency and modulation
26 | // characteristics to be used. You can call this function, or pass it to the constructor
27 | cc110.setIs27MHz(true); // Anaren 430BOOST-CC110L Air BoosterPack test boards have 27MHz
28 | if (!cc110.init())
29 | Serial.println("init failed");
30 | // After init(), the following default values apply:
31 | // TxPower: TransmitPower5dBm
32 | // Frequency: 915.0
33 | // Modulation: GFSK_Rb1_2Fd5_2 (GFSK, Data Rate: 1.2kBaud, Dev: 5.2kHz, RX BW 58kHz, optimised for sensitivity)
34 | // Sync Words: 0xd3, 0x91
35 | // But you can change them:
36 | // cc110.setTxPower(RH_CC110::TransmitPowerM30dBm);
37 | // cc110.setModemConfig(RH_CC110::GFSK_Rb250Fd127);
38 | //cc110.setFrequency(928.0);
39 | }
40 |
41 | void loop()
42 | {
43 | if (cc110.available())
44 | {
45 | // Should be a message for us now
46 | uint8_t buf[RH_CC110_MAX_MESSAGE_LEN];
47 | uint8_t len = sizeof(buf);
48 | if (cc110.recv(buf, &len))
49 | {
50 | // RH_CC110::printBuffer("request: ", buf, len);
51 | Serial.print("got request: ");
52 | Serial.println((char*)buf);
53 | // Serial.print("RSSI: ");
54 | // Serial.println(cc110.lastRssi(), DEC);
55 |
56 | // Send a reply
57 | uint8_t data[] = "And hello back to you";
58 | cc110.send(data, sizeof(data));
59 | cc110.waitPacketSent();
60 | Serial.println("Sent a reply");
61 | }
62 | else
63 | {
64 | Serial.println("recv failed");
65 | }
66 | }
67 | }
68 |
69 |
70 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/mrf89/mrf89_client/mrf89_client.pde:
--------------------------------------------------------------------------------
1 | // mrf89_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple messageing client
4 | // with the RH_MRF89 class. RH_MRF89 class does not provide for addressing or
5 | // reliability, so you should only use RH_RF95 if you do not need the higher
6 | // level messaging abilities.
7 | // It is designed to work with the other example mrf89_server
8 | // Tested with Teensy and MRF89XAM9A
9 |
10 | #include
11 | #include
12 |
13 | // Singleton instance of the radio driver
14 | RH_MRF89 mrf89;
15 |
16 | void setup()
17 | {
18 | Serial.begin(9600);
19 | while (!Serial)
20 | ; // wait for serial port to connect. Needed for native USB
21 |
22 | if (!mrf89.init())
23 | Serial.println("init failed");
24 | // Default after init is 1dBm, 915.4MHz, FSK_Rb20Fd40
25 | // But you can change that if you want:
26 | // mrf89.setTxPower(RH_MRF89_TXOPVAL_M8DBM); // Min power -8dBm
27 | // mrf89.setTxPower(RH_MRF89_TXOPVAL_13DBM); // Max power 13dBm
28 | // if (!mrf89.setFrequency(920.0))
29 | // Serial.println("setFrequency failed");
30 | // if (!mrf89.setModemConfig(RH_MRF89::FSK_Rb200Fd200)) // Fastest
31 | // Serial.println("setModemConfig failed");
32 | }
33 |
34 | void loop()
35 | {
36 | Serial.println("Sending to mrf89_server");
37 | // Send a message to mrf89_server
38 | uint8_t data[] = "Hello World!";
39 | mrf89.send(data, sizeof(data));
40 |
41 | mrf89.waitPacketSent();
42 | // Now wait for a reply
43 | uint8_t buf[RH_MRF89_MAX_MESSAGE_LEN];
44 | uint8_t len = sizeof(buf);
45 |
46 | if (mrf89.waitAvailableTimeout(3000))
47 | {
48 | // Should be a reply message for us now
49 | if (mrf89.recv(buf, &len))
50 | {
51 | Serial.print("got reply: ");
52 | Serial.println((char*)buf);
53 | // Serial.print("RSSI: ");
54 | // Serial.println(mrf89.lastRssi(), DEC);
55 | }
56 | else
57 | {
58 | Serial.println("recv failed");
59 | }
60 | }
61 | else
62 | {
63 | Serial.println("No reply, is mrf89_server running?");
64 | }
65 | delay(400);
66 | }
67 |
68 |
69 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/mrf89/mrf89_server/mrf89_server.pde:
--------------------------------------------------------------------------------
1 | // mrf89_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple messageing server
4 | // with the RH_MRF89 class. RH_MRF89 class does not provide for addressing or
5 | // reliability, so you should only use RH_MRF89 if you do not need the higher
6 | // level messaging abilities.
7 | // It is designed to work with the other example mrf89_client
8 | // Tested with Teensy and MRF89XAM9A
9 |
10 |
11 | #include
12 | #include
13 |
14 | // Singleton instance of the radio driver
15 | RH_MRF89 mrf89;
16 |
17 | void setup()
18 | {
19 | Serial.begin(9600);
20 | while (!Serial)
21 | ; // wait for serial port to connect. Needed for native USB
22 |
23 | if (!mrf89.init())
24 | Serial.println("init failed");
25 |
26 | // Default after init is 1dBm, 915.4MHz, FSK_Rb20Fd40
27 | // But you can change that if you want:
28 | // mrf89.setTxPower(RH_MRF89_TXOPVAL_M8DBM); // Min power -8dBm
29 | // mrf89.setTxPower(RH_MRF89_TXOPVAL_13DBM); // Max power 13dBm
30 | // if (!mrf89.setFrequency(920.0))
31 | // Serial.println("setFrequency failed");
32 | // if (!mrf89.setModemConfig(RH_MRF89::FSK_Rb200Fd200)) // Fastest
33 | // Serial.println("setModemConfig failed");
34 | }
35 |
36 | void loop()
37 | {
38 | if (mrf89.available())
39 | {
40 | // Should be a message for us now
41 | uint8_t buf[RH_MRF89_MAX_MESSAGE_LEN];
42 | uint8_t len = sizeof(buf);
43 | if (mrf89.recv(buf, &len))
44 | {
45 | // RH_MRF89::printBuffer("request: ", buf, len);
46 | Serial.print("got request: ");
47 | Serial.println((char*)buf);
48 | // Serial.print("RSSI: ");
49 | // Serial.println(mrf89.lastRssi(), DEC);
50 |
51 | // Send a reply
52 | uint8_t data[] = "And hello back to you";
53 | mrf89.send(data, sizeof(data));
54 | mrf89.waitPacketSent();
55 | Serial.println("Sent a reply");
56 | }
57 | else
58 | {
59 | Serial.println("recv failed");
60 | }
61 | }
62 | // delay(10000);
63 | // mrf89.printRegisters();
64 | // while (1);
65 | }
66 |
67 |
68 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/nrf24/nrf24_client/nrf24_client.pde:
--------------------------------------------------------------------------------
1 | // nrf24_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple messageing client
4 | // with the RH_NRF24 class. RH_NRF24 class does not provide for addressing or
5 | // reliability, so you should only use RH_NRF24 if you do not need the higher
6 | // level messaging abilities.
7 | // It is designed to work with the other example nrf24_server.
8 | // Tested on Uno with Sparkfun NRF25L01 module
9 | // Tested on Anarduino Mini (http://www.anarduino.com/mini/) with RFM73 module
10 | // Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module
11 |
12 | #include
13 | #include
14 |
15 | // Singleton instance of the radio driver
16 | RH_NRF24 nrf24;
17 | // RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
18 | // RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
19 | // RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini
20 |
21 | void setup()
22 | {
23 | Serial.begin(9600);
24 | while (!Serial)
25 | ; // wait for serial port to connect. Needed for Leonardo only
26 | if (!nrf24.init())
27 | Serial.println("init failed");
28 | // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
29 | if (!nrf24.setChannel(1))
30 | Serial.println("setChannel failed");
31 | if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
32 | Serial.println("setRF failed");
33 | }
34 |
35 |
36 | void loop()
37 | {
38 | Serial.println("Sending to nrf24_server");
39 | // Send a message to nrf24_server
40 | uint8_t data[] = "Hello World!";
41 | nrf24.send(data, sizeof(data));
42 |
43 | nrf24.waitPacketSent();
44 | // Now wait for a reply
45 | uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
46 | uint8_t len = sizeof(buf);
47 |
48 | if (nrf24.waitAvailableTimeout(500))
49 | {
50 | // Should be a reply message for us now
51 | if (nrf24.recv(buf, &len))
52 | {
53 | Serial.print("got reply: ");
54 | Serial.println((char*)buf);
55 | }
56 | else
57 | {
58 | Serial.println("recv failed");
59 | }
60 | }
61 | else
62 | {
63 | Serial.println("No reply, is nrf24_server running?");
64 | }
65 | delay(400);
66 | }
67 |
68 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/nrf24/nrf24_reliable_datagram_client/nrf24_reliable_datagram_client.pde:
--------------------------------------------------------------------------------
1 | // nrf24_reliable_datagram_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging client
4 | // with the RHReliableDatagram class, using the RH_NRF24 driver to control a NRF24 radio.
5 | // It is designed to work with the other example nrf24_reliable_datagram_server
6 | // Tested on Uno with Sparkfun WRL-00691 NRF24L01 module
7 | // Tested on Teensy with Sparkfun WRL-00691 NRF24L01 module
8 | // Tested on Anarduino Mini (http://www.anarduino.com/mini/) with RFM73 module
9 | // Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module
10 |
11 | #include
12 | #include
13 | #include
14 |
15 | #define CLIENT_ADDRESS 1
16 | #define SERVER_ADDRESS 2
17 |
18 | // Singleton instance of the radio driver
19 | RH_NRF24 driver;
20 | // RH_NRF24 driver(8, 7); // For RFM73 on Anarduino Mini
21 |
22 | // Class to manage message delivery and receipt, using the driver declared above
23 | RHReliableDatagram manager(driver, CLIENT_ADDRESS);
24 |
25 | void setup()
26 | {
27 | Serial.begin(9600);
28 | if (!manager.init())
29 | Serial.println("init failed");
30 | // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
31 | }
32 |
33 | uint8_t data[] = "Hello World!";
34 | // Dont put this on the stack:
35 | uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
36 |
37 | void loop()
38 | {
39 | Serial.println("Sending to nrf24_reliable_datagram_server");
40 |
41 | // Send a message to manager_server
42 | if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
43 | {
44 | // Now wait for a reply from the server
45 | uint8_t len = sizeof(buf);
46 | uint8_t from;
47 | if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
48 | {
49 | Serial.print("got reply from : 0x");
50 | Serial.print(from, HEX);
51 | Serial.print(": ");
52 | Serial.println((char*)buf);
53 | }
54 | else
55 | {
56 | Serial.println("No reply, is nrf24_reliable_datagram_server running?");
57 | }
58 | }
59 | else
60 | Serial.println("sendtoWait failed");
61 | delay(500);
62 | }
63 |
64 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/nrf24/nrf24_reliable_datagram_server/nrf24_reliable_datagram_server.pde:
--------------------------------------------------------------------------------
1 | // nrf24_reliable_datagram_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging server
4 | // with the RHReliableDatagram class, using the RH_NRF24 driver to control a NRF24 radio.
5 | // It is designed to work with the other example nrf24_reliable_datagram_client
6 | // Tested on Uno with Sparkfun WRL-00691 NRF24L01 module
7 | // Tested on Teensy with Sparkfun WRL-00691 NRF24L01 module
8 | // Tested on Anarduino Mini (http://www.anarduino.com/mini/) with RFM73 module
9 | // Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module
10 |
11 | #include
12 | #include
13 | #include
14 |
15 | #define CLIENT_ADDRESS 1
16 | #define SERVER_ADDRESS 2
17 |
18 | // Singleton instance of the radio driver
19 | RH_NRF24 driver;
20 | // RH_NRF24 driver(8, 7); // For RFM73 on Anarduino Mini
21 |
22 | // Class to manage message delivery and receipt, using the driver declared above
23 | RHReliableDatagram manager(driver, SERVER_ADDRESS);
24 |
25 | void setup()
26 | {
27 | Serial.begin(9600);
28 | if (!manager.init())
29 | Serial.println("init failed");
30 | // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
31 | }
32 |
33 | uint8_t data[] = "And hello back to you";
34 | // Dont put this on the stack:
35 | uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
36 |
37 | void loop()
38 | {
39 | if (manager.available())
40 | {
41 | // Wait for a message addressed to us from the client
42 | uint8_t len = sizeof(buf);
43 | uint8_t from;
44 | if (manager.recvfromAck(buf, &len, &from))
45 | {
46 | Serial.print("got request from : 0x");
47 | Serial.print(from, HEX);
48 | Serial.print(": ");
49 | Serial.println((char*)buf);
50 |
51 | // Send a reply back to the originator client
52 | if (!manager.sendtoWait(data, sizeof(data), from))
53 | Serial.println("sendtoWait failed");
54 | }
55 | }
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/nrf24/nrf24_server/nrf24_server.pde:
--------------------------------------------------------------------------------
1 | // nrf24_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple messageing server
4 | // with the RH_NRF24 class. RH_NRF24 class does not provide for addressing or
5 | // reliability, so you should only use RH_NRF24 if you do not need the higher
6 | // level messaging abilities.
7 | // It is designed to work with the other example nrf24_client
8 | // Tested on Uno with Sparkfun NRF25L01 module
9 | // Tested on Anarduino Mini (http://www.anarduino.com/mini/) with RFM73 module
10 | // Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module
11 |
12 | #include
13 | #include
14 |
15 | // Singleton instance of the radio driver
16 | RH_NRF24 nrf24;
17 | // RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
18 | // RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
19 | // RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini
20 |
21 | void setup()
22 | {
23 | Serial.begin(9600);
24 | while (!Serial)
25 | ; // wait for serial port to connect. Needed for Leonardo only
26 | if (!nrf24.init())
27 | Serial.println("init failed");
28 | // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
29 | if (!nrf24.setChannel(1))
30 | Serial.println("setChannel failed");
31 | if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
32 | Serial.println("setRF failed");
33 | }
34 |
35 | void loop()
36 | {
37 | if (nrf24.available())
38 | {
39 | // Should be a message for us now
40 | uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
41 | uint8_t len = sizeof(buf);
42 | if (nrf24.recv(buf, &len))
43 | {
44 | // NRF24::printBuffer("request: ", buf, len);
45 | Serial.print("got request: ");
46 | Serial.println((char*)buf);
47 |
48 | // Send a reply
49 | uint8_t data[] = "And hello back to you";
50 | nrf24.send(data, sizeof(data));
51 | nrf24.waitPacketSent();
52 | Serial.println("Sent a reply");
53 | }
54 | else
55 | {
56 | Serial.println("recv failed");
57 | }
58 | }
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/nrf51/nrf51_audio_tx/nrf51_audio.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lupyuen/LoRaArduino/f9318ff8f464b020654658e8616bd3790a121743/libraries/RadioHead/examples/nrf51/nrf51_audio_tx/nrf51_audio.pdf
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/nrf51/nrf51_client/nrf51_client.pde:
--------------------------------------------------------------------------------
1 | // nrf51_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple messageing client
4 | // with the RH_NRF51 class. RH_NRF51 class does not provide for addressing or
5 | // reliability, so you should only use RH_NRF51 if you do not need the higher
6 | // level messaging abilities.
7 | // It is designed to work with the other example nrf51_server.
8 | // Tested on RedBearLabs nRF51822 and BLE Nano kit, built with Arduino 1.6.4.
9 | // See http://redbearlab.com/getting-started-nrf51822/
10 | // for how to set up your Arduino build environment
11 |
12 | #include
13 |
14 | // Singleton instance of the radio driver
15 | RH_NRF51 nrf51;
16 |
17 | void setup()
18 | {
19 | delay(1000); // Wait for serial port etc to be ready
20 | Serial.begin(9600);
21 | while (!Serial)
22 | ; // wait for serial port to connect.
23 | if (!nrf51.init())
24 | Serial.println("init failed");
25 | // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
26 | if (!nrf51.setChannel(1))
27 | Serial.println("setChannel failed");
28 | if (!nrf51.setRF(RH_NRF51::DataRate2Mbps, RH_NRF51::TransmitPower0dBm))
29 | Serial.println("setRF failed");
30 | nrf51.printRegisters();
31 | }
32 |
33 |
34 | void loop()
35 | {
36 | Serial.println("Sending to nrf51_server");
37 | // Send a message to nrf51_server
38 | uint8_t data[] = "Hello World!";
39 | nrf51.send(data, sizeof(data));
40 | nrf51.waitPacketSent();
41 |
42 | // Now wait for a reply
43 | uint8_t buf[RH_NRF51_MAX_MESSAGE_LEN];
44 | uint8_t len = sizeof(buf);
45 |
46 | if (nrf51.waitAvailableTimeout(500))
47 | {
48 | // Should be a reply message for us now
49 | if (nrf51.recv(buf, &len))
50 | {
51 | Serial.print("got reply: ");
52 | Serial.println((char*)buf);
53 | }
54 | else
55 | {
56 | Serial.println("recv failed");
57 | }
58 | }
59 | else
60 | {
61 | Serial.println("No reply, is nrf51_server running?");
62 | }
63 |
64 | delay(400);
65 | }
66 |
67 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/nrf51/nrf51_reliable_datagram_client/nrf51_reliable_datagram_client.pde:
--------------------------------------------------------------------------------
1 | // nrf51_reliable_datagram_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging client
4 | // with the RHReliableDatagram class, using the RH_NRF51 driver to control a NRF51 radio.
5 | // It is designed to work with the other example nrf51_reliable_datagram_server
6 | // Tested on RedBearLabs nRF51822 and BLE Nano kit, built with Arduino 1.6.4.
7 | // See http://redbearlab.com/getting-started-nrf51822/
8 | // for how to set up your Arduino build environment
9 |
10 | #include
11 | #include
12 |
13 | #define CLIENT_ADDRESS 1
14 | #define SERVER_ADDRESS 2
15 |
16 | // Singleton instance of the radio driver
17 | RH_NRF51 driver;
18 |
19 | // Class to manage message delivery and receipt, using the driver declared above
20 | RHReliableDatagram manager(driver, CLIENT_ADDRESS);
21 |
22 | void setup()
23 | {
24 | delay(1000); // Wait for serial port etc to be ready
25 | Serial.begin(9600);
26 | while (!Serial)
27 | ; // wait for serial port to connect.
28 |
29 | if (!manager.init())
30 | Serial.println("init failed");
31 | // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
32 | }
33 |
34 | uint8_t data[] = "Hello World!";
35 | // Dont put this on the stack:
36 | uint8_t buf[RH_NRF51_MAX_MESSAGE_LEN];
37 |
38 | void loop()
39 | {
40 | Serial.println("Sending to nrf51_reliable_datagram_server");
41 |
42 | // Send a message to manager_server
43 | if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
44 | {
45 | // Now wait for a reply from the server
46 | uint8_t len = sizeof(buf);
47 | uint8_t from;
48 | if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
49 | {
50 | Serial.print("got reply from : 0x");
51 | Serial.print(from, HEX);
52 | Serial.print(": ");
53 | Serial.println((char*)buf);
54 | }
55 | else
56 | {
57 | Serial.println("No reply, is nrf51_reliable_datagram_server running?");
58 | }
59 | }
60 | else
61 | Serial.println("sendtoWait failed");
62 | delay(500);
63 | }
64 |
65 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/nrf51/nrf51_reliable_datagram_server/nrf51_reliable_datagram_server.pde:
--------------------------------------------------------------------------------
1 | // nrf51_reliable_datagram_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging server
4 | // with the RHReliableDatagram class, using the RH_NRF51 driver to control a NRF51 radio.
5 | // It is designed to work with the other example nrf51_reliable_datagram_client
6 | // Tested on RedBearLabs nRF51822 and BLE Nano kit, built with Arduino 1.6.4.
7 | // See http://redbearlab.com/getting-started-nrf51822/
8 | // for how to set up your Arduino build environment
9 |
10 |
11 | #include
12 | #include
13 |
14 | #define CLIENT_ADDRESS 1
15 | #define SERVER_ADDRESS 2
16 |
17 | // Singleton instance of the radio driver
18 | RH_NRF51 driver;
19 |
20 | // Class to manage message delivery and receipt, using the driver declared above
21 | RHReliableDatagram manager(driver, SERVER_ADDRESS);
22 |
23 | void setup()
24 | {
25 | delay(1000); // Wait for serial port etc to be ready
26 | Serial.begin(9600);
27 | while (!Serial)
28 | ; // wait for serial port to connect.
29 |
30 | if (!manager.init())
31 | Serial.println("init failed");
32 | // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
33 | }
34 |
35 | uint8_t data[] = "And hello back to you";
36 | // Dont put this on the stack:
37 | uint8_t buf[RH_NRF51_MAX_MESSAGE_LEN];
38 |
39 | void loop()
40 | {
41 | if (manager.available())
42 | {
43 | // Wait for a message addressed to us from the client
44 | uint8_t len = sizeof(buf);
45 | uint8_t from;
46 | if (manager.recvfromAck(buf, &len, &from))
47 | {
48 | Serial.print("got request from : 0x");
49 | Serial.print(from, HEX);
50 | Serial.print(": ");
51 | Serial.println((char*)buf);
52 |
53 | // Send a reply back to the originator client
54 | if (!manager.sendtoWait(data, sizeof(data), from))
55 | Serial.println("sendtoWait failed");
56 | }
57 | }
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/nrf51/nrf51_server/nrf51_server.pde:
--------------------------------------------------------------------------------
1 | // nrf51_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple messageing server
4 | // with the RH_NRF51 class. RH_NRF51 class does not provide for addressing or
5 | // reliability, so you should only use RH_NRF51 if you do not need the higher
6 | // level messaging abilities.
7 | // It is designed to work with the other example nrf51_client
8 | // Tested on RedBearLabs nRF51822 and BLE Nano kit, built with Arduino 1.6.4.
9 | // See http://redbearlab.com/getting-started-nrf51822/
10 | // for how to set up your Arduino build environment
11 |
12 | #include
13 |
14 | // Singleton instance of the radio driver
15 | RH_NRF51 nrf51;
16 |
17 | void setup()
18 | {
19 | delay(1000); // Wait for serial port etc to be ready
20 | Serial.begin(9600);
21 | while (!Serial)
22 | ; // wait for serial port to connect. Needed for Leonardo only
23 | if (!nrf51.init())
24 | Serial.println("init failed");
25 | // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
26 | if (!nrf51.setChannel(1))
27 | Serial.println("setChannel failed");
28 | if (!nrf51.setRF(RH_NRF51::DataRate2Mbps, RH_NRF51::TransmitPower0dBm))
29 | Serial.println("setRF failed");
30 | }
31 |
32 | void loop()
33 | {
34 | if (nrf51.available())
35 | {
36 | // Should be a message for us now
37 | uint8_t buf[RH_NRF51_MAX_MESSAGE_LEN];
38 | uint8_t len = sizeof(buf);
39 | if (nrf51.recv(buf, &len))
40 | {
41 | // NRF51::printBuffer("request: ", buf, len);
42 | Serial.print("got request: ");
43 | Serial.println((char*)buf);
44 |
45 | // Send a reply
46 | uint8_t data[] = "And hello back to you";
47 | nrf51.send(data, sizeof(data));
48 | nrf51.waitPacketSent();
49 | Serial.println("Sent a reply");
50 | }
51 | else
52 | {
53 | Serial.println("recv failed");
54 | }
55 | }
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/nrf905/nrf905_client/nrf905_client.pde:
--------------------------------------------------------------------------------
1 | // nrf905_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple messageing client
4 | // with the RH_NRF905 class. RH_NRF905 class does not provide for addressing or
5 | // reliability, so you should only use RH_NRF905 if you do not need the higher
6 | // level messaging abilities.
7 | // It is designed to work with the other example nrf905_server.
8 | // Tested on Teensy3.1 with nRF905 module
9 | // Tested on Arduino Due with nRF905 module (Caution: use the SPI headers for connecting)
10 |
11 | #include
12 | #include
13 |
14 | // Singleton instance of the radio driver
15 | RH_NRF905 nrf905;
16 |
17 | void setup()
18 | {
19 | Serial.begin(9600);
20 | while (!Serial)
21 | ; // wait for serial port to connect. Needed for Leonardo only
22 | if (!nrf905.init())
23 | Serial.println("init failed");
24 | // Defaults after init are 433.2 MHz (channel 108), -10dBm
25 | }
26 |
27 |
28 | void loop()
29 | {
30 | Serial.println("Sending to nrf905_server");
31 | // Send a message to nrf905_server
32 | uint8_t data[] = "Hello World!";
33 | nrf905.send(data, sizeof(data));
34 |
35 | nrf905.waitPacketSent();
36 | // Now wait for a reply
37 | uint8_t buf[RH_NRF905_MAX_MESSAGE_LEN];
38 | uint8_t len = sizeof(buf);
39 |
40 | if (nrf905.waitAvailableTimeout(500))
41 | {
42 | // Should be a reply message for us now
43 | if (nrf905.recv(buf, &len))
44 | {
45 | Serial.print("got reply: ");
46 | Serial.println((char*)buf);
47 | }
48 | else
49 | {
50 | Serial.println("recv failed");
51 | }
52 | }
53 | else
54 | {
55 | Serial.println("No reply, is nrf905_server running?");
56 | }
57 | delay(400);
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/nrf905/nrf905_reliable_datagram_client/nrf905_reliable_datagram_client.pde:
--------------------------------------------------------------------------------
1 | // nrf905_reliable_datagram_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging client
4 | // with the RHReliableDatagram class, using the RH_NRF905 driver to control a NRF905 radio.
5 | // It is designed to work with the other example nrf905_reliable_datagram_server
6 | // Tested on Teensy3.1 with nRF905 module
7 | // Tested on Arduino Due with nRF905 module (Caution: use the SPI headers for connecting)
8 |
9 | #include
10 | #include
11 | #include
12 |
13 | #define CLIENT_ADDRESS 1
14 | #define SERVER_ADDRESS 2
15 |
16 | // Singleton instance of the radio driver
17 | RH_NRF905 driver;
18 |
19 | // Class to manage message delivery and receipt, using the driver declared above
20 | RHReliableDatagram manager(driver, CLIENT_ADDRESS);
21 |
22 | void setup()
23 | {
24 | Serial.begin(9600);
25 | if (!manager.init())
26 | Serial.println("init failed");
27 | // Defaults after init are 433.2 MHz (channel 108), -10dBm
28 | }
29 |
30 | uint8_t data[] = "Hello World!";
31 | // Dont put this on the stack:
32 | uint8_t buf[RH_NRF905_MAX_MESSAGE_LEN];
33 |
34 | void loop()
35 | {
36 | Serial.println("Sending to nrf905_reliable_datagram_server");
37 |
38 | // Send a message to manager_server
39 | if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
40 | {
41 | // Now wait for a reply from the server
42 | uint8_t len = sizeof(buf);
43 | uint8_t from;
44 | if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
45 | {
46 | Serial.print("got reply from : 0x");
47 | Serial.print(from, HEX);
48 | Serial.print(": ");
49 | Serial.println((char*)buf);
50 | }
51 | else
52 | {
53 | Serial.println("No reply, is nrf905_reliable_datagram_server running?");
54 | }
55 | }
56 | else
57 | Serial.println("sendtoWait failed");
58 | delay(500);
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/nrf905/nrf905_reliable_datagram_server/nrf905_reliable_datagram_server.pde:
--------------------------------------------------------------------------------
1 | // nrf905_reliable_datagram_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging server
4 | // with the RHReliableDatagram class, using the RH_NRF905 driver to control a NRF905 radio.
5 | // It is designed to work with the other example nrf905_reliable_datagram_client
6 | // Tested on Teensy3.1 with nRF905 module
7 | // Tested on Arduino Due with nRF905 module (Caution: use the SPI headers for connecting)
8 |
9 | #include
10 | #include
11 | #include
12 |
13 | #define CLIENT_ADDRESS 1
14 | #define SERVER_ADDRESS 2
15 |
16 | // Singleton instance of the radio driver
17 | RH_NRF905 driver;
18 |
19 | // Class to manage message delivery and receipt, using the driver declared above
20 | RHReliableDatagram manager(driver, SERVER_ADDRESS);
21 |
22 | void setup()
23 | {
24 | Serial.begin(9600);
25 | if (!manager.init())
26 | Serial.println("init failed");
27 | // Defaults after init are 433.2 MHz (channel 108), -10dBm
28 | }
29 |
30 | uint8_t data[] = "And hello back to you";
31 | // Dont put this on the stack:
32 | uint8_t buf[RH_NRF905_MAX_MESSAGE_LEN];
33 |
34 | void loop()
35 | {
36 | if (manager.available())
37 | {
38 | // Wait for a message addressed to us from the client
39 | uint8_t len = sizeof(buf);
40 | uint8_t from;
41 | if (manager.recvfromAck(buf, &len, &from))
42 | {
43 | Serial.print("got request from : 0x");
44 | Serial.print(from, HEX);
45 | Serial.print(": ");
46 | Serial.println((char*)buf);
47 |
48 | // Send a reply back to the originator client
49 | if (!manager.sendtoWait(data, sizeof(data), from))
50 | Serial.println("sendtoWait failed");
51 | }
52 | }
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/nrf905/nrf905_server/nrf905_server.pde:
--------------------------------------------------------------------------------
1 | // nrf905_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple messageing server
4 | // with the RH_NRF905 class. RH_NRF905 class does not provide for addressing or
5 | // reliability, so you should only use RH_NRF905 if you do not need the higher
6 | // level messaging abilities.
7 | // It is designed to work with the other example nrf905_client
8 | // Tested on Teensy3.1 with nRF905 module
9 | // Tested on Arduino Due with nRF905 module (Caution: use the SPI headers for connecting)
10 |
11 | #include
12 | #include
13 |
14 | // Singleton instance of the radio driver
15 | RH_NRF905 nrf905;
16 |
17 | void setup()
18 | {
19 | Serial.begin(9600);
20 | while (!Serial)
21 | ; // wait for serial port to connect. Needed for Leonardo only
22 | if (!nrf905.init())
23 | Serial.println("init failed");
24 | // Defaults after init are 433.2 MHz (channel 108), -10dBm
25 | }
26 |
27 | void loop()
28 | {
29 | if (nrf905.available())
30 | {
31 | // Should be a message for us now
32 | uint8_t buf[RH_NRF905_MAX_MESSAGE_LEN];
33 | uint8_t len = sizeof(buf);
34 | if (nrf905.recv(buf, &len))
35 | {
36 | // nrf905.printBuffer("request: ", buf, len);
37 | Serial.print("got request: ");
38 | Serial.println((char*)buf);
39 |
40 | // Send a reply
41 | uint8_t data[] = "And hello back to you";
42 | nrf905.send(data, sizeof(data));
43 | nrf905.waitPacketSent();
44 | Serial.println("Sent a reply");
45 | }
46 | else
47 | {
48 | Serial.println("recv failed");
49 | }
50 | }
51 | }
52 |
53 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/raspi/Makefile:
--------------------------------------------------------------------------------
1 | # Makefile
2 | # Sample for RH_NRF24 on Raspberry Pi
3 | # Caution: requires bcm2835 library to be already installed
4 | # http://www.airspayce.com/mikem/bcm2835/
5 |
6 | CC = g++
7 | CFLAGS = -DRASPBERRY_PI -DBCM2835_NO_DELAY_COMPATIBILITY
8 | LIBS = -lbcm2835
9 | RADIOHEADBASE = ../..
10 | INCLUDE = -I$(RADIOHEADBASE)
11 |
12 | all: RasPiRH
13 |
14 | RasPi.o: $(RADIOHEADBASE)/RHutil/RasPi.cpp
15 | $(CC) $(CFLAGS) -c $(RADIOHEADBASE)/RHutil/RasPi.cpp $(INCLUDE)
16 |
17 | RasPiRH.o: RasPiRH.cpp
18 | $(CC) $(CFLAGS) -c $(INCLUDE) $<
19 |
20 | RH_NRF24.o: $(RADIOHEADBASE)/RH_NRF24.cpp
21 | $(CC) $(CFLAGS) -c $(INCLUDE) $<
22 |
23 | RHMesh.o: $(RADIOHEADBASE)/RHMesh.cpp
24 | $(CC) $(CFLAGS) -c $(INCLUDE) $<
25 |
26 | RHRouter.o: $(RADIOHEADBASE)/RHRouter.cpp
27 | $(CC) $(CFLAGS) -c $(INCLUDE) $<
28 |
29 | RHReliableDatagram.o: $(RADIOHEADBASE)/RHReliableDatagram.cpp
30 | $(CC) $(CFLAGS) -c $(INCLUDE) $<
31 |
32 | RHDatagram.o: $(RADIOHEADBASE)/RHDatagram.cpp
33 | $(CC) $(CFLAGS) -c $(INCLUDE) $<
34 |
35 | RHHardwareSPI.o: $(RADIOHEADBASE)/RHHardwareSPI.cpp
36 | $(CC) $(CFLAGS) -c $(INCLUDE) $<
37 |
38 | RHNRFSPIDriver.o: $(RADIOHEADBASE)/RHNRFSPIDriver.cpp
39 | $(CC) $(CFLAGS) -c $(INCLUDE) $<
40 |
41 | RHGenericDriver.o: $(RADIOHEADBASE)/RHGenericDriver.cpp
42 | $(CC) $(CFLAGS) -c $(INCLUDE) $<
43 |
44 | RHGenericSPI.o: $(RADIOHEADBASE)/RHGenericSPI.cpp
45 | $(CC) $(CFLAGS) -c $(INCLUDE) $<
46 |
47 | RasPiRH: RasPiRH.o RH_NRF24.o RHMesh.o RHRouter.o RHReliableDatagram.o RHDatagram.o RasPi.o RHHardwareSPI.o RHNRFSPIDriver.o RHGenericDriver.o RHGenericSPI.o
48 | $(CC) $^ $(LIBS) -o RasPiRH
49 |
50 |
51 | clean:
52 | rm -rf *.o RasPiRH
53 |
54 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf22/rf22_client/rf22_client.pde:
--------------------------------------------------------------------------------
1 | // rf22_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple messageing client
4 | // with the RH_RF22 class. RH_RF22 class does not provide for addressing or
5 | // reliability, so you should only use RH_RF22 if you do not need the higher
6 | // level messaging abilities.
7 | // It is designed to work with the other example rf22_server
8 | // Tested on Duemilanove, Uno with Sparkfun RFM22 wireless shield
9 | // Tested on Flymaple with sparkfun RFM22 wireless shield
10 | // Tested on ChiKit Uno32 with sparkfun RFM22 wireless shield
11 |
12 | #include
13 | #include
14 |
15 | // Singleton instance of the radio driver
16 | RH_RF22 rf22;
17 |
18 | void setup()
19 | {
20 | Serial.begin(9600);
21 | if (!rf22.init())
22 | Serial.println("init failed");
23 | // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
24 | }
25 |
26 | void loop()
27 | {
28 | Serial.println("Sending to rf22_server");
29 | // Send a message to rf22_server
30 | uint8_t data[] = "Hello World!";
31 | rf22.send(data, sizeof(data));
32 |
33 | rf22.waitPacketSent();
34 | // Now wait for a reply
35 | uint8_t buf[RH_RF22_MAX_MESSAGE_LEN];
36 | uint8_t len = sizeof(buf);
37 |
38 | if (rf22.waitAvailableTimeout(500))
39 | {
40 | // Should be a reply message for us now
41 | if (rf22.recv(buf, &len))
42 | {
43 | Serial.print("got reply: ");
44 | Serial.println((char*)buf);
45 | }
46 | else
47 | {
48 | Serial.println("recv failed");
49 | }
50 | }
51 | else
52 | {
53 | Serial.println("No reply, is rf22_server running?");
54 | }
55 | delay(400);
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf22/rf22_mesh_client/rf22_mesh_client.pde:
--------------------------------------------------------------------------------
1 | // rf22_mesh_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, routed reliable messaging client
4 | // with the RHMesh class.
5 | // It is designed to work with the other examples rf22_mesh_server*
6 | // Hint: you can simulate other network topologies by setting the
7 | // RH_TEST_NETWORK define in RHRouter.h
8 |
9 | // Mesh has much greater memory requirements, and you may need to limit the
10 | // max message length to prevent wierd crashes
11 | #define RH_MESH_MAX_MESSAGE_LEN 50
12 |
13 | #include
14 | #include
15 | #include
16 |
17 | // In this small artifical network of 4 nodes,
18 | #define CLIENT_ADDRESS 1
19 | #define SERVER1_ADDRESS 2
20 | #define SERVER2_ADDRESS 3
21 | #define SERVER3_ADDRESS 4
22 |
23 | // Singleton instance of the radio driver
24 | RH_RF22 driver;
25 |
26 | // Class to manage message delivery and receipt, using the driver declared above
27 | RHMesh manager(driver, CLIENT_ADDRESS);
28 |
29 | void setup()
30 | {
31 | Serial.begin(9600);
32 | if (!manager.init())
33 | Serial.println("init failed");
34 | // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
35 | }
36 |
37 | uint8_t data[] = "Hello World!";
38 | // Dont put this on the stack:
39 | uint8_t buf[RH_MESH_MAX_MESSAGE_LEN];
40 |
41 | void loop()
42 | {
43 | Serial.println("Sending to manager_mesh_server3");
44 |
45 | // Send a message to a rf22_mesh_server
46 | // A route to the destination will be automatically discovered.
47 | if (manager.sendtoWait(data, sizeof(data), SERVER3_ADDRESS) == RH_ROUTER_ERROR_NONE)
48 | {
49 | // It has been reliably delivered to the next node.
50 | // Now wait for a reply from the ultimate server
51 | uint8_t len = sizeof(buf);
52 | uint8_t from;
53 | if (manager.recvfromAckTimeout(buf, &len, 3000, &from))
54 | {
55 | Serial.print("got reply from : 0x");
56 | Serial.print(from, HEX);
57 | Serial.print(": ");
58 | Serial.println((char*)buf);
59 | }
60 | else
61 | {
62 | Serial.println("No reply, is rf22_mesh_server1, rf22_mesh_server2 and rf22_mesh_server3 running?");
63 | }
64 | }
65 | else
66 | Serial.println("sendtoWait failed. Are the intermediate mesh servers running?");
67 | }
68 |
69 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf22/rf22_mesh_server1/rf22_mesh_server1.pde:
--------------------------------------------------------------------------------
1 | // rf22_mesh_server1.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, routed reliable messaging server
4 | // with the RHMesh class.
5 | // It is designed to work with the other examples rf22_mesh_*
6 | // Hint: you can simulate other network topologies by setting the
7 | // RH_TEST_NETWORK define in RHRouter.h
8 |
9 | // Mesh has much greater memory requirements, and you may need to limit the
10 | // max message length to prevent wierd crashes
11 | #define RH_MESH_MAX_MESSAGE_LEN 50
12 |
13 | #include
14 | #include
15 | #include
16 |
17 | // In this small artifical network of 4 nodes,
18 | #define CLIENT_ADDRESS 1
19 | #define SERVER1_ADDRESS 2
20 | #define SERVER2_ADDRESS 3
21 | #define SERVER3_ADDRESS 4
22 |
23 | // Singleton instance of the radio driver
24 | RH_RF22 driver;
25 |
26 | // Class to manage message delivery and receipt, using the driver declared above
27 | RHMesh manager(driver, SERVER1_ADDRESS);
28 |
29 | void setup()
30 | {
31 | Serial.begin(9600);
32 | if (!manager.init())
33 | Serial.println("RF22 init failed");
34 | // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
35 | }
36 |
37 | uint8_t data[] = "And hello back to you from server1";
38 | // Dont put this on the stack:
39 | uint8_t buf[RH_MESH_MAX_MESSAGE_LEN];
40 | void loop()
41 | {
42 | uint8_t len = sizeof(buf);
43 | uint8_t from;
44 | if (manager.recvfromAck(buf, &len, &from))
45 | {
46 | Serial.print("got request from : 0x");
47 | Serial.print(from, HEX);
48 | Serial.print(": ");
49 | Serial.println((char*)buf);
50 |
51 | // Send a reply back to the originator client
52 | if (manager.sendtoWait(data, sizeof(data), from) != RH_ROUTER_ERROR_NONE)
53 | Serial.println("sendtoWait failed");
54 | }
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf22/rf22_mesh_server2/rf22_mesh_server2.pde:
--------------------------------------------------------------------------------
1 | // rf22_mesh_server1.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, routed reliable messaging server
4 | // with the RHMesh class.
5 | // It is designed to work with the other examples rf22_mesh_*
6 | // Hint: you can simulate other network topologies by setting the
7 | // RH_TEST_NETWORK define in RHRouter.h
8 |
9 | // Mesh has much greater memory requirements, and you may need to limit the
10 | // max message length to prevent wierd crashes
11 | #define RH_MESH_MAX_MESSAGE_LEN 50
12 |
13 | #include
14 | #include
15 | #include
16 |
17 | // In this small artifical network of 4 nodes,
18 | #define CLIENT_ADDRESS 1
19 | #define SERVER1_ADDRESS 2
20 | #define SERVER2_ADDRESS 3
21 | #define SERVER3_ADDRESS 4
22 |
23 | // Singleton instance of the radio driver
24 | RH_RF22 driver;
25 |
26 | // Class to manage message delivery and receipt, using the driver declared above
27 | RHMesh manager(driver, SERVER2_ADDRESS);
28 |
29 | void setup()
30 | {
31 | Serial.begin(9600);
32 | if (!manager.init())
33 | Serial.println("RF22 init failed");
34 | // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
35 | }
36 |
37 | uint8_t data[] = "And hello back to you from server2";
38 | // Dont put this on the stack:
39 | uint8_t buf[RH_MESH_MAX_MESSAGE_LEN];
40 | void loop()
41 | {
42 | uint8_t len = sizeof(buf);
43 | uint8_t from;
44 | if (manager.recvfromAck(buf, &len, &from))
45 | {
46 | Serial.print("got request from : 0x");
47 | Serial.print(from, HEX);
48 | Serial.print(": ");
49 | Serial.println((char*)buf);
50 |
51 | // Send a reply back to the originator client
52 | if (manager.sendtoWait(data, sizeof(data), from) != RH_ROUTER_ERROR_NONE)
53 | Serial.println("sendtoWait failed");
54 | }
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf22/rf22_mesh_server3/rf22_mesh_server3.pde:
--------------------------------------------------------------------------------
1 | // rf22_mesh_server3.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, routed reliable messaging server
4 | // with the RHMesh class.
5 | // It is designed to work with the other examples rf22_mesh_*
6 | // Hint: you can simulate other network topologies by setting the
7 | // RH_TEST_NETWORK define in RHRouter.h
8 |
9 | // Mesh has much greater memory requirements, and you may need to limit the
10 | // max message length to prevent wierd crashes
11 | #define RH_MESH_MAX_MESSAGE_LEN 50
12 |
13 | #include
14 | #include
15 | #include
16 |
17 | // In this small artifical network of 4 nodes,
18 | #define CLIENT_ADDRESS 1
19 | #define SERVER1_ADDRESS 2
20 | #define SERVER2_ADDRESS 3
21 | #define SERVER3_ADDRESS 4
22 |
23 | // Singleton instance of the radio driver
24 | RH_RF22 driver;
25 |
26 | // Class to manage message delivery and receipt, using the driver declared above
27 | RHMesh manager(driver, SERVER3_ADDRESS);
28 |
29 | void setup()
30 | {
31 | Serial.begin(9600);
32 | if (!manager.init())
33 | Serial.println("RF22 init failed");
34 | // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
35 | }
36 |
37 | uint8_t data[] = "And hello back to you from server3";
38 | // Dont put this on the stack:
39 | uint8_t buf[RH_MESH_MAX_MESSAGE_LEN];
40 | void loop()
41 | {
42 | uint8_t len = sizeof(buf);
43 | uint8_t from;
44 | if (manager.recvfromAck(buf, &len, &from))
45 | {
46 | Serial.print("got request from : 0x");
47 | Serial.print(from, HEX);
48 | Serial.print(": ");
49 | Serial.println((char*)buf);
50 |
51 | // Send a reply back to the originator client
52 | if (manager.sendtoWait(data, sizeof(data), from) != RH_ROUTER_ERROR_NONE)
53 | Serial.println("sendtoWait failed");
54 | }
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf22/rf22_reliable_datagram_client/rf22_reliable_datagram_client.pde:
--------------------------------------------------------------------------------
1 | // rf22_reliable_datagram_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging client
4 | // with the RHReliableDatagram class, using the RH_RF22 driver to control a RF22 radio.
5 | // It is designed to work with the other example rf22_reliable_datagram_server
6 | // Tested on Duemilanove, Uno with Sparkfun RFM22 wireless shield
7 | // Tested on Flymaple with sparkfun RFM22 wireless shield
8 | // Tested on ChiKit Uno32 with sparkfun RFM22 wireless shield
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #define CLIENT_ADDRESS 1
15 | #define SERVER_ADDRESS 2
16 |
17 | // Singleton instance of the radio driver
18 | RH_RF22 driver;
19 |
20 | // Class to manage message delivery and receipt, using the driver declared above
21 | RHReliableDatagram manager(driver, CLIENT_ADDRESS);
22 |
23 | void setup()
24 | {
25 | Serial.begin(9600);
26 | if (!manager.init())
27 | Serial.println("init failed");
28 | // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
29 | }
30 |
31 | uint8_t data[] = "Hello World!";
32 | // Dont put this on the stack:
33 | uint8_t buf[RH_RF22_MAX_MESSAGE_LEN];
34 |
35 | void loop()
36 | {
37 | Serial.println("Sending to rf22_reliable_datagram_server");
38 |
39 | // Send a message to manager_server
40 | if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
41 | {
42 | // Now wait for a reply from the server
43 | uint8_t len = sizeof(buf);
44 | uint8_t from;
45 | if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
46 | {
47 | Serial.print("got reply from : 0x");
48 | Serial.print(from, HEX);
49 | Serial.print(": ");
50 | Serial.println((char*)buf);
51 | }
52 | else
53 | {
54 | Serial.println("No reply, is rf22_reliable_datagram_server running?");
55 | }
56 | }
57 | else
58 | Serial.println("sendtoWait failed");
59 | delay(500);
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf22/rf22_reliable_datagram_server/rf22_reliable_datagram_server.pde:
--------------------------------------------------------------------------------
1 | // rf22_reliable_datagram_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging server
4 | // with the RHReliableDatagram class, using the RH_RF22 driver to control a RF22 radio.
5 | // It is designed to work with the other example rf22_reliable_datagram_client
6 | // Tested on Duemilanove, Uno with Sparkfun RFM22 wireless shield
7 | // Tested on Flymaple with sparkfun RFM22 wireless shield
8 | // Tested on ChiKit Uno32 with sparkfun RFM22 wireless shield
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #define CLIENT_ADDRESS 1
15 | #define SERVER_ADDRESS 2
16 |
17 | // Singleton instance of the radio driver
18 | RH_RF22 driver;
19 |
20 | // Class to manage message delivery and receipt, using the driver declared above
21 | RHReliableDatagram manager(driver, SERVER_ADDRESS);
22 |
23 | void setup()
24 | {
25 | Serial.begin(9600);
26 | if (!manager.init())
27 | Serial.println("init failed");
28 | // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
29 | }
30 |
31 | uint8_t data[] = "And hello back to you";
32 | // Dont put this on the stack:
33 | uint8_t buf[RH_RF22_MAX_MESSAGE_LEN];
34 |
35 | void loop()
36 | {
37 | if (manager.available())
38 | {
39 | // Wait for a message addressed to us from the client
40 | uint8_t len = sizeof(buf);
41 | uint8_t from;
42 | if (manager.recvfromAck(buf, &len, &from))
43 | {
44 | Serial.print("got request from : 0x");
45 | Serial.print(from, HEX);
46 | Serial.print(": ");
47 | Serial.println((char*)buf);
48 |
49 | // Send a reply back to the originator client
50 | if (!manager.sendtoWait(data, sizeof(data), from))
51 | Serial.println("sendtoWait failed");
52 | }
53 | }
54 | }
55 |
56 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf22/rf22_router_client/rf22_router_client.pde:
--------------------------------------------------------------------------------
1 | // rf22_router_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, routed reliable messaging client
4 | // with the RHRouter class.
5 | // It is designed to work with the other examples rf22_router_server*
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | // In this small artifical network of 4 nodes,
12 | // messages are routed via intermediate nodes to their destination
13 | // node. All nodes can act as routers
14 | // CLIENT_ADDRESS <-> SERVER1_ADDRESS <-> SERVER2_ADDRESS<->SERVER3_ADDRESS
15 | #define CLIENT_ADDRESS 1
16 | #define SERVER1_ADDRESS 2
17 | #define SERVER2_ADDRESS 3
18 | #define SERVER3_ADDRESS 4
19 |
20 | // Singleton instance of the radio driver
21 | RH_RF22 driver;
22 |
23 | // Class to manage message delivery and receipt, using the driver declared above
24 | RHRouter manager(driver, CLIENT_ADDRESS);
25 |
26 | void setup()
27 | {
28 | Serial.begin(9600);
29 | if (!manager.init())
30 | Serial.println("init failed");
31 | // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
32 |
33 | // Manually define the routes for this network
34 | manager.addRouteTo(SERVER1_ADDRESS, SERVER1_ADDRESS);
35 | manager.addRouteTo(SERVER2_ADDRESS, SERVER2_ADDRESS);
36 | manager.addRouteTo(SERVER3_ADDRESS, SERVER3_ADDRESS);
37 | }
38 |
39 | uint8_t data[] = "Hello World!";
40 | // Dont put this on the stack:
41 | uint8_t buf[RH_ROUTER_MAX_MESSAGE_LEN];
42 |
43 | void loop()
44 | {
45 | Serial.println("Sending to rf22_router_server3");
46 |
47 | // Send a message to a rf22_router_server
48 | // It will be routed by the intermediate
49 | // nodes to the destination node, accorinding to the
50 | // routing tables in each node
51 | if (manager.sendtoWait(data, sizeof(data), SERVER3_ADDRESS) == RH_ROUTER_ERROR_NONE)
52 | {
53 | // It has been reliably delivered to the next node.
54 | // Now wait for a reply from the ultimate server
55 | uint8_t len = sizeof(buf);
56 | uint8_t from;
57 | if (manager.recvfromAckTimeout(buf, &len, 3000, &from))
58 | {
59 | Serial.print("got reply from : 0x");
60 | Serial.print(from, HEX);
61 | Serial.print(": ");
62 | Serial.println((char*)buf);
63 | }
64 | else
65 | {
66 | Serial.println("No reply, is rf22_router_server1, rf22_router_server2 and rf22_router_server3 running?");
67 | }
68 | }
69 | else
70 | Serial.println("sendtoWait failed. Are the intermediate router servers running?");
71 | }
72 |
73 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf22/rf22_router_server1/rf22_router_server1.pde:
--------------------------------------------------------------------------------
1 | // rf22_router_server1.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, routed reliable messaging server
4 | // with the RHRouter class.
5 | // It is designed to work with the other example rf22_router_client
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | // In this small artifical network of 4 nodes,
12 | // messages are routed via intermediate nodes to their destination
13 | // node. All nodes can act as routers
14 | // CLIENT_ADDRESS <-> SERVER1_ADDRESS <-> SERVER2_ADDRESS<->SERVER3_ADDRESS
15 | #define CLIENT_ADDRESS 1
16 | #define SERVER1_ADDRESS 2
17 | #define SERVER2_ADDRESS 3
18 | #define SERVER3_ADDRESS 4
19 |
20 | // Singleton instance of the radio
21 | RH_RF22 driver;
22 |
23 | // Class to manage message delivery and receipt, using the driver declared above
24 | RHRouter manager(driver, SERVER1_ADDRESS);
25 |
26 | void setup()
27 | {
28 | Serial.begin(9600);
29 | if (!manager.init())
30 | Serial.println("init failed");
31 | // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
32 |
33 | // Manually define the routes for this network
34 | manager.addRouteTo(CLIENT_ADDRESS, CLIENT_ADDRESS);
35 | manager.addRouteTo(SERVER2_ADDRESS, SERVER2_ADDRESS);
36 | manager.addRouteTo(SERVER3_ADDRESS, SERVER2_ADDRESS);
37 | }
38 |
39 | uint8_t data[] = "And hello back to you from server1";
40 | // Dont put this on the stack:
41 | uint8_t buf[RH_ROUTER_MAX_MESSAGE_LEN];
42 |
43 | void loop()
44 | {
45 | uint8_t len = sizeof(buf);
46 | uint8_t from;
47 | if (manager.recvfromAck(buf, &len, &from))
48 | {
49 | Serial.print("got request from : 0x");
50 | Serial.print(from, HEX);
51 | Serial.print(": ");
52 | Serial.println((char*)buf);
53 |
54 | // Send a reply back to the originator client
55 | if (manager.sendtoWait(data, sizeof(data), from) != RH_ROUTER_ERROR_NONE)
56 | Serial.println("sendtoWait failed");
57 | }
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf22/rf22_router_server2/rf22_router_server2.pde:
--------------------------------------------------------------------------------
1 | // rf22_router_server2.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, routed reliable messaging server
4 | // with the RHRouter class.
5 | // It is designed to work with the other example rf22_router_client
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | // In this small artifical network of 4 nodes,
12 | // messages are routed via intermediate nodes to their destination
13 | // node. All nodes can act as routers
14 | // CLIENT_ADDRESS <-> SERVER1_ADDRESS <-> SERVER2_ADDRESS<->SERVER3_ADDRESS
15 | #define CLIENT_ADDRESS 1
16 | #define SERVER1_ADDRESS 2
17 | #define SERVER2_ADDRESS 3
18 | #define SERVER3_ADDRESS 4
19 |
20 | // Singleton instance of the radio
21 | RH_RF22 driver;
22 |
23 | // Class to manage message delivery and receipt, using the driver declared above
24 | RHRouter manager(driver, SERVER2_ADDRESS);
25 |
26 | void setup()
27 | {
28 | Serial.begin(9600);
29 | if (!manager.init())
30 | Serial.println("init failed");
31 | // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
32 |
33 | // Manually define the routes for this network
34 | manager.addRouteTo(CLIENT_ADDRESS, CLIENT_ADDRESS);
35 | manager.addRouteTo(SERVER2_ADDRESS, SERVER2_ADDRESS);
36 | manager.addRouteTo(SERVER3_ADDRESS, SERVER2_ADDRESS);
37 | }
38 |
39 | uint8_t data[] = "And hello back to you from server2";
40 | // Dont put this on the stack:
41 | uint8_t buf[RH_ROUTER_MAX_MESSAGE_LEN];
42 |
43 | void loop()
44 | {
45 | uint8_t len = sizeof(buf);
46 | uint8_t from;
47 | if (manager.recvfromAck(buf, &len, &from))
48 | {
49 | Serial.print("got request from : 0x");
50 | Serial.print(from, HEX);
51 | Serial.print(": ");
52 | Serial.println((char*)buf);
53 |
54 | // Send a reply back to the originator client
55 | if (manager.sendtoWait(data, sizeof(data), from) != RH_ROUTER_ERROR_NONE)
56 | Serial.println("sendtoWait failed");
57 | }
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf22/rf22_router_server3/rf22_router_server3.pde:
--------------------------------------------------------------------------------
1 | // rf22_router_server3.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, routed reliable messaging server
4 | // with the RHRouter class.
5 | // It is designed to work with the other example rf22_router_client
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | // In this small artifical network of 4 nodes,
12 | // messages are routed via intermediate nodes to their destination
13 | // node. All nodes can act as routers
14 | // CLIENT_ADDRESS <-> SERVER1_ADDRESS <-> SERVER2_ADDRESS<->SERVER3_ADDRESS
15 | #define CLIENT_ADDRESS 1
16 | #define SERVER1_ADDRESS 2
17 | #define SERVER2_ADDRESS 3
18 | #define SERVER3_ADDRESS 4
19 |
20 | // Singleton instance of the radio
21 | RH_RF22 driver;
22 |
23 | // Class to manage message delivery and receipt, using the driver declared above
24 | RHRouter manager(driver, SERVER3_ADDRESS);
25 |
26 | void setup()
27 | {
28 | Serial.begin(9600);
29 | if (!manager.init())
30 | Serial.println("init failed");
31 | // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
32 |
33 | // Manually define the routes for this network
34 | manager.addRouteTo(CLIENT_ADDRESS, CLIENT_ADDRESS);
35 | manager.addRouteTo(SERVER2_ADDRESS, SERVER2_ADDRESS);
36 | manager.addRouteTo(SERVER3_ADDRESS, SERVER2_ADDRESS);
37 | }
38 |
39 | uint8_t data[] = "And hello back to you from server3";
40 | // Dont put this on the stack:
41 | uint8_t buf[RH_ROUTER_MAX_MESSAGE_LEN];
42 |
43 | void loop()
44 | {
45 | uint8_t len = sizeof(buf);
46 | uint8_t from;
47 | if (manager.recvfromAck(buf, &len, &from))
48 | {
49 | Serial.print("got request from : 0x");
50 | Serial.print(from, HEX);
51 | Serial.print(": ");
52 | Serial.println((char*)buf);
53 |
54 | // Send a reply back to the originator client
55 | if (manager.sendtoWait(data, sizeof(data), from) != RH_ROUTER_ERROR_NONE)
56 | Serial.println("sendtoWait failed");
57 | }
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf22/rf22_router_test/rf22_router_test.pde:
--------------------------------------------------------------------------------
1 | // rf22_router_test.pde
2 | // -*- mode: C++ -*-
3 | //
4 | // Test code used during library development, showing how
5 | // to do various things, and how to call various functions
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | #define CLIENT_ADDRESS 1
12 | #define ROUTER_ADDRESS 2
13 | #define SERVER_ADDRESS 3
14 |
15 | // Singleton instance of the radio driver
16 | RH_RF22 driver;
17 |
18 | // Class to manage message delivery and receipt, using the driver declared above
19 | RHRouter manager(driver, CLIENT_ADDRESS);
20 |
21 | void setup()
22 | {
23 | Serial.begin(9600);
24 | if (!manager.init())
25 | Serial.println("RF22 init failed");
26 | // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
27 | }
28 |
29 | void test_routes()
30 | {
31 | manager.clearRoutingTable();
32 | // manager.printRoutingTable();
33 | manager.addRouteTo(1, 101);
34 | manager.addRouteTo(2, 102);
35 | manager.addRouteTo(3, 103);
36 | RHRouter::RoutingTableEntry* e;
37 | e = manager.getRouteTo(0);
38 | if (e) // Should fail
39 | Serial.println("getRouteTo 0 failed");
40 |
41 | e = manager.getRouteTo(1);
42 | if (!e)
43 | Serial.println("getRouteTo 1 failed");
44 | if (e->dest != 1)
45 | Serial.println("getRouteTo 2 failed");
46 | if (e->next_hop != 101)
47 | Serial.println("getRouteTo 3 failed");
48 | if (e->state != RHRouter::Valid)
49 | Serial.println("getRouteTo 4 failed");
50 |
51 | e = manager.getRouteTo(2);
52 | if (!e)
53 | Serial.println("getRouteTo 5 failed");
54 | if (e->dest != 2)
55 | Serial.println("getRouteTo 6 failed");
56 | if (e->next_hop != 102)
57 | Serial.println("getRouteTo 7 failed");
58 | if (e->state != RHRouter::Valid)
59 | Serial.println("getRouteTo 8 failed");
60 |
61 | if (!manager.deleteRouteTo(1))
62 | Serial.println("deleteRouteTo 1 failed");
63 | // Route to 1 should now be gone
64 | e = manager.getRouteTo(1);
65 | if (e)
66 | Serial.println("deleteRouteTo 2 failed");
67 |
68 | Serial.println("-------------------");
69 |
70 | // manager.printRoutingTable();
71 | delay(500);
72 |
73 | }
74 |
75 | uint8_t data[] = "Hello World!";
76 | // Dont put this on the stack:
77 | //uint8_t buf[RH_RF22_MAX_MESSAGE_LEN];
78 |
79 | void test_tx()
80 | {
81 | manager.addRouteTo(SERVER_ADDRESS, ROUTER_ADDRESS);
82 | uint8_t errorcode;
83 | errorcode = manager.sendtoWait(data, sizeof(data), 100); // Should fail with no route
84 | if (errorcode != RH_ROUTER_ERROR_NO_ROUTE)
85 | Serial.println("sendtoWait 1 failed");
86 | errorcode = manager.sendtoWait(data, 255, 10); // Should fail too big
87 | if (errorcode != RH_ROUTER_ERROR_INVALID_LENGTH)
88 | Serial.println("sendtoWait 2 failed");
89 | errorcode = manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS); // Should fail after timeouts to 110
90 | if (errorcode != RH_ROUTER_ERROR_UNABLE_TO_DELIVER)
91 | Serial.println("sendtoWait 3 failed");
92 | Serial.println("-------------------");
93 | delay(500);
94 | }
95 |
96 | void loop()
97 | {
98 | // test_routes();
99 | test_tx();
100 | }
101 |
102 |
103 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf22/rf22_server/rf22_server.pde:
--------------------------------------------------------------------------------
1 | // rf22_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple messageing server
4 | // with the RH_RF22 class. RH_RF22 class does not provide for addressing or
5 | // reliability, so you should only use RH_RF22 if you do not need the higher
6 | // level messaging abilities.
7 | // It is designed to work with the other example rf22_client
8 | // Tested on Duemilanove, Uno with Sparkfun RFM22 wireless shield
9 | // Tested on Flymaple with sparkfun RFM22 wireless shield
10 | // Tested on ChiKit Uno32 with sparkfun RFM22 wireless shield
11 |
12 | #include
13 | #include
14 |
15 | // Singleton instance of the radio driver
16 | RH_RF22 rf22;
17 |
18 | void setup()
19 | {
20 | Serial.begin(9600);
21 | if (!rf22.init())
22 | Serial.println("init failed");
23 | // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
24 | }
25 |
26 | void loop()
27 | {
28 | if (rf22.available())
29 | {
30 | // Should be a message for us now
31 | uint8_t buf[RH_RF22_MAX_MESSAGE_LEN];
32 | uint8_t len = sizeof(buf);
33 | if (rf22.recv(buf, &len))
34 | {
35 | // RF22::printBuffer("request: ", buf, len);
36 | Serial.print("got request: ");
37 | Serial.println((char*)buf);
38 | // Serial.print("RSSI: ");
39 | // Serial.println(rf22.lastRssi(), DEC);
40 |
41 | // Send a reply
42 | uint8_t data[] = "And hello back to you";
43 | rf22.send(data, sizeof(data));
44 | rf22.waitPacketSent();
45 | Serial.println("Sent a reply");
46 | }
47 | else
48 | {
49 | Serial.println("recv failed");
50 | }
51 | }
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf24/rf24_client/rf24_client.pde:
--------------------------------------------------------------------------------
1 | // rf24_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple messageing client
4 | // with the RH_RF24 class. RH_RF24 class does not provide for addressing or
5 | // reliability, so you should only use RH_RF24 if you do not need the higher
6 | // level messaging abilities.
7 | // It is designed to work with the other example rf24_server.
8 | // Tested on Anarduino Mini http://www.anarduino.com/mini/ with RFM24W and RFM26W
9 |
10 | #include
11 | #include
12 |
13 | // Singleton instance of the radio driver
14 | RH_RF24 rf24;
15 |
16 | void setup()
17 | {
18 | Serial.begin(9600);
19 | if (!rf24.init())
20 | Serial.println("init failed");
21 | // Defaults after init are 434.0MHz, modulation GFSK_Rb5Fd10, power 0x10
22 | // if (!rf24.setFrequency(433.0))
23 | // Serial.println("setFrequency failed");
24 | }
25 |
26 |
27 | void loop()
28 | {
29 | Serial.println("Sending to rf24_server");
30 | // Send a message to rf24_server
31 | uint8_t data[] = "Hello World!";
32 | rf24.send(data, sizeof(data));
33 |
34 | rf24.waitPacketSent();
35 | // Now wait for a reply
36 | uint8_t buf[RH_RF24_MAX_MESSAGE_LEN];
37 | uint8_t len = sizeof(buf);
38 |
39 | if (rf24.waitAvailableTimeout(500))
40 | {
41 | // Should be a reply message for us now
42 | if (rf24.recv(buf, &len))
43 | {
44 | Serial.print("got reply: ");
45 | Serial.println((char*)buf);
46 | }
47 | else
48 | {
49 | Serial.println("recv failed");
50 | }
51 | }
52 | else
53 | {
54 | Serial.println("No reply, is rf24_server running?");
55 | }
56 | delay(400);
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf24/rf24_reliable_datagram_client/rf24_reliable_datagram_client.pde:
--------------------------------------------------------------------------------
1 | // rf24_reliable_datagram_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging client
4 | // with the RHReliableDatagram class, using the RH_RF24 driver to control a RF24 radio.
5 | // It is designed to work with the other example rf24_reliable_datagram_server
6 | // Tested on Anarduino Mini http://www.anarduino.com/mini/ with RFM24W and RFM26W
7 |
8 | #include
9 | #include
10 | #include
11 |
12 | #define CLIENT_ADDRESS 1
13 | #define SERVER_ADDRESS 2
14 |
15 | // Singleton instance of the radio driver
16 | RH_RF24 driver;
17 |
18 | // Class to manage message delivery and receipt, using the driver declared above
19 | RHReliableDatagram manager(driver, CLIENT_ADDRESS);
20 |
21 | void setup()
22 | {
23 | Serial.begin(9600);
24 | if (!manager.init())
25 | Serial.println("init failed");
26 | // Defaults after init are 434.0MHz, modulation GFSK_Rb5Fd10, power 0x10
27 | }
28 |
29 | uint8_t data[] = "Hello World!";
30 | // Dont put this on the stack:
31 | uint8_t buf[RH_RF24_MAX_MESSAGE_LEN];
32 |
33 | void loop()
34 | {
35 | Serial.println("Sending to rf24_reliable_datagram_server");
36 |
37 | // Send a message to manager_server
38 | if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
39 | {
40 | // Now wait for a reply from the server
41 | uint8_t len = sizeof(buf);
42 | uint8_t from;
43 | if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
44 | {
45 | Serial.print("got reply from : 0x");
46 | Serial.print(from, HEX);
47 | Serial.print(": ");
48 | Serial.println((char*)buf);
49 | }
50 | else
51 | {
52 | Serial.println("No reply, is rf24_reliable_datagram_server running?");
53 | }
54 | }
55 | else
56 | Serial.println("sendtoWait failed");
57 | delay(500);
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf24/rf24_reliable_datagram_server/rf24_reliable_datagram_server.pde:
--------------------------------------------------------------------------------
1 | // rf24_reliable_datagram_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging server
4 | // with the RHReliableDatagram class, using the RH_RF24 driver to control a RF24 radio.
5 | // It is designed to work with the other example rf24_reliable_datagram_client
6 | // Tested on Anarduino Mini http://www.anarduino.com/mini/ with RFM24W and RFM26W
7 |
8 | #include
9 | #include
10 | #include
11 |
12 | #define CLIENT_ADDRESS 1
13 | #define SERVER_ADDRESS 2
14 |
15 | // Singleton instance of the radio driver
16 | RH_RF24 driver;
17 |
18 | // Class to manage message delivery and receipt, using the driver declared above
19 | RHReliableDatagram manager(driver, SERVER_ADDRESS);
20 |
21 | void setup()
22 | {
23 | Serial.begin(9600);
24 | if (!manager.init())
25 | Serial.println("init failed");
26 | // Defaults after init are 434.0MHz, modulation GFSK_Rb5Fd10, power 0x10
27 | }
28 |
29 | uint8_t data[] = "And hello back to you";
30 | // Dont put this on the stack:
31 | uint8_t buf[RH_RF24_MAX_MESSAGE_LEN];
32 |
33 | void loop()
34 | {
35 | if (manager.available())
36 | {
37 | // Wait for a message addressed to us from the client
38 | uint8_t len = sizeof(buf);
39 | uint8_t from;
40 | if (manager.recvfromAck(buf, &len, &from))
41 | {
42 | Serial.print("got request from : 0x");
43 | Serial.print(from, HEX);
44 | Serial.print(": ");
45 | Serial.println((char*)buf);
46 |
47 | // Send a reply back to the originator client
48 | if (!manager.sendtoWait(data, sizeof(data), from))
49 | Serial.println("sendtoWait failed");
50 | }
51 | }
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf24/rf24_server/rf24_server.pde:
--------------------------------------------------------------------------------
1 | // rf24_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple messageing server
4 | // with the RH_RF24 class. RH_RF24 class does not provide for addressing or
5 | // reliability, so you should only use RH_RF24 if you do not need the higher
6 | // level messaging abilities.
7 | // It is designed to work with the other example rf24_client
8 | // Tested on Anarduino Mini http://www.anarduino.com/mini/ with RFM24W and RFM26W
9 |
10 | #include
11 | #include
12 |
13 | // Singleton instance of the radio driver
14 | RH_RF24 rf24;
15 |
16 | void setup()
17 | {
18 | Serial.begin(9600);
19 | if (!rf24.init())
20 | Serial.println("init failed");
21 | // Defaults after init are 434.0MHz, modulation GFSK_Rb5Fd10, power 0x10
22 | // if (!rf24.setFrequency(433.0))
23 | // Serial.println("setFrequency failed");
24 |
25 | }
26 |
27 | void loop()
28 | {
29 | if (rf24.available())
30 | {
31 | // Should be a message for us now
32 | uint8_t buf[RH_RF24_MAX_MESSAGE_LEN];
33 | uint8_t len = sizeof(buf);
34 | if (rf24.recv(buf, &len))
35 | {
36 | // RF24::printBuffer("request: ", buf, len);
37 | Serial.print("got request: ");
38 | Serial.println((char*)buf);
39 | // Serial.print("RSSI: ");
40 | // Serial.println((uint8_t)rf24.lastRssi(), DEC);
41 |
42 | // Send a reply
43 | uint8_t data[] = "And hello back to you";
44 | rf24.send(data, sizeof(data));
45 | rf24.waitPacketSent();
46 | Serial.println("Sent a reply");
47 | }
48 | else
49 | {
50 | Serial.println("recv failed");
51 | }
52 | }
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf69/rf69_client/rf69_client.pde:
--------------------------------------------------------------------------------
1 | // rf69_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple messageing client
4 | // with the RH_RF69 class. RH_RF69 class does not provide for addressing or
5 | // reliability, so you should only use RH_RF69 if you do not need the higher
6 | // level messaging abilities.
7 | // It is designed to work with the other example rf69_server.
8 | // Demonstrates the use of AES encryption, setting the frequency and modem
9 | // configuration
10 | // Tested on Moteino with RFM69 http://lowpowerlab.com/moteino/
11 | // Tested on miniWireless with RFM69 www.anarduino.com/miniwireless
12 | // Tested on Teensy 3.1 with RF69 on PJRC breakout board
13 |
14 | #include
15 | #include
16 |
17 | // Singleton instance of the radio driver
18 | RH_RF69 rf69;
19 | //RH_RF69 rf69(15, 16); // For RF69 on PJRC breakout board with Teensy 3.1
20 |
21 | void setup()
22 | {
23 | Serial.begin(9600);
24 | if (!rf69.init())
25 | Serial.println("init failed");
26 | // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
27 | // No encryption
28 | if (!rf69.setFrequency(433.0))
29 | Serial.println("setFrequency failed");
30 |
31 | // If you are using a high power RF69, you *must* set a Tx power in the
32 | // range 14 to 20 like this:
33 | // rf69.setTxPower(14);
34 |
35 | // The encryption key has to be the same as the one in the server
36 | uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
37 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
38 | rf69.setEncryptionKey(key);
39 | }
40 |
41 |
42 | void loop()
43 | {
44 | Serial.println("Sending to rf69_server");
45 | // Send a message to rf69_server
46 | uint8_t data[] = "Hello World!";
47 | rf69.send(data, sizeof(data));
48 |
49 | rf69.waitPacketSent();
50 | // Now wait for a reply
51 | uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
52 | uint8_t len = sizeof(buf);
53 |
54 | if (rf69.waitAvailableTimeout(500))
55 | {
56 | // Should be a reply message for us now
57 | if (rf69.recv(buf, &len))
58 | {
59 | Serial.print("got reply: ");
60 | Serial.println((char*)buf);
61 | }
62 | else
63 | {
64 | Serial.println("recv failed");
65 | }
66 | }
67 | else
68 | {
69 | Serial.println("No reply, is rf69_server running?");
70 | }
71 | delay(400);
72 | }
73 |
74 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf69/rf69_reliable_datagram_client/rf69_reliable_datagram_client.pde:
--------------------------------------------------------------------------------
1 | // rf69_reliable_datagram_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging client
4 | // with the RHReliableDatagram class, using the RH_RF69 driver to control a RF69 radio.
5 | // It is designed to work with the other example rf69_reliable_datagram_server
6 | // Tested on Moteino with RFM69 http://lowpowerlab.com/moteino/
7 | // Tested on miniWireless with RFM69 www.anarduino.com/miniwireless
8 | // Tested on Teensy 3.1 with RF69 on PJRC breakout board
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #define CLIENT_ADDRESS 1
15 | #define SERVER_ADDRESS 2
16 |
17 | // Singleton instance of the radio driver
18 | RH_RF69 driver;
19 | //RH_RF69 driver(15, 16); // For RF69 on PJRC breakout board with Teensy 3.1
20 | //RH_RF69 rf69(4, 2); // For MoteinoMEGA https://lowpowerlab.com/shop/moteinomega
21 |
22 | // Class to manage message delivery and receipt, using the driver declared above
23 | RHReliableDatagram manager(driver, CLIENT_ADDRESS);
24 |
25 | void setup()
26 | {
27 | Serial.begin(9600);
28 | if (!manager.init())
29 | Serial.println("init failed");
30 | // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
31 |
32 | // If you are using a high power RF69, you *must* set a Tx power in the
33 | // range 14 to 20 like this:
34 | // driver.setTxPower(14);
35 | }
36 |
37 | uint8_t data[] = "Hello World!";
38 | // Dont put this on the stack:
39 | uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
40 |
41 | void loop()
42 | {
43 | Serial.println("Sending to rf69_reliable_datagram_server");
44 |
45 | // Send a message to manager_server
46 | if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
47 | {
48 | // Now wait for a reply from the server
49 | uint8_t len = sizeof(buf);
50 | uint8_t from;
51 | if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
52 | {
53 | Serial.print("got reply from : 0x");
54 | Serial.print(from, HEX);
55 | Serial.print(": ");
56 | Serial.println((char*)buf);
57 | }
58 | else
59 | {
60 | Serial.println("No reply, is rf69_reliable_datagram_server running?");
61 | }
62 | }
63 | else
64 | Serial.println("sendtoWait failed");
65 | delay(500);
66 | }
67 |
68 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf69/rf69_reliable_datagram_server/rf69_reliable_datagram_server.pde:
--------------------------------------------------------------------------------
1 | // rf69_reliable_datagram_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging server
4 | // with the RHReliableDatagram class, using the RH_RF69 driver to control a RF69 radio.
5 | // It is designed to work with the other example rf69_reliable_datagram_client
6 | // Tested on Moteino with RFM69 http://lowpowerlab.com/moteino/
7 | // Tested on miniWireless with RFM69 www.anarduino.com/miniwireless
8 | // Tested on Teensy 3.1 with RF69 on PJRC breakout board
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #define CLIENT_ADDRESS 1
15 | #define SERVER_ADDRESS 2
16 |
17 | // Singleton instance of the radio driver
18 | RH_RF69 driver;
19 | //RH_RF69 driver(15, 16); // For RF69 on PJRC breakout board with Teensy 3.1
20 | //RH_RF69 rf69(4, 2); // For MoteinoMEGA https://lowpowerlab.com/shop/moteinomega
21 |
22 | // Class to manage message delivery and receipt, using the driver declared above
23 | RHReliableDatagram manager(driver, SERVER_ADDRESS);
24 |
25 | void setup()
26 | {
27 | Serial.begin(9600);
28 | if (!manager.init())
29 | Serial.println("init failed");
30 | // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
31 |
32 | // If you are using a high power RF69, you *must* set a Tx power in the
33 | // range 14 to 20 like this:
34 | // driver.setTxPower(14);
35 | }
36 |
37 | uint8_t data[] = "And hello back to you";
38 | // Dont put this on the stack:
39 | uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
40 |
41 | void loop()
42 | {
43 | if (manager.available())
44 | {
45 | // Wait for a message addressed to us from the client
46 | uint8_t len = sizeof(buf);
47 | uint8_t from;
48 | if (manager.recvfromAck(buf, &len, &from))
49 | {
50 | Serial.print("got request from : 0x");
51 | Serial.print(from, HEX);
52 | Serial.print(": ");
53 | Serial.println((char*)buf);
54 |
55 | // Send a reply back to the originator client
56 | if (!manager.sendtoWait(data, sizeof(data), from))
57 | Serial.println("sendtoWait failed");
58 | }
59 | }
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf69/rf69_server/rf69_server.pde:
--------------------------------------------------------------------------------
1 | // rf69_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple messageing server
4 | // with the RH_RF69 class. RH_RF69 class does not provide for addressing or
5 | // reliability, so you should only use RH_RF69 if you do not need the higher
6 | // level messaging abilities.
7 | // It is designed to work with the other example rf69_client
8 | // Demonstrates the use of AES encryption, setting the frequency and modem
9 | // configuration.
10 | // Tested on Moteino with RFM69 http://lowpowerlab.com/moteino/
11 | // Tested on miniWireless with RFM69 www.anarduino.com/miniwireless
12 | // Tested on Teensy 3.1 with RF69 on PJRC breakout board
13 |
14 | #include
15 | #include
16 |
17 | // Singleton instance of the radio driver
18 | RH_RF69 rf69;
19 | //RH_RF69 rf69(15, 16); // For RF69 on PJRC breakout board with Teensy 3.1
20 | //RH_RF69 rf69(4, 2); // For MoteinoMEGA https://lowpowerlab.com/shop/moteinomega
21 |
22 | void setup()
23 | {
24 | Serial.begin(9600);
25 | if (!rf69.init())
26 | Serial.println("init failed");
27 | // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
28 | // No encryption
29 | if (!rf69.setFrequency(433.0))
30 | Serial.println("setFrequency failed");
31 |
32 | // If you are using a high power RF69, you *must* set a Tx power in the
33 | // range 14 to 20 like this:
34 | // rf69.setTxPower(14);
35 |
36 | // The encryption key has to be the same as the one in the client
37 | uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
38 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
39 | rf69.setEncryptionKey(key);
40 |
41 | #if 0
42 | // For compat with RFM69 Struct_send
43 | rf69.setModemConfig(RH_RF69::GFSK_Rb250Fd250);
44 | rf69.setPreambleLength(3);
45 | uint8_t syncwords[] = { 0x2d, 0x64 };
46 | rf69.setSyncWords(syncwords, sizeof(syncwords));
47 | rf69.setEncryptionKey((uint8_t*)"thisIsEncryptKey");
48 | #endif
49 | }
50 |
51 | void loop()
52 | {
53 | if (rf69.available())
54 | {
55 | // Should be a message for us now
56 | uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
57 | uint8_t len = sizeof(buf);
58 | if (rf69.recv(buf, &len))
59 | {
60 | // RH_RF69::printBuffer("request: ", buf, len);
61 | Serial.print("got request: ");
62 | Serial.println((char*)buf);
63 | // Serial.print("RSSI: ");
64 | // Serial.println(rf69.lastRssi(), DEC);
65 |
66 | // Send a reply
67 | uint8_t data[] = "And hello back to you";
68 | rf69.send(data, sizeof(data));
69 | rf69.waitPacketSent();
70 | Serial.println("Sent a reply");
71 | }
72 | else
73 | {
74 | Serial.println("recv failed");
75 | }
76 | }
77 | }
78 |
79 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf95/rf95_client/rf95_client.pde:
--------------------------------------------------------------------------------
1 | // rf95_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple messageing client
4 | // with the RH_RF95 class. RH_RF95 class does not provide for addressing or
5 | // reliability, so you should only use RH_RF95 if you do not need the higher
6 | // level messaging abilities.
7 | // It is designed to work with the other example rf95_server
8 | // Tested with Anarduino MiniWirelessLoRa, Rocket Scream Mini Ultra Pro with the RFM95W
9 |
10 | #include
11 | #include
12 |
13 | // Singleton instance of the radio driver
14 | RH_RF95 rf95;
15 | //RH_RF95 driver(5, 2); // Rocket Scream Mini Ultra Pro with the RFM95W
16 |
17 | // Need this on Arduino Zero with SerialUSB port (eg RocketScream Mini Ultra Pro)
18 | //#define Serial SerialUSB
19 |
20 | void setup()
21 | {
22 | // Rocket Scream Mini Ultra Pro with the RFM95W only:
23 | // Ensure serial flash is not interfering with radio communication on SPI bus
24 | // pinMode(4, OUTPUT);
25 | // digitalWrite(4, HIGH);
26 |
27 | Serial.begin(9600);
28 | while (!Serial) ; // Wait for serial port to be available
29 | if (!rf95.init())
30 | Serial.println("init failed");
31 | // Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
32 |
33 | // The default transmitter power is 13dBm, using PA_BOOST.
34 | // If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then
35 | // you can set transmitter powers from 5 to 23 dBm:
36 | // driver.setTxPower(23, false);
37 | // If you are using Modtronix inAir4 or inAir9,or any other module which uses the
38 | // transmitter RFO pins and not the PA_BOOST pins
39 | // then you can configure the power transmitter power for -1 to 14 dBm and with useRFO true.
40 | // Failure to do that will result in extremely low transmit powers.
41 | // driver.setTxPower(14, true);
42 | }
43 |
44 | void loop()
45 | {
46 | Serial.println("Sending to rf95_server");
47 | // Send a message to rf95_server
48 | uint8_t data[] = "Hello World!";
49 | rf95.send(data, sizeof(data));
50 |
51 | rf95.waitPacketSent();
52 | // Now wait for a reply
53 | uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
54 | uint8_t len = sizeof(buf);
55 |
56 | if (rf95.waitAvailableTimeout(3000))
57 | {
58 | // Should be a reply message for us now
59 | if (rf95.recv(buf, &len))
60 | {
61 | Serial.print("got reply: ");
62 | Serial.println((char*)buf);
63 | // Serial.print("RSSI: ");
64 | // Serial.println(rf95.lastRssi(), DEC);
65 | }
66 | else
67 | {
68 | Serial.println("recv failed");
69 | }
70 | }
71 | else
72 | {
73 | Serial.println("No reply, is rf95_server running?");
74 | }
75 | delay(400);
76 | }
77 |
78 |
79 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf95/rf95_reliable_datagram_client/rf95_reliable_datagram_client.pde:
--------------------------------------------------------------------------------
1 | // rf95_reliable_datagram_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging client
4 | // with the RHReliableDatagram class, using the RH_RF95 driver to control a RF95 radio.
5 | // It is designed to work with the other example rf95_reliable_datagram_server
6 | // Tested with Anarduino MiniWirelessLoRa, Rocket Scream Mini Ultra Pro with the RFM95W
7 |
8 | #include
9 | #include
10 | #include
11 |
12 | #define CLIENT_ADDRESS 1
13 | #define SERVER_ADDRESS 2
14 |
15 | // Singleton instance of the radio driver
16 | RH_RF95 driver;
17 | //RH_RF95 rf95(5, 2); // Rocket Scream Mini Ultra Pro with the RFM95W
18 |
19 | // Class to manage message delivery and receipt, using the driver declared above
20 | RHReliableDatagram manager(driver, CLIENT_ADDRESS);
21 |
22 | // Need this on Arduino Zero with SerialUSB port (eg RocketScream Mini Ultra Pro)
23 | //#define Serial SerialUSB
24 |
25 | void setup()
26 | {
27 | // Rocket Scream Mini Ultra Pro with the RFM95W only:
28 | // Ensure serial flash is not interfering with radio communication on SPI bus
29 | // pinMode(4, OUTPUT);
30 | // digitalWrite(4, HIGH);
31 |
32 | Serial.begin(9600);
33 | while (!Serial) ; // Wait for serial port to be available
34 | if (!manager.init())
35 | Serial.println("init failed");
36 | // Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
37 |
38 | // The default transmitter power is 13dBm, using PA_BOOST.
39 | // If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then
40 | // you can set transmitter powers from 5 to 23 dBm:
41 | // driver.setTxPower(23, false);
42 | // If you are using Modtronix inAir4 or inAir9,or any other module which uses the
43 | // transmitter RFO pins and not the PA_BOOST pins
44 | // then you can configure the power transmitter power for -1 to 14 dBm and with useRFO true.
45 | // Failure to do that will result in extremely low transmit powers.
46 | // driver.setTxPower(14, true);
47 | }
48 |
49 | uint8_t data[] = "Hello World!";
50 | // Dont put this on the stack:
51 | uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
52 |
53 | void loop()
54 | {
55 | Serial.println("Sending to rf95_reliable_datagram_server");
56 |
57 | // Send a message to manager_server
58 | if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
59 | {
60 | // Now wait for a reply from the server
61 | uint8_t len = sizeof(buf);
62 | uint8_t from;
63 | if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
64 | {
65 | Serial.print("got reply from : 0x");
66 | Serial.print(from, HEX);
67 | Serial.print(": ");
68 | Serial.println((char*)buf);
69 | }
70 | else
71 | {
72 | Serial.println("No reply, is rf95_reliable_datagram_server running?");
73 | }
74 | }
75 | else
76 | Serial.println("sendtoWait failed");
77 | delay(500);
78 | }
79 |
80 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf95/rf95_reliable_datagram_server/rf95_reliable_datagram_server.pde:
--------------------------------------------------------------------------------
1 | // rf95_reliable_datagram_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging server
4 | // with the RHReliableDatagram class, using the RH_RF95 driver to control a RF95 radio.
5 | // It is designed to work with the other example rf95_reliable_datagram_client
6 | // Tested with Anarduino MiniWirelessLoRa, Rocket Scream Mini Ultra Pro with the RFM95W
7 |
8 | #include
9 | #include
10 | #include
11 |
12 | #define CLIENT_ADDRESS 1
13 | #define SERVER_ADDRESS 2
14 |
15 | // Singleton instance of the radio driver
16 | RH_RF95 driver;
17 | //RH_RF95 driver(5, 2); // Rocket Scream Mini Ultra Pro with the RFM95W
18 |
19 | // Class to manage message delivery and receipt, using the driver declared above
20 | RHReliableDatagram manager(driver, SERVER_ADDRESS);
21 |
22 | // Need this on Arduino Zero with SerialUSB port (eg RocketScream Mini Ultra Pro)
23 | //#define Serial SerialUSB
24 |
25 | void setup()
26 | {
27 | // Rocket Scream Mini Ultra Pro with the RFM95W only:
28 | // Ensure serial flash is not interfering with radio communication on SPI bus
29 | // pinMode(4, OUTPUT);
30 | // digitalWrite(4, HIGH);
31 |
32 | Serial.begin(9600);
33 | while (!Serial) ; // Wait for serial port to be available
34 | if (!manager.init())
35 | Serial.println("init failed");
36 | // Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
37 |
38 | // The default transmitter power is 13dBm, using PA_BOOST.
39 | // If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then
40 | // you can set transmitter powers from 5 to 23 dBm:
41 | // driver.setTxPower(23, false);
42 | // If you are using Modtronix inAir4 or inAir9,or any other module which uses the
43 | // transmitter RFO pins and not the PA_BOOST pins
44 | // then you can configure the power transmitter power for -1 to 14 dBm and with useRFO true.
45 | // Failure to do that will result in extremely low transmit powers.
46 | // driver.setTxPower(14, true);
47 | }
48 |
49 | uint8_t data[] = "And hello back to you";
50 | // Dont put this on the stack:
51 | uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
52 |
53 | void loop()
54 | {
55 | if (manager.available())
56 | {
57 | // Wait for a message addressed to us from the client
58 | uint8_t len = sizeof(buf);
59 | uint8_t from;
60 | if (manager.recvfromAck(buf, &len, &from))
61 | {
62 | Serial.print("got request from : 0x");
63 | Serial.print(from, HEX);
64 | Serial.print(": ");
65 | Serial.println((char*)buf);
66 |
67 | // Send a reply back to the originator client
68 | if (!manager.sendtoWait(data, sizeof(data), from))
69 | Serial.println("sendtoWait failed");
70 | }
71 | }
72 | }
73 |
74 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/rf95/rf95_server/rf95_server.pde:
--------------------------------------------------------------------------------
1 | // rf95_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple messageing server
4 | // with the RH_RF95 class. RH_RF95 class does not provide for addressing or
5 | // reliability, so you should only use RH_RF95 if you do not need the higher
6 | // level messaging abilities.
7 | // It is designed to work with the other example rf95_client
8 | // Tested with Anarduino MiniWirelessLoRa, Rocket Scream Mini Ultra Pro with the RFM95W
9 |
10 |
11 | #include
12 | #include
13 |
14 | // Singleton instance of the radio driver
15 | RH_RF95 rf95;
16 | //RH_RF95 rf95(5, 2); // Rocket Scream Mini Ultra Pro with the RFM95W
17 |
18 | // Need this on Arduino Zero with SerialUSB port (eg RocketScream Mini Ultra Pro)
19 | //#define Serial SerialUSB
20 |
21 | int led = 9;
22 |
23 | void setup()
24 | {
25 | // Rocket Scream Mini Ultra Pro with the RFM95W only:
26 | // Ensure serial flash is not interfering with radio communication on SPI bus
27 | // pinMode(4, OUTPUT);
28 | // digitalWrite(4, HIGH);
29 |
30 | pinMode(led, OUTPUT);
31 | Serial.begin(9600);
32 | while (!Serial) ; // Wait for serial port to be available
33 | if (!rf95.init())
34 | Serial.println("init failed");
35 | // Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
36 |
37 | // The default transmitter power is 13dBm, using PA_BOOST.
38 | // If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then
39 | // you can set transmitter powers from 5 to 23 dBm:
40 | // driver.setTxPower(23, false);
41 | // If you are using Modtronix inAir4 or inAir9,or any other module which uses the
42 | // transmitter RFO pins and not the PA_BOOST pins
43 | // then you can configure the power transmitter power for -1 to 14 dBm and with useRFO true.
44 | // Failure to do that will result in extremely low transmit powers.
45 | // driver.setTxPower(14, true);
46 | }
47 |
48 | void loop()
49 | {
50 | if (rf95.available())
51 | {
52 | // Should be a message for us now
53 | uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
54 | uint8_t len = sizeof(buf);
55 | if (rf95.recv(buf, &len))
56 | {
57 | digitalWrite(led, HIGH);
58 | // RH_RF95::printBuffer("request: ", buf, len);
59 | Serial.print("got request: ");
60 | Serial.println((char*)buf);
61 | // Serial.print("RSSI: ");
62 | // Serial.println(rf95.lastRssi(), DEC);
63 |
64 | // Send a reply
65 | uint8_t data[] = "And hello back to you";
66 | rf95.send(data, sizeof(data));
67 | rf95.waitPacketSent();
68 | Serial.println("Sent a reply");
69 | digitalWrite(led, LOW);
70 | }
71 | else
72 | {
73 | Serial.println("recv failed");
74 | }
75 | }
76 | }
77 |
78 |
79 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/serial/serial_reliable_datagram_client/serial_reliable_datagram_client.pde:
--------------------------------------------------------------------------------
1 | // serial_reliable_datagram_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging client
4 | // with the RHReliableDatagram class, using the RH_Serial driver to
5 | // communicate using packets over a serial port (or a radio connected to a
6 | // serial port, such as the 3DR Telemetry radio V1 and others).
7 | // It is designed to work with the other example serial_reliable_datagram_server
8 | // Tested on Arduino Mega and ChipKit Uno32 (normal Arduinos only have one
9 | // serial port and so it not possible to test on them and still have debug
10 | // output)
11 | // Tested with Arduino Mega, Teensy 3.1, Moteino, Arduino Due
12 | // Also works on Linux and OSX. Build and test with:
13 | // tools/simBuild examples/serial/serial_reliable_datagram_client/serial_reliable_datagram_client.pde
14 | // RH_HARDWARESERIAL_DEVICE_NAME=/dev/ttyUSB1 ./serial_reliable_datagram_client
15 |
16 | #include
17 | #include
18 |
19 | #define CLIENT_ADDRESS 1
20 | #define SERVER_ADDRESS 2
21 |
22 | #if (RH_PLATFORM == RH_PLATFORM_UNIX)
23 | #include
24 | // On Unix we connect to a physical serial port
25 | // You can override this with RH_HARDWARESERIAL_DEVICE_NAME environment variable
26 | HardwareSerial hardwareserial("/dev/ttyUSB0");
27 | RH_Serial driver(hardwareserial);
28 |
29 | #else
30 | // On arduino etc, use a predefined local serial port
31 | // eg Serial1 on a Mega
32 | #include
33 | // Singleton instance of the Serial driver, configured
34 | // to use the port Serial1. Caution: on Uno32, Serial1 is on pins 39 (Rx) and
35 | // 40 (Tx)
36 | RH_Serial driver(Serial1);
37 | #endif
38 |
39 |
40 | // Class to manage message delivery and receipt, using the driver declared above
41 | RHReliableDatagram manager(driver, CLIENT_ADDRESS);
42 |
43 | void setup()
44 | {
45 | Serial.begin(9600);
46 | // Configure the port RH_Serial will use:
47 | driver.serial().begin(9600);
48 | if (!manager.init())
49 | Serial.println("init failed");
50 | }
51 |
52 | uint8_t data[] = "Hello World!";
53 | // Dont put this on the stack:
54 | uint8_t buf[RH_SERIAL_MAX_MESSAGE_LEN];
55 |
56 | void loop()
57 | {
58 | Serial.println("Sending to serial_reliable_datagram_server");
59 |
60 | // Send a message to manager_server
61 | if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
62 | {
63 | // Now wait for a reply from the server
64 | uint8_t len = sizeof(buf);
65 | uint8_t from;
66 | if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
67 | {
68 | Serial.print("got reply from : 0x");
69 | Serial.print(from, HEX);
70 | Serial.print(": ");
71 | Serial.println((char*)buf);
72 | }
73 | else
74 | {
75 | Serial.println("No reply, is serial_reliable_datagram_server running?");
76 | }
77 | }
78 | else
79 | Serial.println("sendtoWait failed");
80 | delay(500);
81 | }
82 |
83 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/serial/serial_reliable_datagram_server/serial_reliable_datagram_server.pde:
--------------------------------------------------------------------------------
1 | // serial_reliable_datagram_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging server
4 | // with the RHReliableDatagram class, using the RH_Serial driver to
5 | // communicate using packets over a serial port (or a radio connected to a
6 | // serial port, such as the 3DR Telemetry radio V1 and others).
7 | // It is designed to work with the other example serial_reliable_datagram_client
8 | // Tested on Arduino Mega and ChipKit Uno32 (normal Arduinos only have one
9 | // serial port and so it not possible to test on them and still have debug
10 | // output)
11 | // Tested with Arduino Mega, Teensy 3.1, Moteino, Arduino Due
12 | // Also works on Linux an OSX. Build and test with:
13 | // tools/simBuild examples/serial/serial_reliable_datagram_server/serial_reliable_datagram_server.pde
14 | // RH_HARDWARESERIAL_DEVICE_NAME=/dev/ttyUSB0 ./serial_reliable_datagram_server
15 |
16 | #include
17 | #include
18 |
19 | #define CLIENT_ADDRESS 1
20 | #define SERVER_ADDRESS 2
21 |
22 | #if (RH_PLATFORM == RH_PLATFORM_UNIX)
23 | #include
24 | // On Unix we connect to a physical serial port
25 | // You can override this with RH_HARDWARESERIAL_DEVICE_NAME environment variable
26 | HardwareSerial hardwareserial("/dev/ttyUSB0");
27 | RH_Serial driver(hardwareserial);
28 |
29 | #else
30 | // On arduino etc, use a predefined local serial port
31 | // eg Serial1 on a Mega
32 | #include
33 | // Singleton instance of the Serial driver, configured
34 | // to use the port Serial1. Caution: on Uno32, Serial1 is on pins 39 (Rx) and
35 | // 40 (Tx)
36 | RH_Serial driver(Serial1);
37 | #endif
38 |
39 | // Class to manage message delivery and receipt, using the driver declared above
40 | RHReliableDatagram manager(driver, SERVER_ADDRESS);
41 |
42 | void setup()
43 | {
44 | Serial.begin(9600);
45 | // Configure the port RH_Serial will use:
46 | driver.serial().begin(9600);
47 | if (!manager.init())
48 | Serial.println("init failed");
49 | }
50 |
51 | uint8_t data[] = "And hello back to you";
52 | // Dont put this on the stack:
53 | uint8_t buf[RH_SERIAL_MAX_MESSAGE_LEN];
54 |
55 | void loop()
56 | {
57 |
58 | // Wait for a message addressed to us from the client
59 | manager.waitAvailable();
60 |
61 | uint8_t len = sizeof(buf);
62 | uint8_t from;
63 | if (manager.recvfromAck(buf, &len, &from))
64 | {
65 | Serial.print("got request from : 0x");
66 | Serial.print(from, HEX);
67 | Serial.print(": ");
68 | Serial.println((char*)buf);
69 |
70 | // Send a reply back to the originator client
71 | if (!manager.sendtoWait(data, sizeof(data), from))
72 | Serial.println("sendtoWait failed");
73 | }
74 | }
75 |
76 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/simulator/simulator_reliable_datagram_client/simulator_reliable_datagram_client.pde:
--------------------------------------------------------------------------------
1 | // simulator_reliable_datagram_client.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging client
4 | // with the RHReliableDatagram class, using the RH_SIMULATOR driver to control a SIMULATOR radio.
5 | // It is designed to work with the other example simulator_reliable_datagram_server
6 | // Tested on Linux
7 | // Build with
8 | // cd whatever/RadioHead
9 | // tools/simBuild examples/simulator/simulator_reliable_datagram_client/simulator_reliable_datagram_client.pde
10 | // Run with ./simulator_reliable_datagram_client
11 | // Make sure you also have the 'Luminiferous Ether' simulator tools/etherSimulator.pl running
12 |
13 | #include
14 | #include
15 |
16 | #define CLIENT_ADDRESS 1
17 | #define SERVER_ADDRESS 2
18 |
19 | // Singleton instance of the radio driver
20 | RH_TCP driver;
21 |
22 | // Class to manage message delivery and receipt, using the driver declared above
23 | RHReliableDatagram manager(driver, CLIENT_ADDRESS);
24 |
25 | void setup()
26 | {
27 | Serial.begin(9600);
28 | if (!manager.init())
29 | Serial.println("init failed");
30 | // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
31 |
32 | // Maybe set this address from teh command line
33 | if (_simulator_argc >= 2)
34 | manager.setThisAddress(atoi(_simulator_argv[1]));
35 | }
36 |
37 | uint8_t data[] = "Hello World!";
38 | // Dont put this on the stack:
39 | uint8_t buf[RH_TCP_MAX_MESSAGE_LEN];
40 |
41 | void loop()
42 | {
43 | Serial.println("Sending to simulator_reliable_datagram_server");
44 |
45 | // Send a message to manager_server
46 | if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
47 | {
48 | // Now wait for a reply from the server
49 | uint8_t len = sizeof(buf);
50 | uint8_t from;
51 | if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
52 | {
53 | Serial.print("got reply from : 0x");
54 | Serial.print(from, HEX);
55 | Serial.print(": ");
56 | Serial.println((char*)buf);
57 | }
58 | else
59 | {
60 | Serial.println("No reply, is simulator_reliable_datagram_server running?");
61 | }
62 | }
63 | else
64 | Serial.println("sendtoWait failed");
65 | delay(500);
66 | }
67 |
68 |
--------------------------------------------------------------------------------
/libraries/RadioHead/examples/simulator/simulator_reliable_datagram_server/simulator_reliable_datagram_server.pde:
--------------------------------------------------------------------------------
1 | // simulator_reliable_datagram_server.pde
2 | // -*- mode: C++ -*-
3 | // Example sketch showing how to create a simple addressed, reliable messaging server
4 | // with the RHReliableDatagram class, using the RH_SIMULATOR driver to control a SIMULATOR radio.
5 | // It is designed to work with the other example simulator_reliable_datagram_client
6 | // Tested on Linux
7 | // Build with
8 | // cd whatever/RadioHead
9 | // tools/simBuild examples/simulator/simulator_reliable_datagram_server/simulator_reliable_datagram_server.pde
10 | // Run with ./simulator_reliable_datagram_server
11 | // Make sure you also have the 'Luminiferous Ether' simulator tools/etherSimulator.pl running
12 |
13 | #include
14 | #include
15 |
16 | #define CLIENT_ADDRESS 1
17 | #define SERVER_ADDRESS 2
18 |
19 | // Singleton instance of the radio driver
20 | RH_TCP driver;
21 |
22 | // Class to manage message delivery and receipt, using the driver declared above
23 | RHReliableDatagram manager(driver, SERVER_ADDRESS);
24 |
25 | void setup()
26 | {
27 | Serial.begin(9600);
28 | if (!manager.init())
29 | Serial.println("init failed");
30 | // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
31 | manager.setRetries(0); // Client will ping us if no ack received
32 | // manager.setTimeout(50);
33 | }
34 |
35 | uint8_t data[] = "And hello back to you";
36 | // Dont put this on the stack:
37 | uint8_t buf[RH_TCP_MAX_MESSAGE_LEN];
38 |
39 | void loop()
40 | {
41 | // Wait for a message addressed to us from the client
42 | manager.waitAvailable();
43 |
44 | // Wait for a message addressed to us from the client
45 | uint8_t len = sizeof(buf);
46 | uint8_t from;
47 | if (manager.recvfromAck(buf, &len, &from))
48 | {
49 | Serial.print("got request from : 0x");
50 | Serial.print(from, HEX);
51 | Serial.print(": ");
52 | Serial.println((char*)buf);
53 |
54 | // Send a reply back to the originator client
55 | if (!manager.sendtoWait(data, sizeof(data), from))
56 | Serial.println("sendtoWait failed");
57 | }
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/libraries/RadioHead/tools/chain.conf:
--------------------------------------------------------------------------------
1 | # chain.conf
2 | # config file for etherSimulator.pl
3 | # Specify the probability of correct delivery between nodea and nodeb (bidirectional)
4 | # probability:nodea:nodeb:probability
5 | # nodea and nodeb are integers 0 to 255
6 | # probability is a float range 0.0 to 1.0
7 |
8 | # In this example, the probability of successful transmission
9 | # between nodes 10 and 2 (and vice versa) is given as 0.5 (ie 50% chance)
10 | probability:10:2:0.5
11 |
--------------------------------------------------------------------------------
/libraries/RadioHead/tools/simBuild:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # simBuild
4 | # build a RadioHead example sketch for running as a simulated process
5 | # on Linux.
6 | #
7 | # usage: simBuild sketchname.pde
8 | # The executable will be saved in the current directory
9 |
10 | INPUT=$1
11 | OUTPUT=$(basename $INPUT ".pde")
12 |
13 | g++ -g -I . -I RHutil -x c++ $INPUT tools/simMain.cpp RHGenericDriver.cpp RHMesh.cpp RHRouter.cpp RHReliableDatagram.cpp RHDatagram.cpp RH_TCP.cpp RH_Serial.cpp RHCRC.cpp RHutil/HardwareSerial.cpp -o $OUTPUT
14 |
--------------------------------------------------------------------------------
/libraries/RadioHead/tools/simMain.cpp:
--------------------------------------------------------------------------------
1 | // main.cpp
2 | // Lets Arduino RadioHead sketches run within a simulator on Linux as a single process
3 | // Copyright (C) 2014 Mike McCauley
4 | // $Id: simMain.cpp,v 1.2 2014/05/09 05:30:03 mikem Exp mikem $
5 |
6 | #include
7 | #if (RH_PLATFORM == RH_PLATFORM_UNIX)
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 | SerialSimulator Serial;
16 |
17 | // Functions we expect to find in the sketch
18 | extern void setup();
19 | extern void loop();
20 |
21 | // Millis at the start of the process
22 | unsigned long start_millis;
23 |
24 | int _simulator_argc;
25 | char** _simulator_argv;
26 |
27 | // Returns milliseconds since beginning of day
28 | unsigned long time_in_millis()
29 | {
30 | struct timeval te;
31 | gettimeofday(&te, NULL); // get current time
32 | unsigned long milliseconds = te.tv_sec*1000LL + te.tv_usec/1000; // caclulate milliseconds
33 | return milliseconds;
34 | }
35 |
36 | // Run the Arduino standard functions in the main loop
37 | int main(int argc, char** argv)
38 | {
39 | // Let simulated program have access to argc and argv
40 | _simulator_argc = argc;
41 | _simulator_argv = argv;
42 | start_millis = time_in_millis();
43 | // Seed the random number generator
44 | srand(getpid() ^ (unsigned) time(NULL)/2);
45 | setup();
46 | while (1)
47 | loop();
48 | }
49 |
50 | void delay(unsigned long ms)
51 | {
52 | usleep(ms * 1000);
53 | }
54 |
55 | // Arduino equivalent, milliseconds since process start
56 | unsigned long millis()
57 | {
58 | return time_in_millis() - start_millis;
59 | }
60 |
61 | long random(long from, long to)
62 | {
63 | return from + (random() % (to - from));
64 | }
65 |
66 | long random(long to)
67 | {
68 | return random(0, to);
69 | }
70 |
71 | #endif
72 |
--------------------------------------------------------------------------------
/libraries/arduino-api/arduinoClasses.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Libelium Comunicaciones Distribuidas S.L.
3 | * http://www.libelium.com
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Lesser General Public License as published by
7 | * the Free Software Foundation, either version 2.1 of the License, or
8 | * (at your option) any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU Lesser General Public License for more details.
14 |
15 | * You should have received a copy of the GNU Lesser General Public License
16 | * along with this program. If not, see .
17 | *
18 | * Version: 1.4
19 | * Design: David Gascón
20 | * Implementation: David Cuartielles, Alberto Bielsa, Yuri Carmona, Ruben Martin
21 | */
22 |
23 | //* Added to use arduino mills and delay functions*//
24 | #include "Arduino.h"
25 |
26 | // strings and math
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | // interrupts and sleep
33 | #include
34 | #include
35 | #include
36 | #include
37 |
38 | #ifdef __cplusplus
39 |
40 | #include "arduinoUtils.h"
41 | #include "arduinoMultiprotocol.h"
42 | #include "arduinoUART.h"
43 |
44 | #endif
45 |
--------------------------------------------------------------------------------
/libraries/arduino-api/arduinoMultiprotocol.h:
--------------------------------------------------------------------------------
1 | /***************************************************
2 | This is a library for the MCP23008 i2c port expander
3 |
4 | These displays use I2C to communicate, 2 pins are required to
5 | interface
6 | Adafruit invests time and resources providing this open source code,
7 | please support Adafruit and open-source hardware by purchasing
8 | products from Adafruit!
9 |
10 | Written by Limor Fried/Ladyada for Adafruit Industries.
11 | BSD license, all text above must be included in any redistribution
12 | ****************************************************/
13 |
14 | #ifndef ARDUINOMULTIPROTOCOL_H
15 | #define ARDUINOMULTIPROTOCOL_H
16 | // Don't forget the Wire library
17 | #ifdef __AVR_ATtiny85__
18 | #include
19 | #else
20 | #include
21 | #endif
22 |
23 | class mp_MCP23008 {
24 | public:
25 |
26 | void begin(uint8_t addr);
27 | void begin(void);
28 |
29 | void pinMode(uint8_t p, uint8_t d);
30 | void digitalWrite(uint8_t p, uint8_t d);
31 | void pullUp(uint8_t p, uint8_t d);
32 | uint8_t digitalRead(uint8_t p);
33 | uint8_t readGPIO(void);
34 | void writeGPIO(uint8_t);
35 |
36 | private:
37 | uint8_t i2caddr;
38 | uint8_t read8(uint8_t addr);
39 | void write8(uint8_t addr, uint8_t data);
40 | };
41 |
42 | #define MCP23008_ADDRESS 0x20
43 |
44 | // registers
45 | #define MCP23008_IODIR 0x00
46 | #define MCP23008_IPOL 0x01
47 | #define MCP23008_GPINTEN 0x02
48 | #define MCP23008_DEFVAL 0x03
49 | #define MCP23008_INTCON 0x04
50 | #define MCP23008_IOCON 0x05
51 | #define MCP23008_GPPU 0x06
52 | #define MCP23008_INTF 0x07
53 | #define MCP23008_INTCAP 0x08
54 | #define MCP23008_GPIO 0x09
55 | #define MCP23008_OLAT 0x0A
56 |
57 |
58 | extern mp_MCP23008 mp;
59 |
60 | #endif
61 |
62 |
63 |
--------------------------------------------------------------------------------
/libraries/arduino-api/keywords.txt:
--------------------------------------------------------------------------------
1 | #############################################
2 | # Syntax Coloring Map For arduino-api
3 | #############################################
4 |
5 | #############################################
6 | # Constants (LITERAL1)
7 | #############################################
8 | Utils KEYWORD1
9 |
10 | #############################################
11 | # Methods and Functions (KEYWORD2)
12 | #############################################
13 | hex2str KEYWORD2
14 | setMuxSocket0 KEYWORD2
15 | setMuxSocket1 KEYWORD2
16 | setMuxUSB KEYWORD2
17 |
18 | multiprotocolBegin KEYWORD2
19 | disableMUX KEYWORD2
20 |
21 | setMUXSocket0 KEYWORD2
22 | setONSocket0 KEYWORD2
23 | setOFFSocket0 KEYWORD2
24 | setCSSocket0 KEYWORD2
25 | unsetCSSocket0 KEYWORD2
26 |
27 | setMUXSocket1 KEYWORD2
28 | setONSocket1 KEYWORD2
29 | setOFFSocket1 KEYWORD2
30 | setCSSocket1 KEYWORD2
31 | unsetCSSocket1 KEYWORD2
32 |
33 | #############################################
34 | # Class (KEYWORD3)
35 | #############################################
36 | arduinoUART KEYWORD3
37 | arduinoUtils KEYWORD3
38 | arduinoClasses KEYWORD3
39 |
40 |
--------------------------------------------------------------------------------
/libraries/arduino-lmic/doc/LMiC-v1.5.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lupyuen/LoRaArduino/f9318ff8f464b020654658e8616bd3790a121743/libraries/arduino-lmic/doc/LMiC-v1.5.pdf
--------------------------------------------------------------------------------
/libraries/arduino-lmic/doc/README.txt:
--------------------------------------------------------------------------------
1 | DISCLAIMER:
2 | Please note that the software is provided AS IS and we cannot
3 | provide support for optimizations, adaptations, integration,
4 | ports to other platforms or device drivers!
5 |
--------------------------------------------------------------------------------
/libraries/arduino-lmic/doc/release-notes.txt:
--------------------------------------------------------------------------------
1 | ==============================================================================
2 | LMIC VERSION 1.4 (17-Mar-2015)
3 | -------------------------------
4 |
5 | - changed API: inverted port indicator flag in LMIC.txrxFlags
6 | (now TXRX_PORT, previously TXRX_NOPORT)
7 |
8 | - fixed offset OFF_CFLIST constant
9 |
10 | - changed CRC-16 algorithm for beacons to CCITT(XMODEM) polynomial
11 |
12 | - fixed radio driver (low data rate optimization for SF11+SF12 only for BW125)
13 |
14 | - fixed timer rollover handling in job queue
15 |
16 | ==============================================================================
17 | LMIC VERSION 1.5 (8-May-2015)
18 | ------------------------------
19 |
20 | - fixed condition in convFreq()
21 |
22 | - fixed freq*100 bug and freq==0 bug for CFList
23 |
24 | - fixed TX scheduling bug
25 |
26 | - better support for GNU compiler toolchain
27 |
28 | ==============================================================================
29 |
--------------------------------------------------------------------------------
/libraries/arduino-lmic/library.properties:
--------------------------------------------------------------------------------
1 | name=IBM LMIC framework
2 | version=1.5.0+arduino-1
3 | author=IBM
4 | maintainer=Matthijs Kooijman
5 | sentence=Arduino port of the LMIC (LoraWAN-in-C, formerly LoraMAC-in-C) framework provided by IBM.
6 | paragraph=Supports SX1272/SX1276 and HopeRF RFM92/RFM95 tranceivers
7 | category=Communication
8 | url=http://www.research.ibm.com/labs/zurich/ics/lrsc/lmic.html
9 | architectures=*
10 |
--------------------------------------------------------------------------------
/libraries/arduino-lmic/src/hal/hal.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015 Matthijs Kooijman
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * This the HAL to run LMIC on top of the Arduino environment.
9 | *******************************************************************************/
10 | #ifndef _hal_hal_h_
11 | #define _hal_hal_h_
12 |
13 | static const int NUM_DIO = 3;
14 |
15 | struct lmic_pinmap {
16 | u1_t nss;
17 | u1_t rxtx;
18 | u1_t rst;
19 | u1_t dio[NUM_DIO];
20 | };
21 |
22 | // Use this for any unused pins.
23 | const u1_t LMIC_UNUSED_PIN = 0xff;
24 |
25 | // Declared here, to be defined an initialized by the application
26 | extern const lmic_pinmap lmic_pins;
27 |
28 | #endif // _hal_hal_h_
29 |
--------------------------------------------------------------------------------
/libraries/arduino-lmic/src/lmic.h:
--------------------------------------------------------------------------------
1 | #ifdef __cplusplus
2 | extern "C"{
3 | #endif
4 |
5 | #include "lmic/lmic.h"
6 |
7 | #ifdef __cplusplus
8 | }
9 | #endif
10 |
--------------------------------------------------------------------------------
/libraries/arduino-lmic/src/lmic/config.h:
--------------------------------------------------------------------------------
1 | #ifndef _lmic_config_h_
2 | #define _lmic_config_h_
3 |
4 | // In the original LMIC code, these config values were defined on the
5 | // gcc commandline. Since Arduino does not allow easily modifying the
6 | // compiler commandline, use this file instead.
7 |
8 | #define CFG_eu868 1
9 | //#define CFG_us915 1
10 | // This is the SX1272/SX1273 radio, which is also used on the HopeRF
11 | // RFM92 boards.
12 | //#define CFG_sx1272_radio 1
13 | // This is the SX1276/SX1277/SX1278/SX1279 radio, which is also used on
14 | // the HopeRF RFM95 boards.
15 | #define CFG_sx1276_radio 1
16 |
17 | // 16 μs per tick
18 | // LMIC requires ticks to be 15.5μs - 100 μs long
19 | #define US_PER_OSTICK_EXPONENT 4
20 | #define US_PER_OSTICK (1 << US_PER_OSTICK_EXPONENT)
21 | #define OSTICKS_PER_SEC (1000000 / US_PER_OSTICK)
22 |
23 | // Enable this to allow using printf() to print to the given serial port
24 | // (or any other Print object). This can be easy for debugging. The
25 | // current implementation only works on AVR, though.
26 | //#define LMIC_PRINTF_TO Serial
27 |
28 | // Any runtime assertion failures are printed to this serial port (or
29 | // any other Print object). If this is unset, any failures just silently
30 | // halt execution.
31 | #define LMIC_FAILURE_TO Serial
32 |
33 | // Uncomment this to disable all code related to joining
34 | //#define DISABLE_JOIN
35 | // Uncomment this to disable all code related to ping
36 | //#define DISABLE_PING
37 | // Uncomment this to disable all code related to beacon tracking.
38 | // Requires ping to be disabled too
39 | //#define DISABLE_BEACONS
40 |
41 | // Uncomment these to disable the corresponding MAC commands.
42 | // Class A
43 | //#define DISABLE_MCMD_DCAP_REQ // duty cycle cap
44 | //#define DISABLE_MCMD_DN2P_SET // 2nd DN window param
45 | //#define DISABLE_MCMD_SNCH_REQ // set new channel
46 | // Class B
47 | //#define DISABLE_MCMD_PING_SET // set ping freq, automatically disabled by DISABLE_PING
48 | //#define DISABLE_MCMD_BCNI_ANS // next beacon start, automatical disabled by DISABLE_BEACON
49 |
50 | // In LoRaWAN, a gateway applies I/Q inversion on TX, and nodes do the
51 | // same on RX. This ensures that gateways can talk to nodes and vice
52 | // versa, but gateways will not hear other gateways and nodes will not
53 | // hear other nodes. By uncommenting this macro, this inversion is
54 | // disabled and this node can hear other nodes. If two nodes both have
55 | // this macro set, they can talk to each other (but they can no longer
56 | // hear gateways). This should probably only be used when debugging
57 | // and/or when talking to the radio directly (e.g. like in the "raw"
58 | // example).
59 | #define DISABLE_INVERT_IQ_ON_RX //// Needed for TP-IoT
60 | #endif // _lmic_config_h_
61 |
--------------------------------------------------------------------------------
/libraries/arduino-lmic/src/lmic/hal.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014-2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * IBM Zurich Research Lab - initial API, implementation and documentation
10 | *******************************************************************************/
11 |
12 | #ifndef _hal_hpp_
13 | #define _hal_hpp_
14 |
15 | #ifdef __cplusplus
16 | extern "C"{
17 | #endif
18 |
19 | /*
20 | * initialize hardware (IO, SPI, TIMER, IRQ).
21 | */
22 | void hal_init (void);
23 |
24 | /*
25 | * drive radio NSS pin (0=low, 1=high).
26 | */
27 | void hal_pin_nss (u1_t val);
28 |
29 | /*
30 | * drive radio RX/TX pins (0=rx, 1=tx).
31 | */
32 | void hal_pin_rxtx (u1_t val);
33 |
34 | /*
35 | * control radio RST pin (0=low, 1=high, 2=floating)
36 | */
37 | void hal_pin_rst (u1_t val);
38 |
39 | /*
40 | * perform 8-bit SPI transaction with radio.
41 | * - write given byte 'outval'
42 | * - read byte and return value
43 | */
44 | u1_t hal_spi (u1_t outval);
45 |
46 | /*
47 | * disable all CPU interrupts.
48 | * - might be invoked nested
49 | * - will be followed by matching call to hal_enableIRQs()
50 | */
51 | void hal_disableIRQs (void);
52 |
53 | /*
54 | * enable CPU interrupts.
55 | */
56 | void hal_enableIRQs (void);
57 |
58 | /*
59 | * put system and CPU in low-power mode, sleep until interrupt.
60 | */
61 | void hal_sleep (void);
62 |
63 | /*
64 | * return 32-bit system time in ticks.
65 | */
66 | u4_t hal_ticks (void);
67 |
68 | /*
69 | * busy-wait until specified timestamp (in ticks) is reached.
70 | */
71 | void hal_waitUntil (u4_t time);
72 |
73 | /*
74 | * check and rewind timer for target time.
75 | * - return 1 if target time is close
76 | * - otherwise rewind timer for target time or full period and return 0
77 | */
78 | u1_t hal_checkTimer (u4_t targettime);
79 |
80 | /*
81 | * perform fatal failure action.
82 | * - called by assertions
83 | * - action could be HALT or reboot
84 | */
85 | void hal_failed (const char *file, u2_t line);
86 |
87 | #ifdef __cplusplus
88 | } // extern "C"
89 | #endif
90 |
91 | #endif // _hal_hpp_
92 |
--------------------------------------------------------------------------------
/libraries/arduino-lmic/src/lmic/oslmic.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2014-2015 IBM Corporation.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * IBM Zurich Research Lab - initial API, implementation and documentation
10 | *******************************************************************************/
11 |
12 | #include "lmic.h"
13 |
14 | // RUNTIME STATE
15 | static struct {
16 | osjob_t* scheduledjobs;
17 | osjob_t* runnablejobs;
18 | } OS;
19 |
20 | void os_init () {
21 | memset(&OS, 0x00, sizeof(OS));
22 | hal_init();
23 | radio_init();
24 | LMIC_init();
25 | }
26 |
27 | ostime_t os_getTime () {
28 | return hal_ticks();
29 | }
30 |
31 | static u1_t unlinkjob (osjob_t** pnext, osjob_t* job) {
32 | for( ; *pnext; pnext = &((*pnext)->next)) {
33 | if(*pnext == job) { // unlink
34 | *pnext = job->next;
35 | return 1;
36 | }
37 | }
38 | return 0;
39 | }
40 |
41 | // clear scheduled job
42 | void os_clearCallback (osjob_t* job) {
43 | hal_disableIRQs();
44 | unlinkjob(&OS.scheduledjobs, job) || unlinkjob(&OS.runnablejobs, job);
45 | hal_enableIRQs();
46 | }
47 |
48 | // schedule immediately runnable job
49 | void os_setCallback (osjob_t* job, osjobcb_t cb) {
50 | osjob_t** pnext;
51 | hal_disableIRQs();
52 | // remove if job was already queued
53 | os_clearCallback(job);
54 | // fill-in job
55 | job->func = cb;
56 | job->next = NULL;
57 | // add to end of run queue
58 | for(pnext=&OS.runnablejobs; *pnext; pnext=&((*pnext)->next));
59 | *pnext = job;
60 | hal_enableIRQs();
61 | }
62 |
63 | // schedule timed job
64 | void os_setTimedCallback (osjob_t* job, ostime_t time, osjobcb_t cb) {
65 | osjob_t** pnext;
66 | hal_disableIRQs();
67 | // remove if job was already queued
68 | os_clearCallback(job);
69 | // fill-in job
70 | job->deadline = time;
71 | job->func = cb;
72 | job->next = NULL;
73 | // insert into schedule
74 | for(pnext=&OS.scheduledjobs; *pnext; pnext=&((*pnext)->next)) {
75 | if((*pnext)->deadline - time > 0) { // (cmp diff, not abs!)
76 | // enqueue before next element and stop
77 | job->next = *pnext;
78 | break;
79 | }
80 | }
81 | *pnext = job;
82 | hal_enableIRQs();
83 | }
84 |
85 | // execute jobs from timer and from run queue
86 | void os_runloop () {
87 | while(1) {
88 | os_runloop_once();
89 | }
90 | }
91 |
92 | void os_runloop_once() {
93 | osjob_t* j = NULL;
94 | hal_disableIRQs();
95 | // check for runnable jobs
96 | if(OS.runnablejobs) {
97 | j = OS.runnablejobs;
98 | OS.runnablejobs = j->next;
99 | } else if(OS.scheduledjobs && hal_checkTimer(OS.scheduledjobs->deadline)) { // check for expired timed jobs
100 | j = OS.scheduledjobs;
101 | OS.scheduledjobs = j->next;
102 | } else { // nothing pending
103 | hal_sleep(); // wake by irq (timer already restarted)
104 | }
105 | hal_enableIRQs();
106 | if(j) { // run job callback
107 | j->func(j);
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/libraries/arduinoLoRa/examples/SX_00_CONFIG_LoRa/SX_00_CONFIG_LoRa.pde:
--------------------------------------------------------------------------------
1 | /*
2 | * LoRa 868 / 915MHz SX1272 LoRa module
3 | *
4 | * Copyright (C) Libelium Comunicaciones Distribuidas S.L.
5 | * http://www.libelium.com
6 | *
7 | * This program is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program. If not, see http://www.gnu.org/licenses/.
19 | *
20 | * Version: 1.2
21 | * Design: David Gascón
22 | * Implementation: Covadonga Albiñana, Victor Boria, Ruben Martin
23 | */
24 |
25 | #include
26 |
27 | // Cooking API libraries
28 | #include
29 |
30 | // Include the SX1272 and SPI library:
31 | #include "arduinoLoRa.h"
32 | #include
33 |
34 | int e;
35 |
36 | void setup()
37 | {
38 | // Open serial communications and wait for port to open:
39 | Serial.begin(9600);
40 |
41 | // Print a start message
42 | Serial.println(F("SX1272 module configuration in Arduino"));
43 |
44 | // Power ON the module
45 | // Only allowed in SOCKET 1 (3,3V SPI interface)
46 | e = sx1272.ON();
47 | Serial.print(F("Setting power ON: state "));
48 | Serial.println(e, DEC);
49 |
50 | // Set transmission mode and print the result
51 | e |= sx1272.setMode(4);
52 | Serial.print(F("Setting Mode: state "));
53 | Serial.println(e, DEC);
54 |
55 | // Set header
56 | e |= sx1272.setHeaderON();
57 | Serial.print(F("Setting Header ON: state "));
58 | Serial.println(e, DEC);
59 |
60 | // Select frequency channel
61 | e |= sx1272.setChannel(CH_10_868);
62 | Serial.print(F("Setting Channel: state "));
63 | Serial.println(e, DEC);
64 |
65 | // Set CRC
66 | e |= sx1272.setCRC_ON();
67 | Serial.print(F("Setting CRC ON: state "));
68 | Serial.println(e, DEC);
69 |
70 | // Select output power (Max, High or Low)
71 | e |= sx1272.setPower('H');
72 | Serial.print(F("Setting Power: state "));
73 | Serial.println(e, DEC);
74 |
75 | // Set the node address and print the result
76 | e |= sx1272.setNodeAddress(3);
77 | Serial.print(F("Setting node address: state "));
78 | Serial.println(e, DEC);
79 |
80 | // Print a success message
81 | if (e == 0)
82 | Serial.println(F("SX1272 successfully configured"));
83 | else
84 | Serial.println(F("SX1272 initialization failed"));
85 | }
86 |
87 | void loop(void)
88 | {
89 | }
90 |
--------------------------------------------------------------------------------
/libraries/arduinoLoRa/examples/SX_01a_TX_LoRa/SX_01a_TX_LoRa.pde:
--------------------------------------------------------------------------------
1 | /*
2 | * LoRa 868 / 915MHz SX1272 LoRa module
3 | *
4 | * Copyright (C) Libelium Comunicaciones Distribuidas S.L.
5 | * http://www.libelium.com
6 | *
7 | * This program is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program. If not, see http://www.gnu.org/licenses/.
19 | *
20 | * Version: 1.2
21 | * Design: David Gascón
22 | * Implementation: Covadonga Albiñana, Victor Boria, Ruben Martin
23 | */
24 |
25 | #include
26 |
27 | // Cooking API libraries
28 | #include
29 |
30 | // Include the SX1272 and SPI library:
31 | #include "arduinoLoRa.h"
32 | #include
33 |
34 | int e;
35 |
36 | char message1 [] = "Packet 1, wanting to see if received packet is the same as sent packet";
37 | char message2 [] = "Packet 2, broadcast test";
38 |
39 | void setup()
40 | {
41 | // Open serial communications and wait for port to open:
42 | Serial.begin(9600);
43 |
44 | // Print a start message
45 | Serial.println(F("SX1272 module and Arduino: send packets without ACK"));
46 |
47 | // Power ON the module
48 | e = sx1272.ON();
49 | Serial.print(F("Setting power ON: state "));
50 | Serial.println(e, DEC);
51 |
52 | // Set transmission mode and print the result
53 | e |= sx1272.setMode(4);
54 | Serial.print(F("Setting Mode: state "));
55 | Serial.println(e, DEC);
56 |
57 | // Set header
58 | e |= sx1272.setHeaderON();
59 | Serial.print(F("Setting Header ON: state "));
60 | Serial.println(e, DEC);
61 |
62 | // Select frequency channel
63 | e |= sx1272.setChannel(CH_10_868);
64 | Serial.print(F("Setting Channel: state "));
65 | Serial.println(e, DEC);
66 |
67 | // Set CRC
68 | e |= sx1272.setCRC_ON();
69 | Serial.print(F("Setting CRC ON: state "));
70 | Serial.println(e, DEC);
71 |
72 | // Select output power (Max, High or Low)
73 | e |= sx1272.setPower('H');
74 | Serial.print(F("Setting Power: state "));
75 | Serial.println(e, DEC);
76 |
77 | // Set the node address and print the result
78 | e |= sx1272.setNodeAddress(3);
79 | Serial.print(F("Setting node address: state "));
80 | Serial.println(e, DEC);
81 |
82 | // Print a success message
83 | if (e == 0)
84 | Serial.println(F("SX1272 successfully configured"));
85 | else
86 | Serial.println(F("SX1272 initialization failed"));
87 | }
88 |
89 | void loop(void)
90 | {
91 | // Send message1 and print the result
92 | e = sx1272.sendPacketTimeout(8, message1);
93 | Serial.print(F("Packet sent, state "));
94 | Serial.println(e, DEC);
95 |
96 | delay(4000);
97 |
98 | // Send message2 broadcast and print the result
99 | e = sx1272.sendPacketTimeout(0, message2);
100 | Serial.print(F("Packet sent, state "));
101 | Serial.println(e, DEC);
102 |
103 | delay(4000);
104 | }
105 |
106 |
--------------------------------------------------------------------------------
/libraries/arduinoLoRa/examples/SX_01b_RX_LoRa/SX_01b_RX_LoRa.pde:
--------------------------------------------------------------------------------
1 | /*
2 | * LoRa 868 / 915MHz SX1272 LoRa module
3 | *
4 | * Copyright (C) Libelium Comunicaciones Distribuidas S.L.
5 | * http://www.libelium.com
6 | *
7 | * This program is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program. If not, see http://www.gnu.org/licenses/.
19 | *
20 | * Version: 1.2
21 | * Design: David Gascón
22 | * Implementation: Covadonga Albiñana, Victor Boria, Ruben Martin
23 | */
24 |
25 | #include
26 |
27 | // Cooking API libraries
28 | #include
29 |
30 | // Include the SX1272 and SPI library:
31 | #include "arduinoLoRa.h"
32 | #include
33 |
34 | int e;
35 | char my_packet[100];
36 |
37 | void setup()
38 | {
39 | // Open serial communications and wait for port to open:
40 | Serial.begin(9600);
41 |
42 | // Print a start message
43 | Serial.println(F("SX1272 module and Arduino: receive packets without ACK"));
44 |
45 | // Power ON the module
46 | e = sx1272.ON();
47 | Serial.print(F("Setting power ON: state "));
48 | Serial.println(e, DEC);
49 |
50 | // Set transmission mode and print the result
51 | e |= sx1272.setMode(4);
52 | Serial.print(F("Setting Mode: state "));
53 | Serial.println(e, DEC);
54 |
55 | // Set header
56 | e |= sx1272.setHeaderON();
57 | Serial.print(F("Setting Header ON: state "));
58 | Serial.println(e, DEC);
59 |
60 | // Select frequency channel
61 | e |= sx1272.setChannel(CH_10_868);
62 | Serial.print(F("Setting Channel: state "));
63 | Serial.println(e, DEC);
64 |
65 | // Set CRC
66 | e |= sx1272.setCRC_ON();
67 | Serial.print(F("Setting CRC ON: state "));
68 | Serial.println(e, DEC);
69 |
70 | // Select output power (Max, High or Low)
71 | e |= sx1272.setPower('H');
72 | Serial.print(F("Setting Power: state "));
73 | Serial.println(e, DEC);
74 |
75 | // Set the node address and print the result
76 | e |= sx1272.setNodeAddress(8);
77 | Serial.print(F("Setting node address: state "));
78 | Serial.println(e, DEC);
79 |
80 | // Print a success message
81 | if (e == 0)
82 | Serial.println(F("SX1272 successfully configured"));
83 | else
84 | Serial.println(F("SX1272 initialization failed"));
85 | }
86 |
87 | void loop(void)
88 | {
89 | // Receive message
90 | e = sx1272.receivePacketTimeout(10000);
91 | if ( e == 0 )
92 | {
93 | Serial.print(F("Receive packet, state "));
94 | Serial.println(e, DEC);
95 |
96 | for (unsigned int i = 0; i < sx1272.packet_received.length; i++)
97 | {
98 | my_packet[i] = (char)sx1272.packet_received.data[i];
99 | }
100 | Serial.print(F("Message: "));
101 | Serial.println(my_packet);
102 | }
103 | else {
104 | Serial.print(F("Receive packet, state "));
105 | Serial.println(e, DEC);
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/libraries/arduinoLoRa/keywords.txt:
--------------------------------------------------------------------------------
1 | #######################################
2 | # Syntax Coloring Map For LoRa
3 | #######################################
4 |
5 | #######################################
6 | # Class (KEYWORD3)
7 | #######################################
8 |
9 | LoRa KEYWORD3
10 | SX12712 KEYWORD3
11 |
12 | #######################################
13 | # Methods and Functions (KEYWORD2)
14 | #######################################
15 |
16 | arduinoLoRa KEYWORD2
17 | arduinoClasses KEYWORD2
18 | arduinoUART KEYWORD2
19 | arduinoUtils KEYWORD2
20 |
21 | _bandwidth KEYWORD2
22 | _codingRate KEYWORD2
23 | _spreadingFactor KEYWORD2
24 | _channel KEYWORD2
25 | _power KEYWORD2
26 | _SNR KEYWORD2
27 | _RSSI KEYWORD2
28 | _RSSIpacket KEYWORD2
29 | _preamblelength KEYWORD2
30 | _payloadlength KEYWORD2
31 | _nodeAddress KEYWORD2
32 | _header KEYWORD2
33 | _hreceived KEYWORD2
34 | _CRC KEYWORD2
35 | _destination KEYWORD2
36 | _packetNumber KEYWORD2
37 | _reception KEYWORD2
38 | _retries KEYWORD2
39 | _maxRetries KEYWORD2
40 | _maxCurrent KEYWORD2
41 | _modem KEYWORD2
42 | _packet_sent KEYWORD2
43 | _packet_received KEYWORD2
44 | _temp KEYWORD2
45 | _sendTime KEYWORD2
46 | ACK KEYWORD2
47 | ON KEYWORD2
48 | OFF KEYWORD2
49 | readRegister KEYWORD2
50 | writeRegister KEYWORD2
51 | clearFlags KEYWORD2
52 | setLORA KEYWORD2
53 | setFSK KEYWORD2
54 | getMode KEYWORD2
55 | setMode KEYWORD2
56 | getHeader KEYWORD2
57 | setHeaderON KEYWORD2
58 | setHeaderOFF KEYWORD2
59 | getCRC KEYWORD2
60 | setCRC_ON KEYWORD2
61 | setCRC_OFF KEYWORD2
62 | isSF KEYWORD2
63 | getSF KEYWORD2
64 | isBW KEYWORD2
65 | setBW KEYWORD2
66 | isCR KEYWORD2
67 | getCR KEYWORD2
68 | setCR KEYWORD2
69 | isChannel KEYWORD2
70 | getChannel KEYWORD2
71 | setChannel KEYWORD2
72 | getPower KEYWORD2
73 | setPower KEYWORD2
74 | setPowerNum KEYWORD2
75 | getPreambleLength KEYWORD2
76 | setPreamblelenght KEYWORD2
77 | getPayloadLength KEYWORD2
78 | setPacketLength KEYWORD2
79 | getNodeAddress KEYWORD2
80 | setNodeAddress KEYWORD2
81 | getSNR KEYWORD2
82 | getRSSI KEYWORD2
83 | getRSSIpacket KEYWORD2
84 | setRetries KEYWORD2
85 | getMaxCurrent KEYWORD2
86 | setMaxCurrent KEYWORD2
87 | getRegs KEYWORD2
88 | truncPayLoad KEYWORD2
89 | setACK KEYWORD2
90 | receive KEYWORD2
91 | receivePacketMAXTimeout KEYWORD2
92 | receivePacketTimeout KEYWORD2
93 | receivePacketMAXTimeoutACK KEYWORD2
94 | receivePacketTimeoutACK KEYWORD2
95 | receiveAll KEYWORD2
96 | availableData KEYWORD2
97 | setPacket KEYWORD2
98 | getPacketMAXTimeout KEYWORD2
99 | getPacket KEYWORD2
100 | sendWithMAXTimeout KEYWORD2
101 | sendWithTimeout KEYWORD2
102 |
103 | #######################################
104 | # Constants (LITERAL1)
105 | #######################################
106 |
107 | LORA_ANSWER_OK LITERAL1
108 | LORA_ANSWER_ERROR LITERAL1
109 | LORA_NO_ANSWER LITERAL1
110 |
--------------------------------------------------------------------------------
/libraries/readme.txt:
--------------------------------------------------------------------------------
1 | For information on installing libraries, see: http://www.arduino.cc/en/Guide/Libraries
2 |
--------------------------------------------------------------------------------