-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUWBluetooth.cpp
53 lines (41 loc) · 1.18 KB
/
UWBluetooth.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* TODO: Add summary info
*/
#include <SoftwareSerial.h>
#include "BluefruitConfig.h"
#include "Adafruit_BluefruitLE_UART.h"
SoftwareSerial bluefruitSS = SoftwareSerial(BLUEFRUIT_SWUART_TXD_PIN,
BLUEFRUIT_SWUART_RXD_PIN);
Adafruit_BluefruitLE_UART ble(bluefruitSS,
BLUEFRUIT_UART_MODE_PIN,
BLUEFRUIT_UART_CTS_PIN,
BLUEFRUIT_UART_RTS_PIN);
UWBluetooth::UWBluetooth {
}
void error(const __FlashStringHelper*err) {
Serial.println(err);
while (1);
}
void UWBluetooth::begin(String name) {
bool didBegin, didReset;
didBegin = ble.begin(VERBOSE_MODE);
if (!didBegin) {
error(F("Couldn't find Bluefruit, make sure it's in CoMmanD mode & check wiring?"));
}
if (FACTORYRESET_ENABLE) {
didReset = ble.factoryReset();
if (!didReset){
error(F("Couldn't factory reset"));
}
}
ble.echo(false);
ble.info();
ble.reset();
}
bool UWBluetooth::print(String message) {
ble.sendCommandCheckOK(F(message));
}
bool UWBluetooth::println(String message) {
String withNewline = message + '\n';
ble.sendCommandCheckOK(F(withNewline));
}