Program to control UPAS with MicroChip BLE chip + iPhone App
Dependencies: ADS1115 BME280 Calibration CronoDot EEPROM LSM303 MCP40D17 MicroBLE NCP5623BMUTBG SDFileSystem SI1145 STC3100 mbed
main.cpp
- Committer:
- jelord
- Date:
- 2016-01-28
- Revision:
- 1:9fbb5b665068
- Parent:
- 0:2cb2b2ea316f
- Child:
- 2:88fcbfadec6a
File content as of revision 1:9fbb5b665068:
#include "mbed.h" Serial pc(USBTX, USBRX); //Serial microChannel(PA_9, PA_10); // tx, rx Serial microChannel(D8, D2); // tx, rx Timer t; struct tm tt; // manual set RTC values int minute =00; // 0-59 int hour =21; // 2-23 int dayofmonth =6; // 1-31 int month =1; // 1-12 int year =16; // last 2 digits int count,ended,timeout; char timebuf[30]; char buf[2024]; char snd[1024]; char ssid[32] = "AdHoc"; // enter WiFi router ssid inside the quotes char pwd [32] = "password"; // enter WiFi router password inside the quotes void gettime(),setRTC(); void SendCMD(),getreply(),ESPconfig(),ESPsetbaudrate(), YoYo(); void pc_recv(void){ while(pc.readable()){ pc.getc(); } } static uint8_t rx_buf[20]; static uint8_t rx_len=0; static int haltBLE = 1; static int transmissionValue = 0; void uartMicro(void){ haltBLE = 2; while(microChannel.readable()){ rx_buf[rx_len++] = microChannel.getc(); if(rx_buf[rx_len-1]=='\0' || rx_buf[rx_len-1]=='\0'){ wait(0.1); haltBLE = 1; break; } } if(haltBLE!=1){ for(int i=0; i<rx_len; i++){ pc.putc(rx_buf[0]); } } rx_len = 0; } int main(){ // reset=0; //hardware reset for 8266 pc.baud(115200); // set what you want here depending on your terminal program speed pc.printf("\f\n\r-------------Startup-------------\n\r"); wait(0.5); //reset=1; timeout=2; pc.attach(pc_recv); microChannel.attach(uartMicro,microChannel.RxIrq); microChannel.baud(115200); // change this to the new ESP8266 baudrate if it is changed at any time. //uint8_t tempBuf[20] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,0x13}; microChannel.printf("$$$"); wait(1); microChannel.printf("SN, JakeMicro\r"); wait(1); microChannel.printf("A\r"); wait(1); microChannel.printf("---"); wait(1); microChannel.printf("Here is 21 character\n"); // continuosly get AP list and IP while(1) { wait(25); uint8_t zero[1] = {0,}; microChannel.printf("Here is 20 characr\n"); microChannel.putc(zero[0]); //pc.printf("Alive\n"); //microChannel.printf("ALIVE"); } }