esp8266: allow reading received data
This commit is contained in:
parent
ae394561e2
commit
ad1aa69180
@ -52,6 +52,7 @@ static void radio_esp8266_transmit(uint8_t* data, uint8_t length) {
|
||||
__WFI(); // sleep until something happened
|
||||
}
|
||||
usart_disable_tx_interrupt(USART(RADIO_ESP8266_USART)); // ensure transmit interrupt is disable to prevent index corruption (the ISR should already have done it)
|
||||
rx_used = 0; // reset receive buffer
|
||||
radio_esp8266_activity = false; // reset status because of new activity
|
||||
for (tx_used = 0; tx_used < length && tx_used < LENGTH(tx_buffer); tx_used++) { // copy data
|
||||
tx_buffer[tx_used] = data[length - 1 - tx_used]; // put character in buffer (in reverse order)
|
||||
@ -173,15 +174,20 @@ void USART_ISR(RADIO_ESP8266_USART)(void)
|
||||
rx_used--; // update used buffer information
|
||||
}
|
||||
rx_buffer[rx_used++] = usart_recv(USART(RADIO_ESP8266_USART)); // put character in buffer
|
||||
/*
|
||||
if ('\n' == rx_buffer[rx_used - 1]) {
|
||||
rx_buffer[rx_used] = '\0';
|
||||
printf((char*)rx_buffer);
|
||||
printf("\n");
|
||||
}
|
||||
*/
|
||||
// if the used send a packet with these strings during the commands detection the AT command response will break (AT commands are hard to handle perfectly)
|
||||
if (rx_used >= 4 && memcmp((char*)&rx_buffer[rx_used - 4], "OK\r\n", 4) == 0) { // OK received
|
||||
radio_esp8266_activity = true; // response received
|
||||
radio_esp8266_success = true; // command succeeded
|
||||
rx_used = 0; // reset buffer
|
||||
} else if (rx_used >= 7 && memcmp((char*)&rx_buffer[rx_used - 7], "ERROR\r\n", 7) == 0) { // ERROR received
|
||||
radio_esp8266_activity = true; // response received
|
||||
radio_esp8266_success = false; // command failed
|
||||
rx_used = 0; // reset buffer
|
||||
} else if (rx_used >= 7 && memcmp((char*)&rx_buffer[0], "\r\n+IPD,", 7) == 0) { // IP data being received
|
||||
// find if we received the length
|
||||
int32_t data_length = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user