Permalink
Browse files

Add support for full transparent mode and atmega reset

  • Loading branch information...
1 parent 98a1a5e commit 679b1881d5b3ed445f8b5928b5f4e059ea2363a1 @garyservin committed Dec 15, 2014
Showing with 94 additions and 13 deletions.
  1. +1 −0 at/user/at_cmd.h
  2. +84 −9 at/user/at_ipCmd.c
  3. +1 −0 at/user/at_ipCmd.h
  4. +3 −2 at/user/at_wifiCmd.c
  5. +5 −2 at/user/user_main.c
View
@@ -58,6 +58,7 @@ at_funcationType at_fun[at_cmdNum]={
{"+CIUPDATE", 9, NULL, NULL, NULL, at_exeCmdCiupdate},
{"+CIPING", 7, NULL, NULL, NULL, at_exeCmdCiping},
{"+CIPAPPUP", 9, NULL, NULL, NULL, at_exeCmdCipappup},
+ {"+RODI", 5, NULL, NULL, NULL, at_exeCmdRodi},
#ifdef ali
{"+MPINFO", 7, NULL, NULL, at_setupCmdMpinfo, NULL}
#endif
View
@@ -26,6 +26,8 @@
#include "driver/uart.h"
#include<stdlib.h>
+#include "gpio.h"
+
extern at_mdStateType mdState;
extern BOOL specialAtState;
extern at_stateType at_state;
@@ -36,6 +38,7 @@ extern uint8_t at_dataLine[];///
//extern UartDevice UartDev;
extern uint8_t at_wifiMode;
extern int8_t at_dataStrCpy(void *pDest, const void *pSrc, int8_t maxLen);
+extern BOOL echoFlag;
uint16_t at_sendLen; //now is 256
uint16_t at_tranLen; //now is 256
@@ -45,14 +48,15 @@ uint8_t ipDataSendFlag = 0;
static BOOL at_ipMux = FALSE;
static BOOL disAllFlag = FALSE;
+static BOOL rodiMode = FALSE;
static at_linkConType pLink[at_linkMax];
static uint8_t sendingID;
static BOOL serverEn = FALSE;
static at_linkNum = 0;
//static uint8_t repeat_time = 0;
-static uint16_t server_timeover = 180;
+static uint16_t server_timeover = 3600;
static struct espconn *pTcpServer;
static struct espconn *pUdpServer;
@@ -281,6 +285,13 @@ at_tcpclient_recv(void *arg, char *pdata, unsigned short len)
uart0_sendStr(temp);
uart0_tx_buffer(pdata, len);
}
+ else if(rodiMode && (len == 10) && (os_memcmp(pdata, "bootloader", 10) == 0)) //UartDev.rcv_buff.pRcvMsgBuff
+ {
+ gpio_output_set(0, BIT2, BIT2, 0); // Reset arduino
+ os_delay_us(10);
+ gpio_output_set(BIT2, 0, BIT2, 0);
+ return;
+ }
else
{
uart0_tx_buffer(pdata, len);
@@ -1321,15 +1332,21 @@ at_ipDataTransparent(void *arg)
{
// ETS_UART_INTR_DISABLE(); //
specialAtState = TRUE;
- at_state = at_statIdle;
+ at_state = at_statIdle;
+ if(rodiMode){
+ uart0_sendStr("\r\nATMODE\r\n");
+ }
// ETS_UART_INTR_ENABLE();
// IPMODE = FALSE;
return;
}
else if(at_tranLen)
{
+ if(pLink[0].linkEn == TRUE)
+ {
ETS_UART_INTR_DISABLE(); //
espconn_sent(pLink[0].pCon, at_dataLine, at_tranLen); //UartDev.rcv_buff.pRcvMsgBuff ////
+ }
ipDataSendFlag = 1;
// pDataLine = UartDev.rcv_buff.pRcvMsgBuff;
pDataLine = at_dataLine;
@@ -1373,7 +1390,7 @@ at_exeCmdCipsend(uint8_t id)
at_backError;
return;
}
- if(pLink[0].linkEn == FALSE)
+ if(pLink[0].linkEn == FALSE && !rodiMode)
{
at_backError;
return;
@@ -1386,7 +1403,9 @@ at_exeCmdCipsend(uint8_t id)
os_timer_setfn(&at_delayCheck, (os_timer_func_t *)at_ipDataTransparent, NULL);
os_timer_arm(&at_delayCheck, 20, 0);
// IPMODE = TRUE;
- uart0_sendStr("\r\n>");
+ if(!rodiMode){
+ uart0_sendStr("\r\n>");
+ }
}
/**
@@ -1481,7 +1500,9 @@ at_tcpserver_discon_cb(void *arg)
}
else
{
- uart0_sendStr("CLOSED\r\n");
+ if(!rodiMode){
+ uart0_sendStr("CLOSED\r\n");
+ }
}
if(linkTemp->teToff == TRUE)
{
@@ -1498,8 +1519,14 @@ at_tcpserver_discon_cb(void *arg)
disAllFlag = false;
}
ETS_UART_INTR_ENABLE();
- specialAtState = true;
- at_state = at_statIdle;
+
+ if(specialAtState == TRUE){
+ specialAtState = true;
+ at_state = at_statIdle;
+ } else{
+ // GSC: Added for full transparent mode
+ specialAtState = FALSE;
+ }
}
/**
@@ -1537,7 +1564,11 @@ at_tcpserver_recon_cb(void *arg, sint8 errType)
}
else
{
- uart0_sendStr("CONNECT\r\n");
+ if(!rodiMode){
+ uart0_sendStr("CONNECT\r\n");
+ }else{
+ at_exeCmdCipsend(0);
+ }
}
// uart0_sendStr("Unlink\r\n");
@@ -1599,7 +1630,11 @@ at_tcpserver_listen(void *arg)
}
else
{
- uart0_sendStr("CONNECT\r\n");
+ if(!rodiMode){
+ uart0_sendStr("CONNECT\r\n");
+ }else{
+ at_exeCmdCipsend(i);
+ }
}
// uart0_sendStr("Link\r\n");
}
@@ -2280,5 +2315,45 @@ at_exeCmdCipappup(uint8_t id)
}
/**
+ * @brief Setup RoDI stuff
+ * @retval None
+ */
+void ICACHE_FLASH_ATTR
+at_exeCmdRodi(uint8_t id)
+{
+ // Set RoDI mode
+ rodiMode = TRUE;
+
+ // ATE=0
+ echoFlag = FALSE;
+
+ // AT+CIPMODE=1
+ IPMODE = 1;
+
+ // AT+CIPMUX=1
+ at_ipMux = TRUE;
+
+ // AT+CIPSERVER=1,1234
+ char param[] = "=1,1234";
+ at_setupCmdCipserver(0, param);
+
+ // AT+CIPMUX=0
+ at_ipMux = FALSE;
+
+ // GSC: Added for full transparent mode
+ // This prevent entering AT mode unless +++ is received
+ at_exeCmdCipsend(0);
+
+ // Initialize the GPIO subsystem.
+ gpio_init();
+
+ // Set GPIO2 to output mode
+ PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);
+
+ // Set GPIO2 high
+ gpio_output_set(BIT2, 0, BIT2, 0);
+}
+
+/**
* @}
*/
View
@@ -74,4 +74,5 @@ void at_exeCmdCiping(uint8_t id);
void at_exeCmdCipappup(uint8_t id);
+void at_exeCmdRodi(uint8_t id);
#endif
@@ -466,12 +466,13 @@ at_queryCmdCwsap(uint8_t id)
return;
}
wifi_softap_get_config(&apConfig);
- os_sprintf(temp,"%s:\"%s\",\"%s\",%d,%d\r\n",
+ os_sprintf(temp,"%s:\"%s\",\"%s\",%d,%d,%d\r\n",
at_fun[id].at_cmdName,
apConfig.ssid,
apConfig.password,
apConfig.channel,
- apConfig.authmode);
+ apConfig.authmode,
+ apConfig.max_connection);
uart0_sendStr(temp);
at_backOk;
}
View
@@ -20,6 +20,8 @@
#include "osapi.h"
#include "at.h"
+#include "at_ipCmd.h"
+
extern uint8_t at_wifiMode;
extern void user_esp_platform_load_param(void *param, uint16 len);
@@ -36,10 +38,11 @@ void user_init(void)
}
else
{
- uart_init(BIT_RATE_115200, BIT_RATE_115200);
+ uart_init(BIT_RATE_57600, BIT_RATE_115200);
}
at_wifiMode = wifi_get_opmode();
os_printf("\r\nready!!!\r\n");
- uart0_sendStr("\r\nready\r\n");
at_init();
+ at_exeCmdRodi(0);
+ uart0_sendStr("\r\nready\r\n");
}

0 comments on commit 679b188

Please sign in to comment.