HM10 Ibeacon scanning

Hello guys,
I am trying to scan ibeacons using HM10 bluetooth module and arduino. When i pass "AT+DISI?" command from the serial monitor, the module responds positively and scans the BLEs around me, everytime I type in that command. However when I try to enter the command through a code using looping for continuous scanning, it scans only twice or thrice and then stops scanning. I have added my code here too. Please help.

#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10,11);

char disi_result[400];
int top=0;
int d1=0;
int i=0;
struct devices {
unsigned int major=0;
unsigned int minor=0;
unsigned int power=0;
int rssi=0;

};
devices device[4];

void setup()
{

Serial.begin(38400);
BTSerial.begin(9600);
start_at();
}
void loop(){
if(d1==0)
{
Serial.println("Scanning started");
BTSerial.write("AT+DISI?");
d1=1;

}
if(d1==1){

if (BTSerial.available() ){
while(BTSerial.available()){
disi_result*=char(BTSerial.read());*

  • i++;*

  • }*

  • }*

  • int j;*

  • String str="";*

  • for(j=i-8;j<=i;j++)*

  • {*

  • str=str+disi_result[j];*

  • }*

  • if(str=="OK+DISCE" ){*

  • d1=2;*

  • }*

  • }*

  • if(d1==2)*

  • {*

  • int j=0;*

  • for(j=0;j<=i;j++)*

  • {*

  • Serial.print( disi_result[j]);*

  • }*

  • i=0;*
    d1=0;

  • delay(1000);*

  • }*
    }
    void start_at(){

  • String c="";*

  • do{*

  • BTSerial.print("AT");*

  • delay(500);*

  • if (BTSerial.available())*

  • {*

  • while(BTSerial.available())*

  • {*

  • c=c+char(BTSerial.read());*

  • }*

  • }*

  • }while(c!="OK");*
    }

I also have a problem. I tried your code but it reported a char to char error

You were trying to put single char in the place of a char array. The fix is simpe:

disi_result*=char(BTSerial.read());*

diande:
You were trying to put single char in the place of a char array. The fix is simpe:

disi_result*=char(BTSerial.read());*
[/quote]...and that's why you should use code tags.