OK, it's been a while but I have an update. I've got the Arduino Uno R3 with a Seeeduino BT shield able to scan for BT devices; which is what I wanted to start with.
/* */
#include <SoftwareSerial.h> //Software Serial Port
#define RxD 5
#define TxD 6
#define DEBUG_ENABLED 1
char recvChar;
String recvBuf;
String recvAddr;
String recvInq;
SoftwareSerial blueToothSerial(RxD,TxD);
void setup()
{
Serial.begin(9600);
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
setupBlueToothConnection();
//wait 1 sec and flush the serial buffer
delay(1000);
Serial.flush();
blueToothSerial.flush();
Serial.println(" ");
Serial.println("restarted....");
Serial.println("Starting BTScan....");
}
void loop()
{
btScan();
}
void setupBlueToothConnection()
{
blueToothSerial.begin(38400); //Set Bluetooth to 38400
blueToothSerial.print("\r\n+STWMOD=1\r\n");//set bluetooth to master mode
blueToothSerial.print("\r\n+STNA=PeddleComp\r\n");//set bluetooth name as "PeddleComp"
blueToothSerial.print("\r\n+STAUTO=0\r\n");// no Auto-connection
delay(2000); // This delay is required.
blueToothSerial.flush();
blueToothSerial.print("\r\n+INQ=1\r\n");//make the master inquire
delay(2000); // This delay is required.
}
void btScan() //scan for devices
{
if (blueToothSerial.available())
{
recvChar = blueToothSerial.read();
recvBuf += recvChar;
if (((recvChar > 47) && (recvChar < 58)) || ((recvChar > 64) && (recvChar < 71))) // get numbers and A-F only
{
recvAddr += recvChar;
if(recvAddr.length()==12)
{
Serial.println(recvAddr);
recvAddr = "";
blueToothSerial.flush();
}
}
}
}
If anyone knows a better way to trap the numbers and A-F only; please let me know. BASIC was my first language and that was on a 4K Trash-80 Model I.