EJEMPLO NRF5X

Fork of BLE_Driver by TESIS SATUROMETRICA

Committer:
Ferszt
Date:
Mon Aug 22 01:00:45 2016 +0000
Revision:
0:9b6cb48c1cc3
Libreria Terminada.; Falta documentacion.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Ferszt 0:9b6cb48c1cc3 1 /** Driver BLE para Proyecto - Pulsera Saturometrica.
Ferszt 0:9b6cb48c1cc3 2 * Util para implementar rapidamente comunicacion simple BLE.
Ferszt 0:9b6cb48c1cc3 3 *
Ferszt 0:9b6cb48c1cc3 4 * Ejemplo:
Ferszt 0:9b6cb48c1cc3 5 * @code
Ferszt 0:9b6cb48c1cc3 6 * #include "mbed.h"
Ferszt 0:9b6cb48c1cc3 7 * #include "BLE_Driver.h"
Ferszt 0:9b6cb48c1cc3 8 *
Ferszt 0:9b6cb48c1cc3 9 * DigitalOut CONECT_LED(LED2, 1);
Ferszt 0:9b6cb48c1cc3 10 * DigitalOut TEST_LED(LED3, 1);
Ferszt 0:9b6cb48c1cc3 11 * DigitalIn TEST_BUTTON(p17,PullUp);
Ferszt 0:9b6cb48c1cc3 12 *
Ferszt 0:9b6cb48c1cc3 13 * void callbackBLE(int event) {
Ferszt 0:9b6cb48c1cc3 14 * switch (event){
Ferszt 0:9b6cb48c1cc3 15 * case 1: CONECT_LED = 0; break;
Ferszt 0:9b6cb48c1cc3 16 * case 2: CONECT_LED = 1; break;
Ferszt 0:9b6cb48c1cc3 17 * }
Ferszt 0:9b6cb48c1cc3 18 * }
Ferszt 0:9b6cb48c1cc3 19 *
Ferszt 0:9b6cb48c1cc3 20 * void periodicCallback(void){
Ferszt 0:9b6cb48c1cc3 21 * uint8_t a;
Ferszt 0:9b6cb48c1cc3 22 * a= getBLE();
Ferszt 0:9b6cb48c1cc3 23 * if (a=='G')
Ferszt 0:9b6cb48c1cc3 24 * TEST_LED = !TEST_LED;
Ferszt 0:9b6cb48c1cc3 25 * }
Ferszt 0:9b6cb48c1cc3 26 *
Ferszt 0:9b6cb48c1cc3 27 * int main(void){
Ferszt 0:9b6cb48c1cc3 28 * iniBLE("Sigfried");
Ferszt 0:9b6cb48c1cc3 29 * while(1){
Ferszt 0:9b6cb48c1cc3 30 * if (TEST_BUTTON == 0)
Ferszt 0:9b6cb48c1cc3 31 * putBLE("Hola\n\r");
Ferszt 0:9b6cb48c1cc3 32 * }
Ferszt 0:9b6cb48c1cc3 33 * }
Ferszt 0:9b6cb48c1cc3 34 * @endcode
Ferszt 0:9b6cb48c1cc3 35 */
Ferszt 0:9b6cb48c1cc3 36 #ifndef MBED_BLE_DRIVER_H
Ferszt 0:9b6cb48c1cc3 37 #define MBED_BLE_DRIVER_H
Ferszt 0:9b6cb48c1cc3 38
Ferszt 0:9b6cb48c1cc3 39 #include <string.h>
Ferszt 0:9b6cb48c1cc3 40 #include "mbed.h"
Ferszt 0:9b6cb48c1cc3 41 #include "BLE.h"
Ferszt 0:9b6cb48c1cc3 42 #include "UARTService.h"
Ferszt 0:9b6cb48c1cc3 43
Ferszt 0:9b6cb48c1cc3 44 #define TX_RX_MSG_LENGTH 160
Ferszt 0:9b6cb48c1cc3 45
Ferszt 0:9b6cb48c1cc3 46 void putBLE(const char*); //Definicion de rutina de escritura.
Ferszt 0:9b6cb48c1cc3 47 void iniBLE(const char*); //Definicion de inicialización. Inicaliza el BLE y el advertising.
Ferszt 0:9b6cb48c1cc3 48 uint8_t getBLE(void); //Definicion de rutina de lectura.
Ferszt 0:9b6cb48c1cc3 49
Ferszt 0:9b6cb48c1cc3 50 void callbackBLE(int);
Ferszt 0:9b6cb48c1cc3 51
Ferszt 0:9b6cb48c1cc3 52
Ferszt 0:9b6cb48c1cc3 53
Ferszt 0:9b6cb48c1cc3 54 #endif