Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- MwadimeMakokha
- Date:
- 2019-11-13
- Revision:
- 0:3d4b4cf5f0e3
- Child:
- 1:940070f92554
File content as of revision 0:3d4b4cf5f0e3:
#include "global.h"
char modem_response[255];
Timer t;
 int main(){
     DEBUG_PRINTLN("PROGRAM START");
     MODEM_PRINTLN("AT");
      get_response(1000,false);
     if((strcmp(modem_response,"OK") != 0)){
         DEBUG_PRINTLN("%s",modem_response);
         return 0;
    }
    DEBUG_PRINTLN("%s",modem_response);
    MODEM_PRINTLN("AT+BTHOST?");
    get_response(1000,false);
    DEBUG_PRINTLN("%s",modem_response);
    MODEM_PRINTLN("AT+BTSTATUS?");
    get_response(1000,false);
    DEBUG_PRINTLN("%s",modem_response);
    MODEM_PRINTLN("AT+BTPOWER=1");
    get_response(1000,false);
    DEBUG_PRINTLN("%s",modem_response);
    MODEM_PRINTLN("AT+BTSCAN=1,10");
    get_response(10000,true);
    DEBUG_PRINTLN("%s",modem_response);
 while(1){
    
 } 
    
}
void get_response(uint16_t timeout,bool is_multiline){
    int arr_index=0;
    while(timeout){
    if(arr_index >= 254) break;
    while(modemSerial.readable()){
    char c = modemSerial.getc();
    if(c == '\r') continue;
    if(c=='\n' && arr_index==0){
    continue;
    }
    if(c=='\n' && !is_multiline){
    break;    
    }
    modem_response[arr_index] = c;
    arr_index++;
    }
    timeout--;
    wait_ms(1);
    }
    modem_response[arr_index] = 0;
    
}