LoRa Access Point 1.5.2018
Dependencies: mbed ds3231 SX1276Lib_LoRa_Access_Point
HC05.cpp
- Committer:
- lukas_formanek
- Date:
- 2018-04-18
- Revision:
- 1:7543af31b91f
- Parent:
- 0:ea088908ad26
- Child:
- 2:0499e1d037a5
File content as of revision 1:7543af31b91f:
#include "HC05.h" const char* BT_ALIVE_RESPONSE = "~~LoRa Gateway~~"; HC05 bt(BT_TX,BT_RX); // Globalna instancia HC05::HC05(PinName tx, PinName rx) : btUart(tx,rx,BAUDRATE) { ClearBuffer(); }; void HC05::Init() { ClearBuffer(); btUart.attach(callback(this,&HC05::RxBtInterrupt), Serial::RxIrq); }; void HC05::ClearBuffer() { memset(buffer, '\0', sizeof(buffer)); pt = 0; }; void HC05::RxBtInterrupt() { char c = btUart.getc(); // pc.putc(c); buffer[pt++] = c; if(pt >= BUFFERSIZE - 1) ClearBuffer(); if(c =='\n') { if( strncmp( ( const char* )buffer, "~~~", 3 ) == 0 ) { btUart.printf("%s\r\n", BT_ALIVE_RESPONSE); // pc.printf("%s", buffer); } if( strncmp( ( const char* )buffer, "AT+SAVETRANSLINK=", 17 ) == 0 ) { // memcpy(server_ip_address, bt_Buffer, sizeof(server_ip_address)); wifi.SetIpOfServer(buffer); // set_server_ip_address = true; // esp.printf("%s",server_ip_address); // pc.printf("%s", buffer); // btUart.printf("OK\r\n"); } if( strncmp( ( const char* )buffer, "AT+CWJAP=", 9 ) == 0 ) { wifi.SetWiFiConnection(buffer); // memcpy(wifi_connection, bt_Buffer, sizeof(wifi_connection)); // set_wifi_connection = true; // esp.printf("%s",server_ip_address); // pc.printf("%s", buffer); // btUart.printf("OK\r\n"); } ClearBuffer(); } }; void HC05::Print(char* message) { btUart.printf("%s\r\n",message); }; /* Serial HC05::GetSerial() { return btUart; } */