search for bluetooth devices

Hello,

I want to find out what devices are around me and say hello to each person around.

[SOLVED] Before saying hello, I do not understand what the error means:
request for member 'indexOf' in 'bt', which is of non-class type 'int'

string bt=0;                                // list of bt devices
void setup() {
    Serial.begin(9600);               // initializes serial communication at 9600 bits per second
    Serial.print("AT+JDDS=0");     // search for devices
}

void loop() {
    if(Serial.available() > 0){     
      bt = Serial.read();
      if (bt.indexOf("device1") > 0){
          "hello 1"}
}

EDIT 1: After solving the "int" problem and thinking I need to use AT mode, the question becomes:
How do I use AT mode to tell arduino what devices are nearby?

After I resolve this part I will play a sound saying Hello to each person.
The problem, I guess, is that "Serial.print("AT+JDDS=0");" will not do a search.

Thanks,
Dan.

The int data type doesn't have an indexOf method.

the String class has an indexOf method. Based on the code, it should be

String bt;
// not int bt;

blh64:
the String class has an indexOf method. Based on the code, it should be

String bt;

// not int bt;

So I think it was funny to see I am trying to send an AT command to the HC05 bt module like this.
Is it only possible in AT mode?

Djmarian:
Is it only possible in AT mode?

How else would the module know you're trying to send it a command to process, rather than data to transmit?

wvmarle:
How else would the module know you're trying to send it a command to process, rather than data to transmit?

So is it possible to do what I want with HC05?

Answer based on not knowing what you actually want to do: maybe.

Probably. See: 28. Inquiry Bluetooth Device
https://www.itead.cc/wiki/Serial_Port_Bluetooth_Module_(Master/Slave)_:_HC-05#28._Inquiry_Bluetooth_Device

wvmarle:
Answer based on not knowing what you actually want to do: maybe.

I edited the question so I think my problem is I don't know how to do a search in AT mode.

johnwasser:
Probably. See: 28. Inquiry Bluetooth Device

Thank you.

johnwasser:
Probably. See: 28. Inquiry Bluetooth Device

I've been messing around and it seems that "RoboIndia Code for HC-05 with AT Mode" no longer works. I get for

AT+JDDS=0 -> ERROR:(0),
AT+INQ -> ERROR:(16),
AT+NAME -> ERROR:(4)
and AT+PSWD= -> ERROR:(F)

The first arduino code I ever managed to get working still works with this HC05, I can command arduino by phone.

I was trying to do something like so for the second project I ever tried to get working:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(0,1); //RX,TX
int flag=0;                        // makes sure that the serial only prints once the state
String bt;                         // list of bt devices
void setup() {
  pinMode(5, OUTPUT);              // sets the pin as output
  digitalWrite(5, LOW);
  Serial.begin(9600);
  mySerial.begin(9600);
  delay(1000);
//  long b=mySerial.read(); some comands from an example
//  mySerial.println("AT+CIPMUX=1");
//  b=mySerial.read();
//  Serial.write(bt);
//  delay(100);
//  b="";
}
void loop() {
// search for devices, I don't know which is better from the two next lines
mySerial.println("AT+JDDS=0");
mySerial.write("AT+INQ/r/n");
    if(Serial.available() > 0){     
      byte bt = mySerial.read();           
      flag=0;
if (bt.indexOf("device1") > 0){
        digitalWrite(5, HIGH);
       }
}
}//end void