Skip to content

Commit

Permalink
Rename network classes
Browse files Browse the repository at this point in the history
  • Loading branch information
me-no-dev committed Mar 20, 2024
1 parent 7afd573 commit cc5765f
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 108 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ set(ARDUINO_LIBRARY_WiFiClientSecure_SRCS
libraries/WiFiClientSecure/src/WiFiClientSecure.cpp)

set(ARDUINO_LIBRARY_Networking_SRCS
libraries/Networking/src/ESP_Network_Interface.cpp
libraries/Networking/src/ESP_Network_Events.cpp
libraries/Networking/src/ESP_Network_Manager.cpp
libraries/Networking/src/NetworkInterface.cpp
libraries/Networking/src/NetworkEvents.cpp
libraries/Networking/src/NetworkManager.cpp
libraries/Networking/src/WiFiClient.cpp
libraries/Networking/src/WiFiServer.cpp
libraries/Networking/src/WiFiUdp.cpp)
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESPmDNS/src/ESPmDNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ License (MIT license):
#define STR(tok) tok
#endif

// static void addInterface(ESP_Network_Interface * iface){
// static void addInterface(NetworkInterface * iface){
// #if defined(CONFIG_MDNS_ADD_CUSTOM_NETIF) && !defined(CONFIG_MDNS_PREDEF_NETIF_STA) && !defined(CONFIG_MDNS_PREDEF_NETIF_ETH)
// /* Demonstration of adding a custom netif to mdns service, but we're adding the default example one,
// * so we must disable all predefined interfaces (PREDEF_NETIF_STA, AP and ETH) first
Expand Down
4 changes: 2 additions & 2 deletions libraries/Ethernet/src/ETH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
}

/* attach to receive events */
initNetif((ESP_Network_Interface_ID)(ESP_NETIF_ID_ETH+_eth_index));
initNetif((Network_Interface_ID)(ESP_NETIF_ID_ETH+_eth_index));

ret = esp_eth_start(_eth_handle);
if(ret != ESP_OK){
Expand Down Expand Up @@ -679,7 +679,7 @@ bool ETHClass::beginSPI(eth_phy_type_t type, int32_t phy_addr, int cs, int irq,
}

/* attach to receive events */
initNetif((ESP_Network_Interface_ID)(ESP_NETIF_ID_ETH+_eth_index));
initNetif((Network_Interface_ID)(ESP_NETIF_ID_ETH+_eth_index));

// Start Ethernet driver state machine
ret = esp_eth_start(_eth_handle);
Expand Down
2 changes: 1 addition & 1 deletion libraries/Ethernet/src/ETH.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ typedef enum {
ETH_PHY_MAX
} eth_phy_type_t;

class ETHClass: public ESP_Network_Interface {
class ETHClass: public NetworkInterface {
public:
ETHClass(uint8_t eth_index=0);
~ETHClass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "ESP_Network_Events.h"
#include "ESP_Network_Manager.h"
#include "NetworkEvents.h"
#include "NetworkManager.h"
#include "esp_task.h"
#include "esp32-hal.h"

Expand All @@ -25,18 +25,18 @@ static std::vector<NetworkEventCbList_t> cbEventList;

static void _network_event_task(void * arg){
for (;;) {
((ESP_Network_Events*)arg)->checkForEvent();
((NetworkEvents*)arg)->checkForEvent();
}
vTaskDelete(NULL);
}

ESP_Network_Events::ESP_Network_Events()
NetworkEvents::NetworkEvents()
: _arduino_event_group(NULL)
, _arduino_event_queue(NULL)
, _arduino_event_task_handle(NULL)
{}

ESP_Network_Events::~ESP_Network_Events(){
NetworkEvents::~NetworkEvents(){
if(_arduino_event_task_handle != NULL){
vTaskDelete(_arduino_event_task_handle);
_arduino_event_task_handle = NULL;
Expand All @@ -57,7 +57,7 @@ ESP_Network_Events::~ESP_Network_Events(){

static uint32_t _initial_bits = NET_DNS_IDLE_BIT;

bool ESP_Network_Events::initNetworkEvents(){
bool NetworkEvents::initNetworkEvents(){
if(!_arduino_event_group){
_arduino_event_group = xEventGroupCreate();
if(!_arduino_event_group){
Expand Down Expand Up @@ -92,7 +92,7 @@ bool ESP_Network_Events::initNetworkEvents(){
return true;
}

bool ESP_Network_Events::postEvent(arduino_event_t *data)
bool NetworkEvents::postEvent(arduino_event_t *data)
{
if(data == NULL || _arduino_event_queue == NULL){
return false;
Expand All @@ -110,7 +110,7 @@ bool ESP_Network_Events::postEvent(arduino_event_t *data)
return true;
}

void ESP_Network_Events::checkForEvent()
void NetworkEvents::checkForEvent()
{
arduino_event_t *event = NULL;
if(_arduino_event_queue == NULL){
Expand Down Expand Up @@ -140,7 +140,7 @@ void ESP_Network_Events::checkForEvent()
free(event);
}

network_event_handle_t ESP_Network_Events::onEvent(NetworkEventCb cbEvent, arduino_event_id_t event)
network_event_handle_t NetworkEvents::onEvent(NetworkEventCb cbEvent, arduino_event_id_t event)
{
if(!cbEvent) {
return 0;
Expand All @@ -154,7 +154,7 @@ network_event_handle_t ESP_Network_Events::onEvent(NetworkEventCb cbEvent, ardui
return newEventHandler.id;
}

network_event_handle_t ESP_Network_Events::onEvent(NetworkEventFuncCb cbEvent, arduino_event_id_t event)
network_event_handle_t NetworkEvents::onEvent(NetworkEventFuncCb cbEvent, arduino_event_id_t event)
{
if(!cbEvent) {
return 0;
Expand All @@ -168,7 +168,7 @@ network_event_handle_t ESP_Network_Events::onEvent(NetworkEventFuncCb cbEvent, a
return newEventHandler.id;
}

network_event_handle_t ESP_Network_Events::onEvent(NetworkEventSysCb cbEvent, arduino_event_id_t event)
network_event_handle_t NetworkEvents::onEvent(NetworkEventSysCb cbEvent, arduino_event_id_t event)
{
if(!cbEvent) {
return 0;
Expand All @@ -182,7 +182,7 @@ network_event_handle_t ESP_Network_Events::onEvent(NetworkEventSysCb cbEvent, ar
return newEventHandler.id;
}

network_event_handle_t ESP_Network_Events::onSysEvent(NetworkEventCb cbEvent, arduino_event_id_t event)
network_event_handle_t NetworkEvents::onSysEvent(NetworkEventCb cbEvent, arduino_event_id_t event)
{
if(!cbEvent) {
return 0;
Expand All @@ -196,7 +196,7 @@ network_event_handle_t ESP_Network_Events::onSysEvent(NetworkEventCb cbEvent, ar
return newEventHandler.id;
}

network_event_handle_t ESP_Network_Events::onSysEvent(NetworkEventFuncCb cbEvent, arduino_event_id_t event)
network_event_handle_t NetworkEvents::onSysEvent(NetworkEventFuncCb cbEvent, arduino_event_id_t event)
{
if(!cbEvent) {
return 0;
Expand All @@ -210,7 +210,7 @@ network_event_handle_t ESP_Network_Events::onSysEvent(NetworkEventFuncCb cbEvent
return newEventHandler.id;
}

network_event_handle_t ESP_Network_Events::onSysEvent(NetworkEventSysCb cbEvent, arduino_event_id_t event)
network_event_handle_t NetworkEvents::onSysEvent(NetworkEventSysCb cbEvent, arduino_event_id_t event)
{
if(!cbEvent) {
return 0;
Expand All @@ -224,7 +224,7 @@ network_event_handle_t ESP_Network_Events::onSysEvent(NetworkEventSysCb cbEvent,
return newEventHandler.id;
}

void ESP_Network_Events::removeEvent(NetworkEventCb cbEvent, arduino_event_id_t event)
void NetworkEvents::removeEvent(NetworkEventCb cbEvent, arduino_event_id_t event)
{
if(!cbEvent) {
return;
Expand All @@ -245,7 +245,7 @@ static size_t getStdFunctionAddress(std::function<T(U...)> f) {
return (size_t) *fnPointer;
}

void ESP_Network_Events::removeEvent(NetworkEventFuncCb cbEvent, arduino_event_id_t event)
void NetworkEvents::removeEvent(NetworkEventFuncCb cbEvent, arduino_event_id_t event)
{
if(!cbEvent) {
return;
Expand All @@ -259,7 +259,7 @@ void ESP_Network_Events::removeEvent(NetworkEventFuncCb cbEvent, arduino_event_i
}
}

void ESP_Network_Events::removeEvent(NetworkEventSysCb cbEvent, arduino_event_id_t event)
void NetworkEvents::removeEvent(NetworkEventSysCb cbEvent, arduino_event_id_t event)
{
if(!cbEvent) {
return;
Expand All @@ -273,7 +273,7 @@ void ESP_Network_Events::removeEvent(NetworkEventSysCb cbEvent, arduino_event_id
}
}

void ESP_Network_Events::removeEvent(network_event_handle_t id)
void NetworkEvents::removeEvent(network_event_handle_t id)
{
for(uint32_t i = 0; i < cbEventList.size(); i++) {
NetworkEventCbList_t entry = cbEventList[i];
Expand All @@ -283,30 +283,30 @@ void ESP_Network_Events::removeEvent(network_event_handle_t id)
}
}

int ESP_Network_Events::setStatusBits(int bits){
int NetworkEvents::setStatusBits(int bits){
if(!_arduino_event_group){
_initial_bits |= bits;
return _initial_bits;
}
return xEventGroupSetBits(_arduino_event_group, bits);
}

int ESP_Network_Events::clearStatusBits(int bits){
int NetworkEvents::clearStatusBits(int bits){
if(!_arduino_event_group){
_initial_bits &= ~bits;
return _initial_bits;
}
return xEventGroupClearBits(_arduino_event_group, bits);
}

int ESP_Network_Events::getStatusBits(){
int NetworkEvents::getStatusBits(){
if(!_arduino_event_group){
return _initial_bits;
}
return xEventGroupGetBits(_arduino_event_group);
}

int ESP_Network_Events::waitStatusBits(int bits, uint32_t timeout_ms){
int NetworkEvents::waitStatusBits(int bits, uint32_t timeout_ms){
if(!_arduino_event_group){
return 0;
}
Expand All @@ -324,7 +324,7 @@ int ESP_Network_Events::waitStatusBits(int bits, uint32_t timeout_ms){
* @return A string representation of the event id.
* @note: arduino_event_id_t values as of Mar 2023 (arduino-esp32 r2.0.7) are: 0-39 (ARDUINO_EVENT_MAX=40) and are defined in WiFiGeneric.h.
*/
const char * ESP_Network_Events::eventName(arduino_event_id_t id) {
const char * NetworkEvents::eventName(arduino_event_id_t id) {
switch(id) {
case ARDUINO_EVENT_ETH_START: return "ETH_START";
case ARDUINO_EVENT_ETH_STOP: return "ETH_STOP";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ typedef void (*NetworkEventSysCb)(arduino_event_t *event);

typedef size_t network_event_handle_t;

class ESP_Network_Events {
class NetworkEvents {
public:
ESP_Network_Events();
~ESP_Network_Events();
NetworkEvents();
~NetworkEvents();

network_event_handle_t onEvent(NetworkEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
network_event_handle_t onEvent(NetworkEventFuncCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
Expand Down
Loading

0 comments on commit cc5765f

Please sign in to comment.