Xbee Bluetooth, una librería modificada para la configuracion y protocolo de comunicación

Committer:
Lucas_eb
Date:
Mon Apr 30 22:11:03 2012 +0000
Revision:
0:6af096b11230
Xbee Bluetooht

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Lucas_eb 0:6af096b11230 1 //BluetoothBee.cpp
Lucas_eb 0:6af096b11230 2
Lucas_eb 0:6af096b11230 3 #include"BluetoothBee.h"
Lucas_eb 0:6af096b11230 4 #include "mbed.h"
Lucas_eb 0:6af096b11230 5
Lucas_eb 0:6af096b11230 6 #define WAIT_TIME 2 // wait time; you may need to increase this number for higher reliability (but slower)
Lucas_eb 0:6af096b11230 7
Lucas_eb 0:6af096b11230 8 BluetoothBee::BluetoothBee(PinName tx, PinName rx) :Serial(tx,rx) {}
Lucas_eb 0:6af096b11230 9
Lucas_eb 0:6af096b11230 10 void BluetoothBee::setup() {
Lucas_eb 0:6af096b11230 11 baud(115200); // the Bluetooth Bee defaults to 38400 baud, 8N1 (8 data bits, no parity, 1 stop bit)
Lucas_eb 0:6af096b11230 12 // mbed defaults to 9600 8N1; thus, change baud rate to 38400
Lucas_eb 0:6af096b11230 13 printf("\r\n+STWMOD=0\r\n"); // set as slave mode
Lucas_eb 0:6af096b11230 14 wait(WAIT_TIME);
Lucas_eb 0:6af096b11230 15 printf("\r\n+STNA=Microbots\r\n"); // set device name as "BluetoothBee"
Lucas_eb 0:6af096b11230 16 wait(WAIT_TIME);
Lucas_eb 0:6af096b11230 17 printf("\r\n+STOAUT=1\r\n"); // allow devices to connect to module
Lucas_eb 0:6af096b11230 18 wait(WAIT_TIME);
Lucas_eb 0:6af096b11230 19 printf("\r\n+INQ=1\r\n"); // start broadcasting (make device visible)
Lucas_eb 0:6af096b11230 20 wait(WAIT_TIME);
Lucas_eb 0:6af096b11230 21 }