This repository has been archived by the owner on Jul 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Continue to improve network module abstraction
- Loading branch information
1 parent
689f643
commit e1a032b
Showing
11 changed files
with
114 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,21 @@ | ||
/// @file WiFi_Client.hpp | ||
/// @file Client.hpp | ||
/// @author Alix ANNERAUD ([email protected]) | ||
/// @brief | ||
/// @version 0.1.0 | ||
/// @date 16-05-2023 | ||
/// | ||
/// @copyright Copyright (c) 2023 | ||
|
||
#ifndef Communication_WiFi_Client_Hpp_Included | ||
#define Communication_WiFi_Client_Hpp_Included | ||
#ifndef Xila_Network_WiFi_Client_Hpp_Included | ||
#define Xila_Network_WiFi_Client_Hpp_Included | ||
|
||
|
||
|
||
#ifdef Xila_WiFi_Hardware_ESP32 | ||
#include <WiFiClientSecure.h> | ||
#endif | ||
|
||
#include "Module/Module.hpp" | ||
#include "../Client.hpp" | ||
|
||
namespace Xila_Namespace | ||
{ | ||
namespace Communication_Types | ||
namespace Network_Types | ||
{ | ||
typedef class WiFi_Client_Class : public Xila_Namespace::Stream_Type | ||
typedef class WiFi_Client_Class : public Client_Class | ||
{ | ||
public: | ||
// - Methods | ||
|
@@ -32,21 +26,21 @@ namespace Xila_Namespace | |
|
||
// - - Operations | ||
|
||
Result_Type Connect(const char *Host, uint16_t Port, int32_t Timeout = 30000); | ||
Result_Type Connect(const char *Host, uint16_t Port, int32_t Timeout = 30000) override; | ||
|
||
void Stop(); | ||
void Stop() override; | ||
|
||
bool Connected(); | ||
String_Type &Last_Error(String_Type &Error_Buffer); | ||
bool Connected() override; | ||
String_Type &Last_Error(String_Type &Error_Buffer) override; | ||
|
||
// - - Getters | ||
|
||
// - - Setters | ||
|
||
void Set_Insecure(); | ||
void Set_Insecure() override; | ||
|
||
void Set_Handshake_Timeout(uint32_t Timeout); | ||
void Set_Timeout(uint32_t Timeout); | ||
void Set_Handshake_Timeout(uint32_t Timeout) override; | ||
void Set_Timeout(uint32_t Timeout) override; | ||
|
||
// - - - Overrided Stream_Type methods | ||
|
||
|
@@ -63,21 +57,10 @@ namespace Xila_Namespace | |
|
||
// - - Operators | ||
|
||
operator bool(); | ||
|
||
bool operator==(WiFi_Client_Class &Client); | ||
bool operator!=(WiFi_Client_Class &Client); | ||
|
||
/// @brief Cast operator to WiFiClientSecure (compatibility purpose) | ||
operator WiFiClientSecure &() | ||
{ | ||
return Client; | ||
} | ||
operator bool() override; | ||
|
||
private: | ||
#if defined(Xila_WiFi_Hardware_ESP32) | ||
WiFiClientSecure Client; | ||
#endif | ||
bool operator==(WiFi_Client_Class &Client) override; | ||
bool operator!=(WiFi_Client_Class &Client) override; | ||
} WiFi_Client_Type; | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,28 @@ | ||
/// @file WiFi_Client.cpp | ||
/// @author Alix ANNERAUD ([email protected]) | ||
/// @brief | ||
/// @version 0.1.0 | ||
/// @date 16-05-2023 | ||
/// | ||
/// @copyright Copyright (c) 2023 | ||
|
||
/// @file Client.cpp | ||
/// @author Alix ANNERAUD ([email protected]) | ||
/// @brief | ||
/// @version 0.1.0 | ||
/// @date 16-05-2023 | ||
/// | ||
/// @copyright Copyright (c) 2023 | ||
|
||
#include "Communication/WiFi_Client.hpp" | ||
#ifdef Xila_WiFi_Hardware_ESP32 | ||
|
||
#include <WiFiClientSecure.h> | ||
|
||
#include "Network/WiFi/Client.hpp" | ||
|
||
using namespace Xila_Namespace; | ||
using namespace Communication_Types; | ||
using namespace Network_Types; | ||
|
||
WiFi_Client_Class::WiFi_Client_Class() | ||
{ | ||
Data = new | ||
} | ||
|
||
Result_Type WiFi_Client_Class::Connect(const char* Host, uint16_t Port, int32_t Timeout) | ||
Result_Type WiFi_Client_Class::Connect(const char *Host, uint16_t Port, int32_t Timeout) | ||
{ | ||
|
||
return (Result_Type)Client.connect(Host, Port, Timeout); | ||
} | ||
|
||
|
@@ -31,18 +36,17 @@ bool WiFi_Client_Class::Connected() | |
return Client.connected(); | ||
} | ||
|
||
String_Type& WiFi_Client_Class::Last_Error(String_Type& Error_Buffer) | ||
String_Type &WiFi_Client_Class::Last_Error(String_Type &Error_Buffer) | ||
{ | ||
if (!Error_Buffer) | ||
return Error_Buffer; | ||
|
||
if (Client.lastError((char*)Error_Buffer, Error_Buffer.Get_Size()) == 0) | ||
if (Client.lastError((char *)Error_Buffer, Error_Buffer.Get_Size()) == 0) | ||
Error_Buffer = ""; | ||
|
||
return Error_Buffer; | ||
} | ||
|
||
|
||
void WiFi_Client_Class::Set_Insecure() | ||
{ | ||
Client.setInsecure(); | ||
|
@@ -83,7 +87,7 @@ String_Type &WiFi_Client_Class::Read_String(String_Type &String) | |
if (!String) | ||
return String; | ||
|
||
Client.read((uint8_t*)(char*)String, String.Get_Size()); | ||
Client.read((uint8_t *)(char *)String, String.Get_Size()); | ||
return String; | ||
} | ||
|
||
|
@@ -102,9 +106,9 @@ Size_Type WiFi_Client_Class::Write_Bytes(const Byte_Type *Buffer, Size_Type Leng | |
return Client.write(Buffer, Length); | ||
} | ||
|
||
Size_Type WiFi_Client_Class::Write_String(const char* String) | ||
Size_Type WiFi_Client_Class::Write_String(const char *String) | ||
{ | ||
return Client.write((uint8_t*)String, strlen(String)); | ||
return Client.write((uint8_t *)String, strlen(String)); | ||
} | ||
|
||
WiFi_Client_Class::operator bool() | ||
|
@@ -122,4 +126,4 @@ bool WiFi_Client_Class::operator!=(WiFi_Client_Class &Client) | |
return Client != Client; | ||
} | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.