BayEOS-Arduino  1.8.0_0.0.4
BayBluetooth.cpp
1 #include "BayBluetooth.h"
2 BayBluetooth::BayBluetooth(HardwareSerial &serial):BaySerial(serial){
3 }
4 
5 
7  _serial->print("\r\n+STPIN=0000\r\n"); // Set pin to 0000
8  delay(2000); // This delay is required.
9  _serial->print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable
10  delay(2000); // This delay is required.
11  flush();
12 }
13 
14 void BayBluetooth::begin(long baud,const char* name){
15  BaySerial::begin(baud);
16  _serial->print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
17  _serial->print("\r\n+STNA=");
18  _serial->print(name);
19  _serial->print("\r\n"); //set the bluetooth name
20  _serial->print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
21  _serial->print("\r\n+STAUTO=1\r\n"); // Auto-connection should be forbidden here
22  _serial->flush();
23 }
24 
25 void BayBluetooth::begin(long baud,int eeprom_offset,uint8_t start_byte){
26  BaySerial::begin(baud);
27  _serial->print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
28  _serial->print("\r\n+STNA=");
29  if(EEPROM.read(eeprom_offset)==start_byte){
30  uint8_t i=1;
31  while(char n=EEPROM.read(eeprom_offset+i)){
32  _serial->print(n);
33  i++;
34  }
35  } else _serial->print("NA");
36  _serial->print("\r\n"); //set the bluetooth name
37  _serial->print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
38  _serial->print("\r\n+STAUTO=1\r\n"); // Auto-connection should be forbidden here
39  _serial->flush();
40 }
void inquirable(void)
Definition: BayBluetooth.cpp:6
void begin(long baud, const char *name)
BayBluetooth(HardwareSerial &serial=Serial)
Definition: BayBluetooth.cpp:2