blob: c5113f91510880bced6666ba9d6c275e7fda6c7d (
plain)
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
|
/*
Adaptics BT platform
11/11/11
persistent connection with a BT serial module
this WAS working well with precompiled library and setting the baudrate artificially to 76800 (because F_CPU not working)
although println(unsigned long) was causing an error.
what's changed :-(
15/11/11
using 38400 and non precomiled- sucessfully enters inquiry
can only seem to connect straight after pairing, which is annoying
when connected the BT module sends some fragments of commands ie.e "+STOAU\0xf4"
it only seems to stay connected for 1/2 second. Voltage issue?
yep- it works on 0v-3v but ont on -3v-0v
-3v seems to kind of work at 9600bps - received junk
at 19200 it stays on for a few seconds but received junk
*/
#include "adapticsBT.h"
void setupBlueTooth(){
pinMode(BTC,INPUT); //connection indicator
Serial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
Serial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
Serial.print("\r\n+STNA=AdapticsElectic\r\n"); //set the bluetooth name
Serial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
Serial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
//necessary?
Serial.print("\r\n +STPIN=0000\r\n"); //"\r\n+DLPIN\r\n");
Serial.print("\r\n+LOSSRECONN=0\r\n"); //setting this to 1 seems to stop it working
advertise();
}
void advertise(){
delay(2000); // This delay is required - its really 2 seconds
Serial.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable
delay(2000); // This delay is required.
Serial.flush();
}
|