mn_basic_slip_driver.hpp
Go to the documentation of this file.
1 /*
2 *This file is part of the Mini Thread Library (https://github.com/RoseLeBlood/MiniThread ).
3 *Copyright (c) 2018 Amber-Sophia Schroeck
4 *
5 *The Mini Thread Library is free software; you can redistribute it and/or modify
6 *it under the terms of the GNU Lesser General Public License as published by
7 *the Free Software Foundation, version 3, or (at your option) any later version.
8 
9 *The Mini Thread Library is distributed in the hope that it will be useful, but
10 *WITHOUT ANY WARRANTY; without even the implied warranty of
11 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 *General Public License for more details.
13 *
14 *You should have received a copy of the GNU Lesser General Public
15 *License along with the Mini Thread Library; if not, see
16 *<https://www.gnu.org/licenses/>.
17 */
18 #ifndef __MINILIB_BASIC_SLIP_DRIVER_H__
19 #define __MINILIB_BASIC_SLIP_DRIVER_H__
20 
21 #include "../mn_config.hpp"
22 
23 
24 #ifdef CONFIG_LWIP_SLIP_SUPPORT
25 
26 #include <esp_netif.h>
27 #include <esp_netif_net_stack.h>
28 
29 #include <esp_log.h>
30 
31 #include "net/mn_basic_netif.hpp"
32 
33 namespace mn {
34  namespace net {
35 
36  class basic_slip_net_if : public basic_net_if {
37  protected:
38  basic_slip_net_if() : basic_net_if() { }
39 
40  virtual bool create_default();
41  };
42 
43  class basic_slip_driver : public basic_slip_net_if {
44  public:
45  basic_slip_driver(uint8_t uart_num = UART_NUM_2)
46  : basic_slip_driver(uart_num, 4, 36, 115200, 1024) { }
47  basic_slip_driver(uint8_t uart_num, uint8_t tx_pin, uint8_t rx_pin)
48  : basic_slip_driver(uart_num, tx_pin, rx_pin, 115200, 1024) { }
49  basic_slip_driver(uint8_t uart_num, uint8_t tx_pin, uint8_t rx_pin,
50  uint32_t baud, uint32_t buffer_len) ;
51 
52  virtual int start();
53 
54  virtual ip4_address get_ip() { return MNNET_IPV4_ADDRESS_ANY; }
55  virtual ip4_address get_broadcast() { return MNNET_IPV4_ADDRESS_ANY; }
56  virtual ip4_address get_gateway() { return MNNET_IPV4_ADDRESS_ANY; }
57  virtual ip4_address get_netmask() { return MNNET_IPV4_ADDRESS_ANY; }
58 
59  void set_pin(const uint8_t& pin, const uint8_t& rx_pin);
60  void set_serial(const uint8_t& uart_num, const uint32_t& baud);
61  void set_buffer(const uint32_t& buffer_len);
62  void set_ip(const ip4_address& ip);
63  private:
64  esp_netif_slip_config_t m_slipConfig;
65  esp_netif_netstack_config_t m_slipNetStackConfig;
66  };
67  }
68 }
69 #endif // CONFIG_LWIP_SLIP_SUPPORT
70 #endif // __MINILIB_BASIC_SLIP_DRIVER_H__
#define MNNET_IPV4_ADDRESS_ANY
Definition: mn_basic_ip4_address.hpp:25
basic_ip4_address ip4_address
using basic_ip4_address for ip4_address
Definition: mn_socket.hpp:33
Definition: mn_allocator_typetraits.hpp:25