Compare commits

...

4 commits

Author SHA1 Message Date
bf1a26201b fuuuck 2023-01-30 22:20:59 +01:00
f2248c03eb A lot of changes 2023-01-30 22:17:19 +01:00
17c294881f Another change 2023-01-30 22:10:59 +01:00
2965291073 Attempt 1 2023-01-30 22:03:49 +01:00
3 changed files with 23 additions and 48 deletions

View file

@ -1,16 +1,8 @@
#include <string.h> #include <string.h>
#include "freertos/FreeRTOS.h" #include "FreeRTOS.h"
#include "freertos/task.h" //#include "freertos/task.h"
#include "freertos/event_groups.h" //#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_wifi.h"
#include "esp_event_loop.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "driver/uart.h"
#include "driver/gpio.h"
#include "tcpip_adapter.h" #include "tcpip_adapter.h"
#include "netif/ppp/pppos.h" #include "netif/ppp/pppos.h"
#include "lwip/err.h" #include "lwip/err.h"
@ -53,85 +45,85 @@ static void ppp_status_cb(ppp_pcb *pcb, int err_code, void *ctx)
switch (err_code) { switch (err_code) {
case PPPERR_NONE: { case PPPERR_NONE: {
ESP_LOGE(TAG, "status_cb: Connected\n"); //ESP_LOGE(TAG, "status_cb: Connected\n");
#if PPP_IPV4_SUPPORT #if PPP_IPV4_SUPPORT
ESP_LOGE(TAG, " ipaddr_v4 = %s\n", ipaddr_ntoa(&pppif->ip_addr)); //ESP_LOGE(TAG, " ipaddr_v4 = %s\n", ipaddr_ntoa(&pppif->ip_addr));
ESP_LOGE(TAG, " gateway = %s\n", ipaddr_ntoa(&pppif->gw)); //ESP_LOGE(TAG, " gateway = %s\n", ipaddr_ntoa(&pppif->gw));
ESP_LOGE(TAG, " netmask = %s\n", ipaddr_ntoa(&pppif->netmask)); //ESP_LOGE(TAG, " netmask = %s\n", ipaddr_ntoa(&pppif->netmask));
#endif /* PPP_IPV4_SUPPORT */ #endif /* PPP_IPV4_SUPPORT */
#if PPP_IPV6_SUPPORT #if PPP_IPV6_SUPPORT
ESP_LOGE(TAG, " ipaddr_v6 = %s\n", ip6addr_ntoa(netif_ip6_addr(pppif, 0))); //ESP_LOGE(TAG, " ipaddr_v6 = %s\n", ip6addr_ntoa(netif_ip6_addr(pppif, 0)));
#endif /* PPP_IPV6_SUPPORT */ #endif /* PPP_IPV6_SUPPORT */
PPPOS_connected = true; PPPOS_connected = true;
break; break;
} }
case PPPERR_PARAM: { case PPPERR_PARAM: {
ESP_LOGE(TAG, "status_cb: Invalid parameter\n"); //ESP_LOGE(TAG, "status_cb: Invalid parameter\n");
break; break;
} }
case PPPERR_OPEN: { case PPPERR_OPEN: {
ESP_LOGE(TAG, "status_cb: Unable to open PPP session\n"); //ESP_LOGE(TAG, "status_cb: Unable to open PPP session\n");
break; break;
} }
case PPPERR_DEVICE: { case PPPERR_DEVICE: {
ESP_LOGE(TAG, "status_cb: Invalid I/O device for PPP\n"); //ESP_LOGE(TAG, "status_cb: Invalid I/O device for PPP\n");
break; break;
} }
case PPPERR_ALLOC: { case PPPERR_ALLOC: {
ESP_LOGE(TAG, "status_cb: Unable to allocate resources\n"); //ESP_LOGE(TAG, "status_cb: Unable to allocate resources\n");
break; break;
} }
case PPPERR_USER: { case PPPERR_USER: {
ESP_LOGE(TAG, "status_cb: User interrupt\n"); //ESP_LOGE(TAG, "status_cb: User interrupt\n");
PPPOS_started = false; PPPOS_started = false;
PPPOS_connected = false; PPPOS_connected = false;
break; break;
} }
case PPPERR_CONNECT: { case PPPERR_CONNECT: {
ESP_LOGE(TAG, "status_cb: Connection lost\n"); //ESP_LOGE(TAG, "status_cb: Connection lost\n");
PPPOS_started = false; PPPOS_started = false;
PPPOS_connected = false; PPPOS_connected = false;
break; break;
} }
case PPPERR_AUTHFAIL: { case PPPERR_AUTHFAIL: {
ESP_LOGE(TAG, "status_cb: Failed authentication challenge\n"); //ESP_LOGE(TAG, "status_cb: Failed authentication challenge\n");
PPPOS_started = false; PPPOS_started = false;
PPPOS_connected = false; PPPOS_connected = false;
break; break;
} }
case PPPERR_PROTOCOL: { case PPPERR_PROTOCOL: {
ESP_LOGE(TAG, "status_cb: Failed to meet protocol\n"); //ESP_LOGE(TAG, "status_cb: Failed to meet protocol\n");
PPPOS_started = false; PPPOS_started = false;
PPPOS_connected = false; PPPOS_connected = false;
break; break;
} }
case PPPERR_PEERDEAD: { case PPPERR_PEERDEAD: {
ESP_LOGE(TAG, "status_cb: Connection timeout\n"); //ESP_LOGE(TAG, "status_cb: Connection timeout\n");
PPPOS_started = false; PPPOS_started = false;
PPPOS_connected = false; PPPOS_connected = false;
break; break;
} }
case PPPERR_IDLETIMEOUT: { case PPPERR_IDLETIMEOUT: {
ESP_LOGE(TAG, "status_cb: Idle Timeout\n"); //ESP_LOGE(TAG, "status_cb: Idle Timeout\n");
PPPOS_started = false; PPPOS_started = false;
PPPOS_connected = false; PPPOS_connected = false;
break; break;
} }
case PPPERR_CONNECTTIME: { case PPPERR_CONNECTTIME: {
ESP_LOGE(TAG, "status_cb: Max connect time reached\n"); //ESP_LOGE(TAG, "status_cb: Max connect time reached\n");
PPPOS_started = false; PPPOS_started = false;
PPPOS_connected = false; PPPOS_connected = false;
break; break;
} }
case PPPERR_LOOPBACK: { case PPPERR_LOOPBACK: {
ESP_LOGE(TAG, "status_cb: Loopback detected\n"); //ESP_LOGE(TAG, "status_cb: Loopback detected\n");
PPPOS_started = false; PPPOS_started = false;
PPPOS_connected = false; PPPOS_connected = false;
break; break;
} }
default: { default: {
ESP_LOGE(TAG, "status_cb: Unknown error code %d\n", err_code); //ESP_LOGE(TAG, "status_cb: Unknown error code %d\n", err_code);
PPPOS_started = false; PPPOS_started = false;
PPPOS_connected = false; PPPOS_connected = false;
break; break;
@ -171,23 +163,8 @@ char* data = (char*)malloc(BUF_SIZE);
} }
void PPPOS_init(int txPin, int rxPin, int baudrate, int uart_number, char* user, char* pass){ void PPPOS_init(int uart_number, char* user, char* pass){
PPPOS_uart_num = uart_number; PPPOS_uart_num = uart_number;
gpio_set_direction(txPin, GPIO_MODE_OUTPUT);
gpio_set_direction(rxPin, GPIO_MODE_INPUT);
gpio_set_pull_mode(rxPin, GPIO_PULLUP_ONLY);
uart_config_t uart_config = {
.baud_rate = baudrate,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE
};
uart_param_config(PPPOS_uart_num, &uart_config) ;
uart_set_pin(PPPOS_uart_num, txPin, rxPin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_driver_install(PPPOS_uart_num, BUF_SIZE * 2, BUF_SIZE * 2, 0, NULL, 0);
tcpip_adapter_init(); tcpip_adapter_init();
PPP_User = user; PPP_User = user;
PPP_Pass = pass; PPP_Pass = pass;

View file

@ -8,7 +8,7 @@ extern "C" {
#define BUF_SIZE (1024) #define BUF_SIZE (1024)
void PPPOS_init(int txPin, int rxPin, int baudrate, int uart_number, char* user, char* pass); void PPPOS_init(int uart_number, char* user, char* pass);
bool PPPOS_isConnected(); bool PPPOS_isConnected();

View file

@ -11,8 +11,6 @@
#include "Client.h" #include "Client.h"
#include "lwip/dns.h" #include "lwip/dns.h"
#include "lwip/inet.h" #include "lwip/inet.h"
#include "esp_system.h"
#include "esp_wifi.h"
#include "lwip/err.h" #include "lwip/err.h"
#include "lwip/sockets.h" #include "lwip/sockets.h"
#include "lwip/sys.h" #include "lwip/sys.h"