Nucleo STM32 F401RE , NodeMCU and TCP Conneciton
Dependencies: BufferedSerial mbed-rtos mbed
Fork of NucleoF401_ESP8622 by
Connection SCHEMA
SOCKET DATA
DETAIL DESCRIPTION
http://veyselkaradag.blogspot.com.tr/
main.cpp
- Committer:
- veyselka
- Date:
- 2015-01-13
- Revision:
- 0:515a38e245a4
- Child:
- 1:4a50b910342c
File content as of revision 0:515a38e245a4:
/* --------------------------------------------------------------------------- ** This software is in the public domain, furnished "as is", without technical ** support, and with no warranty, express or implied, as to its usefulness for ** any purpose. ** ** main.ccp ** Quectel M95 GPRS module with STM32F401RE Nucleo Board ** ** Author: <veyselka@hotmail.com> ** -------------------------------------------------------------------------*/ #include "mbed.h" #include "rtos.h" #include "ID_STM32F4.h" #include "modem.h" //------------------------------------ // Hyperterminal configuration // 9600 bauds, 8-bit data, no parity //------------------------------------ Serial pc(USBTX, USBRX); Modem com(PA_9, PA_10); InterruptIn button(USER_BUTTON); DigitalOut myled(LED1); int sms_flag; void GSM(void const *args); void GPS(void const *args); void SERIAL(void const *args); void button_pressed(void); char command_buffer[255]; int main() { button.fall(&button_pressed); pc.baud(115200); com.baud(115200); Thread GSM_THREAD(GSM); Thread GPS_THREAD(GPS); Thread SERIAL_THREAD(SERIAL); while(1); } void GSM(void const *args) { sms_flag=0; com.printf("ATE1\r\n"); Thread::wait(100); while(true) { myled=!myled; com.printf("AT+GSN\r\n"); Thread::wait(100); memset(command_buffer,0,128); com.read_buf(command_buffer,128); pc.printf("Command ANs:%s:\r\n",command_buffer); if(sms_flag==1){ com.printf("AT+CMGF=1\r\n"); Thread::wait(250); com.printf("AT+CMGS=\"+905355948809\"\r\n"); Thread::wait(1000); com.puts("Hello WORLD"); Thread::wait(250); com.putc((char)0x1a); Thread::wait(1000); sms_flag=0; } Thread::wait(1000); } } void GPS(void const *args) { while(true) { // Read a line from the large rx buffer from rx interrupt routine Thread::wait(500); } } void SERIAL(void const *args) { int count=0; int ID=0; uint8_t uID[12]; ID= TM_ID_GetSignature() ; printf("ID:%X:\r\n",ID); printf("uID:"); for(count=0;count<12;count++){ uID[count]=TM_ID_GetUnique8(count); printf("0x%02X ",uID[count]); } printf("\r\n"); count=0; while(true) { Thread::wait(1000); } } void button_pressed() { sms_flag=1; }