Nikolas Goldin original creater of this. Added some of my own notes and also a few additional commands

Dependencies:   btbee m3pi_ng mbed

Fork of configure_btbee by Nikolas Goldin

main.cpp

Committer:
ngoldin
Date:
2013-05-16
Revision:
1:af0aa8d6e586
Parent:
0:e674a8b2b330
Child:
2:d0adbf94c4c0

File content as of revision 1:af0aa8d6e586:

#include "mbed.h"
#include "m3pi_ng.h"
#include "btbee.h"

m3pi m3pi;
btbee btbee;

DigitalOut mbed_led[] = {(LED1), (LED2),(LED3), (LED4)};
DigitalOut m3pi_led[] = {(p13), (p14), (p15), (p16), (p17), (p18), (p19), (p20)};

int main ()
{
// initialization stuff ////////////////////////////////////////////////////////////////////////////////////////////////////
    for (int i = 0; i <4; i++) {
        mbed_led[i] = 0;
    }
    for (int i = 0; i <8; i++) {
        m3pi_led[i] = 0;
    }
    btbee.at_baud();
// end initialization stuff ////////////////////////////////////////////////////////////////////////////////////////////////
    m3pi.locate(0,1);
    m3pi.printf("ATSWITCH");
    m3pi.locate(0,0);
    m3pi.printf("RIGHT???");
    wait(0.1);
    m3pi_led[0]=1;

//btbee.printf("at\r\n"); // test command, returns "OK\r\n"
//btbee.printf("at+uart=9600,0,0\r\n"); //default values, returns "OK\r\n"
//btbee.printf("at+uart=115200,0,0\r\n"); //changing the baud rate, returns "OK\r\n"
    btbee.printf("at+uart?\r\n"); //asking for the set parameters, replies "+UART:baud,stop,parity\r\n"

    m3pi_led[1]=1;

    while (!btbee.readable()) { //wait for reply
        mbed_led[0]=!mbed_led[0];
        wait(0.1);
    }

    char reply_array[30];
    int reply_length=0;
    
    m3pi_led[2]=1;
    btbee.read_all(reply_array, 30, &reply_length);
    m3pi_led[3]=1;

    m3pi.locate(0,0);
    m3pi.cls();
    if (reply_length<9) {
        m3pi.print(reply_array, reply_length);
    } else {
        m3pi.print(reply_array, 8);
        m3pi.locate(0,1);
        m3pi.print(reply_array+8, reply_length-8);
    }
    m3pi_led[4]=1;

}//main