Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/PPPOS.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "netif/ppp/pppapi.h"
#include "PPPOS.h"


#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -45,6 +44,10 @@ ppp_pcb *ppp;
/* The PPP IP interface */
struct netif ppp_netif;

/* DNS Info */
esp_netif_dns_info_t dns;
ip_addr_t dns_server;

/* PPP status callback example */
static void ppp_status_cb(ppp_pcb *pcb, int err_code, void *ctx)
{
Expand All @@ -53,7 +56,12 @@ static void ppp_status_cb(ppp_pcb *pcb, int err_code, void *ctx)

switch (err_code) {
case PPPERR_NONE: {

esp_netif_dns_info_t dns_info = {0};
IP_ADDR4(&dns_info.ip, 8, 8, 8, 8);
ESP_LOGE(TAG, "status_cb: Connected\n");

esp_netif_set_dns_info(pppif, ESP_NETIF_DNS_MAIN, &dns_info);
#if PPP_IPV4_SUPPORT
ESP_LOGE(TAG, " ipaddr_v4 = %s\n", ipaddr_ntoa(&pppif->ip_addr));
ESP_LOGE(TAG, " gateway = %s\n", ipaddr_ntoa(&pppif->gw));
Expand Down Expand Up @@ -152,7 +160,6 @@ static u32_t ppp_output_callback(ppp_pcb *pcb, u8_t *data, u32_t len, void *ctx)
}



static void pppos_client_task(void *pvParameters)
{

Expand Down Expand Up @@ -208,7 +215,7 @@ void PPPOS_start(){
}
pppapi_set_default(ppp);
pppapi_set_auth(ppp, PPPAUTHTYPE_PAP, PPP_User, PPP_Pass);
ppp_set_usepeerdns(ppp, 1);
ppp_set_usepeerdns(ppp, 0);
pppapi_connect(ppp, 0);

PPPOS_started = true;
Expand All @@ -221,6 +228,7 @@ bool PPPOS_status(){

void PPPOS_stop(){
pppapi_close(ppp, 0);
PPPOS_connected = false;
}

char* PPPOS_read(){
Expand All @@ -235,6 +243,8 @@ char* PPPOS_read(){

void PPPOS_write(char* cmd){
uart_flush(PPPOS_uart_num);
// uart_flush_input(PPPOS_uart_num);

if (cmd != NULL) {
int cmdSize = strlen(cmd);
uart_write_bytes(PPPOS_uart_num, (const char*)cmd, cmdSize);
Expand Down
2 changes: 1 addition & 1 deletion src/PPPOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extern "C" {
#endif


#define BUF_SIZE (1024)
#define BUF_SIZE (4096)


void PPPOS_init(int txPin, int rxPin, int baudrate, int uart_number, char* user, char* pass);
Expand Down
2 changes: 1 addition & 1 deletion src/PPPOSClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ size_t PPPOSClient::write(const uint8_t *buf, size_t size)
}
}
else if(res < 0) {
log_e("fail on fd %d, errno: %d, \"%s\"", fd(), errno, strerror(errno));
log_e("fail on fd %d, errno: %d, \"%s\"", errno, strerror(errno)); // fd()
if(errno != EAGAIN) {
stop();
res = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/PPPOSClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class PPPOSClient : public Client
virtual void flush();
virtual void stop();
virtual uint8_t connected();

using Print::write;

protected:
Expand Down