Passive data reception breakpoints
This commit is contained in:
@@ -17,15 +17,12 @@ ESP8266::~ESP8266() {
|
|||||||
// TODO Auto-generated destructor stub
|
// TODO Auto-generated destructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
void ESP8266::uart_callback(){
|
|
||||||
uart_receive_until_termination_byte(interruptPayload, MAX_BUFFER_SIZE, '\n', 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ESP8266::init(){
|
void ESP8266::init(){
|
||||||
command("AT+CWMODE=1,1\r\n");
|
command("AT+CWMODE=1,1\r\n");
|
||||||
command("AT+CWJAP=\"Gabriel_2G\",\"gabrielwifi\"\r\n");
|
command("AT+CWJAP=\"Gabriel_2G\",\"gabrielwifi\"\r\n");
|
||||||
//command("AT+CWLAP\r\n");
|
//command("AT+CWLAP\r\n");
|
||||||
command("AT+CIPMUX=1\r\n");
|
command("AT+CIPMUX=1\r\n");
|
||||||
|
command("AT+CIPRECVMODE=1\r\n");
|
||||||
command("AT+CIPSTART=0,\"UDP\",\"239.0.0.1\",10001,11001,0\r\n");
|
command("AT+CIPSTART=0,\"UDP\",\"239.0.0.1\",10001,11001,0\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,6 +45,12 @@ void ESP8266::send_uint32(const char* name, uint32_t value){
|
|||||||
send(payloadBuffer);
|
send(payloadBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t ESP8266::receive_uint32() {
|
||||||
|
char commandBuffer[256];
|
||||||
|
sprintf(commandBuffer, "AT+CIPRECVDATA=0,256\r\n");
|
||||||
|
command(commandBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
HAL_StatusTypeDef ESP8266::wait_on_flag_until_timeout(uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout) {
|
HAL_StatusTypeDef ESP8266::wait_on_flag_until_timeout(uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout) {
|
||||||
/* Wait until flag is set */
|
/* Wait until flag is set */
|
||||||
while ((__HAL_UART_GET_FLAG(huart, Flag) ? SET : RESET) == Status) {
|
while ((__HAL_UART_GET_FLAG(huart, Flag) ? SET : RESET) == Status) {
|
||||||
@@ -120,15 +123,13 @@ ESP8266::statusTypeDef ESP8266::wait_until_ok() {
|
|||||||
HAL_UART_AbortReceive_IT(huart);
|
HAL_UART_AbortReceive_IT(huart);
|
||||||
while(uart_receive_until_termination_byte(buffer, MAX_BUFFER_SIZE, '\n', OK_TIMEOUT) != HAL_TIMEOUT){
|
while(uart_receive_until_termination_byte(buffer, MAX_BUFFER_SIZE, '\n', OK_TIMEOUT) != HAL_TIMEOUT){
|
||||||
if(!strcmp((char*) buffer, "OK\r\n")){
|
if(!strcmp((char*) buffer, "OK\r\n")){
|
||||||
HAL_UART_Receive_IT(huart, interruptHeader, 9);
|
|
||||||
return STATUS_OK;
|
return STATUS_OK;
|
||||||
}
|
}
|
||||||
if(!strcmp((char*) buffer, "ERROR\r\n")){
|
if(!strcmp((char*) buffer, "ERROR\r\n")){
|
||||||
HAL_UART_Receive_IT(huart, interruptHeader, 9);
|
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
}
|
}
|
||||||
if(buffer[0] == '+'){
|
if(buffer[0] == '+'){
|
||||||
|
__NOP();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return STATUS_TIMEOUT;
|
return STATUS_TIMEOUT;
|
||||||
@@ -138,15 +139,13 @@ ESP8266::statusTypeDef ESP8266::wait_until_send_ok() {
|
|||||||
HAL_UART_AbortReceive_IT(huart);
|
HAL_UART_AbortReceive_IT(huart);
|
||||||
while(uart_receive_until_termination_byte(buffer, MAX_BUFFER_SIZE, '\n', OK_TIMEOUT) != HAL_TIMEOUT){
|
while(uart_receive_until_termination_byte(buffer, MAX_BUFFER_SIZE, '\n', OK_TIMEOUT) != HAL_TIMEOUT){
|
||||||
if(!strcmp((char*) buffer, "SEND OK\r\n")){
|
if(!strcmp((char*) buffer, "SEND OK\r\n")){
|
||||||
HAL_UART_Receive_IT(huart, interruptHeader, 9);
|
|
||||||
return STATUS_OK;
|
return STATUS_OK;
|
||||||
}
|
}
|
||||||
if(!strcmp((char*) buffer, "SEND ERROR\r\n")){
|
if(!strcmp((char*) buffer, "SEND ERROR\r\n")){
|
||||||
HAL_UART_Receive_IT(huart, interruptHeader, 9);
|
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
}
|
}
|
||||||
if(buffer[0] == '+'){
|
if(buffer[0] == '+'){
|
||||||
|
__NOP();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return STATUS_TIMEOUT;
|
return STATUS_TIMEOUT;
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ public:
|
|||||||
|
|
||||||
ESP8266(UART_HandleTypeDef* huart);
|
ESP8266(UART_HandleTypeDef* huart);
|
||||||
virtual ~ESP8266();
|
virtual ~ESP8266();
|
||||||
void uart_callback();
|
|
||||||
void init();
|
void init();
|
||||||
statusTypeDef command(const char* command);
|
statusTypeDef command(const char* command);
|
||||||
void send_uint32(const char* name, uint32_t value);
|
void send_uint32(const char* name, uint32_t value);
|
||||||
|
uint32_t receive_uint32();
|
||||||
private:
|
private:
|
||||||
static const uint32_t MAX_BUFFER_SIZE = 256;
|
static const uint32_t MAX_BUFFER_SIZE = 256;
|
||||||
static const uint32_t OK_TIMEOUT = 5000;
|
static const uint32_t OK_TIMEOUT = 5000;
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
|
|
||||||
if(huart == &huart1){
|
|
||||||
esp0.uart_callback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) {
|
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) {
|
||||||
if(huart == &huart2){
|
if(huart == &huart2){
|
||||||
debug.serialTxCpltCallback();
|
debug.serialTxCpltCallback();
|
||||||
@@ -68,6 +62,7 @@ void start(){
|
|||||||
debug.info("Init ESP8266 end");
|
debug.info("Init ESP8266 end");
|
||||||
while(true){
|
while(true){
|
||||||
esp0.send_uint32("TIM1->CNT", TIM1->CNT);
|
esp0.send_uint32("TIM1->CNT", TIM1->CNT);
|
||||||
|
esp0.receive_uint32();
|
||||||
/*sprintf(buf, "TIM1->CNT: %lu", TIM1->CNT);
|
/*sprintf(buf, "TIM1->CNT: %lu", TIM1->CNT);
|
||||||
debug.debug(buf);*/
|
debug.debug(buf);*/
|
||||||
//HAL_Delay(10);
|
//HAL_Delay(10);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user