-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathbtclass_h.pde
58 lines (52 loc) · 1.56 KB
/
btclass_h.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*****************************************************************************
*
* Copyright (C) 2010 Circuits At Home, LTD. All rights reserved.
*
* This software may be distributed and modified under the terms of the GNU
* General Public License version 2 (GPL) as published by the Free Software
* Foundation and appearing in the file GPL.TXT included in the packaging of
* this file. Please note that GPL Section 2[b] requires that all works based
* on this software must also be made publicly available under the terms of
* the GPL ("Copyleft").
*
* Contact information:
* Circuits At Home Web site: http://www.circuitsathome.com
* e-mail: [email protected]
*****************************************************************************/
#include "serial.h"
#include "bt_h.h"
#include "Max3421e.h"
#include "Usb.h"
TBT BT;
uint8_t state;
extern const int8_t uname[], welcome[];
void setup(void){
Serial.begin(115200);
welcome_banner();
state = 0;
}
void loop(void){
uint8_t len, i;
int8_t str[48];
if(state == 0){
SerialHandler();
} else {
if((state == 1) && (BT.GetState() == BT_STATE_CONNECTED)){
Serial.println("Connected");
state = 2;
}
SerialHandler();
len = BT.Task(str);
if(len > 0){
for(i = 0; i < len; i++) {
// Arduino 1.0 compatibility
#if defined(ARDUINO) && ARDUINO >= 100
Serial.write(str[i]);
#else
Serial.print(str[i], BYTE);
#endif
}
Serial.print("\r\n");
}
}
}