Original library sources.
This commit is contained in:
30
examples/recv/recv.ino
Normal file
30
examples/recv/recv.ino
Normal file
@ -0,0 +1,30 @@
|
||||
#include <SPI.h>
|
||||
#include <RF24.h>
|
||||
#include <BTLE.h>
|
||||
|
||||
RF24 radio(9,10);
|
||||
|
||||
BTLE btle(&radio);
|
||||
|
||||
void setup() {
|
||||
|
||||
Serial.begin(9600);
|
||||
while (!Serial) { }
|
||||
Serial.println("BTLE advertisement receiver");
|
||||
|
||||
btle.begin("");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
Serial.print("Listening... ");
|
||||
|
||||
if (btle.listen()) {
|
||||
Serial.print("Got payload: ");
|
||||
for (uint8_t i = 0; i < (btle.buffer.pl_size)-6; i++) { Serial.print(btle.buffer.payload[i],HEX); Serial.print(" "); }
|
||||
}
|
||||
|
||||
Serial.println("done.");
|
||||
btle.hopChannel();
|
||||
}
|
||||
|
23
examples/send/send.ino
Normal file
23
examples/send/send.ino
Normal file
@ -0,0 +1,23 @@
|
||||
#include <SPI.h>
|
||||
#include <RF24.h>
|
||||
#include <BTLE.h>
|
||||
|
||||
RF24 radio(9,10);
|
||||
|
||||
BTLE btle(&radio);
|
||||
|
||||
void setup() {
|
||||
|
||||
Serial.begin(9600);
|
||||
while (!Serial) { }
|
||||
Serial.println("BTLE advertisement sender");
|
||||
|
||||
btle.begin("foobar");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
btle.advertise(0,0);
|
||||
btle.hopChannel();
|
||||
Serial.print(".");
|
||||
}
|
||||
|
46
examples/temperature/temperature.ino
Normal file
46
examples/temperature/temperature.ino
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Emulates a nRF8001 temperature beacon;
|
||||
* reads temperature from a DHT11 and sends it via BTLE.
|
||||
* Compatible with Nordic Semiconductor apps such as
|
||||
* nRF Master Control Panel or nRF Temp 2.0.
|
||||
*/
|
||||
|
||||
#include <BTLE.h>
|
||||
|
||||
#include <SPI.h>
|
||||
#include <RF24.h>
|
||||
#include <dht.h>
|
||||
|
||||
RF24 radio(9,10);
|
||||
BTLE btle(&radio);
|
||||
|
||||
dht DHT;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(57600);
|
||||
while (!Serial) { }
|
||||
Serial.println("BTLE temperature sender");
|
||||
Serial.end();
|
||||
|
||||
// 8 chars max
|
||||
btle.begin("SimoTemp");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
DHT.read11(A0);
|
||||
|
||||
nrf_service_data buf;
|
||||
buf.service_uuid = NRF_TEMPERATURE_SERVICE_UUID;
|
||||
buf.value = BTLE::to_nRF_Float(DHT.temperature);
|
||||
|
||||
if(!btle.advertise(0x16, &buf, sizeof(buf))) {
|
||||
Serial.begin(57600);
|
||||
Serial.println("BTLE advertisement failure");
|
||||
Serial.end();
|
||||
}
|
||||
btle.hopChannel();
|
||||
|
||||
delay(1000);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user