
BLE Nano Code.Tested with Integrated mDot code
Dependencies: BLE_API mbed nRF51822
Fork of eco_Labs_ble_Client by
main.cpp
- Committer:
- vidyasagarbhat
- Date:
- 2016-10-04
- Revision:
- 10:09d1a403eb14
- Parent:
- 9:5f0732aa3008
- Child:
- 11:b8e687d97537
File content as of revision 10:09d1a403eb14:
/** ****************************************************************************** * @file Main.cpp * @author Happiesstminds Firmware Team * @version v1.0 * @date 4-Oct-2016 * @brief * ****************************************************************************** * @attention * * ****************************************************************************** */ /******************************************************************************/ /* Include Files*/ /******************************************************************************/ #include <string.h> #include "mbed.h" #include "BLE.h" #include "UARTService.h" /******************************************************************************/ /* Local Defines */ /******************************************************************************/ #define NEED_CONSOLE_OUTPUT 1 /* Set this if you need debug messages on the console; * it will have an impact on code-size and power consumption. */ #if NEED_CONSOLE_OUTPUT #define DEBUG(STR) { if (uart) uart->write(STR, strlen(STR)); } #else #define DEBUG(...) /* nothing */ #endif /* #if NEED_CONSOLE_OUTPUT */ /******************************************************************************/ /* Extern Function declarations */ /******************************************************************************/ extern void ble_event_wait(void); extern void ble_init(void); extern void ble_data_handler_init(void); /******************************************************************************/ /* External Variable Declarations */ /******************************************************************************/ extern bool isDeviceConnected; /******************************************************************************/ /* Static Variable Declarations */ /******************************************************************************/ static DigitalOut led1(LED1); /******************************************************************************/ /* Static Functions */ /******************************************************************************/ /** * @brief periodicCallback - Periodic timer call back * @param * @retval */ static void periodicCallback(void) { // Toggle the LED only if device is Advertizing if(!isDeviceConnected) led1 = !led1; } /** * @brief Initializes the LED * @param none * @retval none */ static void led_init(void) { led1 = 1; Ticker ticker; ticker.attach(periodicCallback, 1); } /******************************************************************************/ /* Global Functions */ /******************************************************************************/ /** * @brief Main - entry point to the application * @param * @retval */ int main(void) { led_init(); //spi_init(); ble_init(); ble_data_handler_init(); // Infinite loop, never exits while (true) { ble_event_wait(); } } /******************************************************************************/ /* END OF FILE */ /******************************************************************************/