Garren Boggs / Mbed 2 deprecated WirelessInterface_Demo

Dependencies:   WirelessInterface mbed

main.cpp

Committer:
gboggs3
Date:
2016-04-24
Revision:
0:6b892e818f10
Child:
1:c7cfaf8c38f2

File content as of revision 0:6b892e818f10:

#include "mbed.h"
#include "WirelessInterface.h"
    //Wireless Interface contains include files for the Huzzah and BT Friend
#include <string>

//Debug serial port
RawSerial pc(USBTX, USBRX);

WirelessInterface cmd(p28,p27,p26,pc);  //Comment this out to manually configure each device individually
//Huzzah cmd(p28,p27,p26,pc);
//BTFriend cmd(p28,p27,p26,pc);
DigitalOut sel(p22);
InterruptIn pb(p18);

//Interrupt function to change the selected device to communicate with
void changeDevice()
{
    sel = !sel;
    
    char selDev[256];
    if(!sel)
        sprintf(selDev, "Huzzah WiFi Module");
    else
        sprintf(selDev, "Bluetooth Module");
        
    pc.printf("Communicating with: '%s'\r\n", selDev);
    wait(1);    //Debounce
}

int main()
{
    sel = 0;    //0 = WiFi, 1 = Bluetooth
    
    /* An external interrupt can be setup to change the sel pin during runtime */
    pb.rise(&changeDevice);

    while(1) {
        sleep();
    }
}