Using HC-05 - Serial to Bluetooth HelloWorld Example for WIZwiki-W7500

Dependencies:   mbed-src

main.cpp

Committer:
justinkim
Date:
2015-07-01
Revision:
0:a4c1f76c9564

File content as of revision 0:a4c1f76c9564:

/**
 ******************************************************************************
 * @project HC-05_HelloWorld_WIZwiki-W7500
 * @author  WIZnet
 * @version V1.0.0
 * @date    01-JUL-2015
 * @brief   Main program
*******************************************************************************
**/

/* Includes ------------------------------------------------------------------*/
#include "mbed.h"

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
Serial pc(USBTX, USBRX);
Serial bt(PA_14, PA_13);

/* Private function prototypes -----------------------------------------------*/

/* Private functions ---------------------------------------------------------*/
/**
   * @brief  Main Function
   * @param  None
   * @retval None
   */
int main(void)
{
    char ch;
    pc.baud(115200);
    bt.baud(115200);
    pc.printf("Hello World!\n\r");
    bt.printf("Hello World!\r\n");
    
    while(1)
    {
        if(bt.readable())
        {
            ch=bt.getc();
            pc.printf("%c",ch);
            bt.printf("%c",ch);
        }
        
        else if(pc.readable())
        {
            ch=pc.getc();
            bt.printf("%c",ch);
            pc.printf("%c",ch); 
        }
    }
}