Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Commit

Permalink
Continue to work on network module
Browse files Browse the repository at this point in the history
  • Loading branch information
AlixANNERAUD committed Sep 19, 2023
1 parent dcc5a05 commit 37dfb7c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lib/Shell
Submodule Shell updated 1 files
+15 −9 src/Shell.cpp
2 changes: 2 additions & 0 deletions lib/Xila/include/Network/Interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ namespace Xila_Namespace

// - - - IP

virtual Byte_Type& Get_MAC_Address(Byte_Type& MAC_Address) = 0;
virtual IP_Address_Type Get_IP_Address(bool IPv6 = false) = 0;
virtual IP_Address_Type Get_Gateway_IP_Address() = 0;
virtual IP_Address_Type Get_Subnet_Mask() = 0;
virtual IP_Address_Type Get_DNS_IP_Address(Natural_Type Index) = 0;
virtual IP_Address_Type Get_Broadcast_IP_Address() = 0;
virtual IP_Address_Type Get_Network_ID() = 0;
virtual Byte_Type Get_Subnet_CIDR() = 0;
virtual bool Is_IP_v6() = 0;

Expand Down
4 changes: 3 additions & 1 deletion lib/Xila/include/Network/WiFi/Interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@ namespace Xila_Namespace
Client_Type& Create_Client() override;

State_Type Get_State() override;
Byte_Type& Get_MAC_Address(Byte_Type& MAC_Address) override;
IP_Address_Type Get_IP_Address(bool IPv6 = false) override;
IP_Address_Type Get_Gateway_IP_Address() override;
IP_Address_Type Get_Subnet_Mask() override;
IP_Address_Type Get_DNS_IP_Address(Natural_Type Index) override;
IP_Address_Type Get_Broadcast_IP_Address() override;
IP_Address_Type Get_Network_ID() override;
Byte_Type Get_Subnet_CIDR() override;
bool Is_IP_v6() override;
Boolean_Type Is_IP_v6() override;
String_Type &Get_Host_Name(String_Type &Host_Name) override;
Interface_Type_Type Get_Type() override;

Expand Down
72 changes: 51 additions & 21 deletions lib/Xila/src/Network/WiFi/Drivers/ESP32/Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ WiFi_Interface_Type WiFi_Interface;

// - Methods

WiFi_Interface_Class::WiFi_Interface_Class()
WiFi_Interface_Class::WiFi_Interface_Class() : Station(), Access_Point(), Scan()
{
}

Expand Down Expand Up @@ -238,18 +238,37 @@ Result_Type WiFi_Interface_Class::Set_Transmission_Power(int16_t Power)
Result_Type WiFi_Interface_Class::Set_Host_Name(const char *Host_Name)
{
if (Host_Name)
if (ESP32_WiFi.setHostname(Host_Name))
if (ESP32_WiFi.setHostname(Host_Name) && ESP32_WiFi.softAPsetHostname(Host_Name))
return Result_Type::Success;

return Result_Type::Error;
}

Boolean_Type WiFi_Interface_Class::Is_IP_v6()
{
return IP_v6;
}

Result_Type WiFi_Interface_Class::Set_IP_v6(bool Enable)
{
if (Enable)
if (!Enable)
return Result_Type::Success;

this->IP_v6 = Enable;

if (this->Get_Mode() == Mode_Type::Access_Point)
{
if (!ESP32_WiFi.softAPenableIpV6())
return Result_Type::Error;
}
else if (this->Get_Mode() == Mode_Type::Station)
{
if (!ESP32_WiFi.enableIpV6())
return Result_Type::Error;

}
else
return Result_Type::Error;

return Result_Type::Success;
}

Expand Down Expand Up @@ -323,20 +342,32 @@ int8_t WiFi_Interface_Class::Station_Class::Get_RSSI()
return ESP32_WiFi.RSSI();
}

uint8_t *WiFi_Interface_Class::Station_Class::Get_MAC_Address(uint8_t *MAC_Address)
Byte_Type& WiFi_Interface_Class::Get_MAC_Address(Byte_Type& MAC_Address)
{
return ESP32_WiFi.macAddress(MAC_Address);
if (this->Get_Mode() == Mode_Type::Access_Point)
return *ESP32_WiFi.softAPmacAddress(&MAC_Address);
else if (this->Get_Mode() == Mode_Type::Station)
return *ESP32_WiFi.macAddress(&MAC_Address);
return MAC_Address;
}

IP_Address_Type WiFi_Interface_Class::Get_IP_Address(bool IPv6)
{
if (this->Get_Mode() == Mode_Type::Access_Point)
return IP_Address_Type((uint32_t)ESP32_WiFi.softAPIP());

if (IPv6)
return IP_Address_Class(ESP32_WiFi.localIPv6());

return IP_Address_Type((uint32_t)ESP32_WiFi.localIP());
{
if (IPv6)
return IP_Address_Class(ESP32_WiFi.softAPIPv6());
else
return IP_Address_Type((uint32_t)ESP32_WiFi.softAPIP());
}
else if (this->Get_Mode() == Mode_Type::Station)
{
if (IPv6)
return IP_Address_Class(ESP32_WiFi.localIPv6());
else
return IP_Address_Type((uint32_t)ESP32_WiFi.localIP());
}
return IP_Address_Type();
}

IP_Address_Type WiFi_Interface_Class::Get_Subnet_Mask()
Expand All @@ -360,11 +391,16 @@ IP_Address_Type WiFi_Interface_Class::Get_Broadcast_IP_Address()
return IP_Address_Type((uint32_t)ESP32_WiFi.softAPBroadcastIP());
else if (this->Get_Mode() == Mode_Type::Station)
return IP_Address_Type((uint32_t)ESP32_WiFi.broadcastIP());
return IP_Address_Type();
}

IP_Address_Type WiFi_Interface_Class::Station_Class::Get_Network_ID()
IP_Address_Type WiFi_Interface_Class::Get_Network_ID()
{
return IP_Address_Type(ESP32_WiFi.networkID());
if (this->Get_Mode() == Mode_Type::Access_Point)
return IP_Address_Type(ESP32_WiFi.softAPNetworkID());
else if (this->Get_Mode() == Mode_Type::Station)
return IP_Address_Type(ESP32_WiFi.networkID());
return IP_Address_Type();
}

Byte_Type WiFi_Interface_Class::Get_Subnet_CIDR()
Expand Down Expand Up @@ -485,8 +521,6 @@ IP_Address_Type WiFi_Interface_Class::Access_Point_Class::Get_Network_ID()
return IP_Address_Type(ESP32_WiFi.softAPNetworkID());
}



uint8_t *WiFi_Interface_Class::Access_Point_Class::Get_MAC_Address(uint8_t *MAC_Address)
{
return ESP32_WiFi.softAPmacAddress(MAC_Address);
Expand Down Expand Up @@ -560,10 +594,6 @@ Client_Type &WiFi_Interface_Class::Create_Client()
return *(new WiFi_Client_Type());
}

WiFi_Interface_Class::WiFi_Interface_Class() : Station(), Access_Point(), Scan()
{
}

Result_Type WiFi_Interface_Class::Start()
{
if (this->Load_Registry() != Result_Type::Success)
Expand Down
2 changes: 1 addition & 1 deletion lib/Xila/src/System/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ void System_Class::Restart()
Display.Stop();
Power.Stop();
Sound.Stop();
Communication.Stop();
Network.Stop();

this->Stop_Load_Animation(&Logo, Animation);

Expand Down

0 comments on commit 37dfb7c

Please sign in to comment.