Completed AT command library

This commit is contained in:
David Cermak
2021-04-19 11:28:53 +02:00
parent 26bde89834
commit 9e8ffbc760
20 changed files with 335 additions and 65 deletions

View File

@ -1,16 +1,24 @@
//
// Created by david on 2/7/21.
//
#include<stdio.h>
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
#include "esp_netif.h"
#include "esp_err.h"
#include<string.h> //strlen
#include<sys/socket.h>
#include<arpa/inet.h> //inet_addr
#include <sys/types.h>
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include<stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <ifaddrs.h>
#include <net/if.h>
#include "esp_netif.h"
#include "esp_err.h"
esp_netif_t *esp_netif_get_handle_from_ifkey(const char *if_key)
{
@ -31,19 +39,12 @@ esp_err_t esp_netif_dhcpc_get_status(esp_netif_t *esp_netif, esp_netif_dhcp_stat
esp_err_t esp_netif_get_ip6_linklocal(esp_netif_t *esp_netif, esp_ip6_addr_t *if_ip6)
{
struct ifaddrs *addrs, *tmp;
getifaddrs(&addrs);
tmp = addrs;
while (tmp)
{
// if (tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_INET)
// {
// struct sockaddr_in *pAddr = (struct sockaddr_in *)tmp->ifa_addr;
// printf("%s: %s\n", tmp->ifa_name, inet_ntoa(pAddr->sin_addr));
// } else
if (tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_INET6) {
char addr[64];
struct sockaddr_in6 *pAddr = (struct sockaddr_in6 *)tmp->ifa_addr;

View File

@ -15,12 +15,14 @@
#define _HOST_ESP_NETIF_H_
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include "esp_netif_ip_addr.h"
#include "esp_err.h"
#include "esp_event.h"
#include "esp_event_base.h"
struct esp_netif_obj {};
typedef struct esp_netif_obj esp_netif_t;
typedef struct esp_netif_driver_base_s {
esp_err_t (*post_attach)(esp_netif_t *netif, void* h);
@ -34,8 +36,6 @@ struct esp_netif_driver_ifconfig {
void (*driver_free_rx_buffer)(void *h, void* buffer);
};
typedef struct esp_netif_obj esp_netif_t;
/** @brief Status of DHCP client or DHCP server */
typedef enum {
ESP_NETIF_DHCP_INIT = 0, /**< DHCP client/server is in initial state (not yet started) */