Skip to content

Commit 51596b2

Browse files
committed
Fix more stuff
1 parent b82600f commit 51596b2

25 files changed

+64
-596
lines changed

include/Common.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@
4848
#if __cplusplus >= 202'302L
4949
#warning "C++23 compiler detected"
5050
#elif __cplusplus >= 202'002L
51-
#warning "C++20 compiler detected"
51+
// C++20 :3
5252
#elif __cplusplus >= 201'703L
53-
// C++17 :3
53+
#error "C++17 compiler detected, OpenShock requires a C++20 compliant compiler"
5454
#elif __cplusplus >= 201'402L
55-
#error "C++14 compiler detected, OpenShock requires a C++17 compliant compiler"
55+
#error "C++14 compiler detected, OpenShock requires a C++20 compliant compiler"
5656
#elif __cplusplus >= 201'103L
57-
#error "C++11 compiler detected, OpenShock requires a C++17 compliant compiler"
57+
#error "C++11 compiler detected, OpenShock requires a C++20 compliant compiler"
5858
#elif __cplusplus >= 199'711L
59-
#error "C++98 compiler detected, OpenShock requires a C++17 compliant compiler"
59+
#error "C++98 compiler detected, OpenShock requires a C++20 compliant compiler"
6060
#elif __cplusplus == 1
61-
#error "Pre-C++98 compiler detected, OpenShock requires a C++17 compliant compiler"
61+
#error "Pre-C++98 compiler detected, OpenShock requires a C++20 compliant compiler"
6262
#else
63-
#error "Unknown C++ standard detected, OpenShock requires a C++17 compliant compiler"
63+
#error "Unknown C++ standard detected, OpenShock requires a C++20 compliant compiler"
6464
#endif
6565

6666
namespace OpenShock::Constants {

include/GatewayClient.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
#include "Common.h"
44
#include "GatewayClientState.h"
5-
#include "span.h"
65

76
#include <WebSocketsClient.h>
87

98
#include <cstdint>
9+
#include <span>
1010
#include <string>
1111
#include <string_view>
1212
#include <unordered_map>
@@ -26,7 +26,7 @@ namespace OpenShock {
2626
void disconnect();
2727

2828
bool sendMessageTXT(std::string_view data);
29-
bool sendMessageBIN(tcb::span<const uint8_t> data);
29+
bool sendMessageBIN(std::span<const uint8_t> data);
3030

3131
bool loop();
3232

include/GatewayConnectionManager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#pragma once
22

33
#include "AccountLinkResultCode.h"
4-
#include "span.h"
54

65
#include <cstdint>
76
#include <functional>
7+
#include <span>
88
#include <string_view>
99

1010
namespace OpenShock::GatewayConnectionManager {
@@ -17,7 +17,7 @@ namespace OpenShock::GatewayConnectionManager {
1717
void UnLink();
1818

1919
bool SendMessageTXT(std::string_view data);
20-
bool SendMessageBIN(tcb::span<const uint8_t> data);
20+
bool SendMessageBIN(std::span<const uint8_t> data);
2121

2222
void Update();
2323
} // namespace OpenShock::GatewayConnectionManager

include/TinyVec.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <cstring>
99
#include <limits>
1010
#include <new>
11-
#include <span.h>
11+
#include <span>
1212
#include <type_traits>
1313
#include <utility>
1414

@@ -68,6 +68,14 @@ class TinyVec {
6868
T& operator[](SizeType i) noexcept { return _data[i]; }
6969
const T& operator[](SizeType i) const noexcept { return _data[i]; }
7070

71+
T* begin() noexcept { return _data; }
72+
const T* begin() const noexcept { return _data; }
73+
T* end() noexcept { return _data + _len; }
74+
const T* end() const noexcept { return _data + _len; }
75+
76+
operator std::span<T>() noexcept { return {_data, static_cast<std::size_t>(_len)}; }
77+
operator std::span<const T>() const noexcept { return {_data, static_cast<std::size_t>(_len)}; }
78+
7179
void reserve(SizeType new_cap)
7280
{
7381
if (new_cap <= _cap) return;

include/WebSocketDeFragger.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#include "Common.h"
4-
#include "span.h"
54
#include "TinyVec.h"
65
#include "WebSocketMessageType.h"
76

@@ -10,14 +9,15 @@
109
#include <cstdint>
1110
#include <functional>
1211
#include <map>
12+
#include <span>
1313

1414
namespace OpenShock {
1515
class WebSocketDeFragger {
1616
DISABLE_COPY(WebSocketDeFragger);
1717
DISABLE_MOVE(WebSocketDeFragger);
1818

1919
public:
20-
typedef std::function<void(uint8_t socketId, WebSocketMessageType type, tcb::span<const uint8_t> data)> EventCallback;
20+
typedef std::function<void(uint8_t socketId, WebSocketMessageType type, std::span<const uint8_t> data)> EventCallback;
2121

2222
WebSocketDeFragger(EventCallback callback);
2323
~WebSocketDeFragger();

include/captiveportal/CaptivePortalInstance.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#include "Common.h"
4-
#include "span.h"
54
#include "WebSocketDeFragger.h"
65

76
#include <DNSServer.h>
@@ -12,6 +11,7 @@
1211
#include <freertos/task.h>
1312

1413
#include <cstdint>
14+
#include <span>
1515
#include <string_view>
1616

1717
namespace OpenShock::CaptivePortal {
@@ -24,15 +24,15 @@ namespace OpenShock::CaptivePortal {
2424
~CaptivePortalInstance();
2525

2626
bool sendMessageTXT(uint8_t socketId, std::string_view data) { return m_socketServer.sendTXT(socketId, data.data(), data.length()); }
27-
bool sendMessageBIN(uint8_t socketId, tcb::span<const uint8_t> data) { return m_socketServer.sendBIN(socketId, data.data(), data.size()); }
27+
bool sendMessageBIN(uint8_t socketId, std::span<const uint8_t> data) { return m_socketServer.sendBIN(socketId, data.data(), data.size()); }
2828
bool broadcastMessageTXT(std::string_view data) { return m_socketServer.broadcastTXT(data.data(), data.length()); }
29-
bool broadcastMessageBIN(tcb::span<const uint8_t> data) { return m_socketServer.broadcastBIN(data.data(), data.size()); }
29+
bool broadcastMessageBIN(std::span<const uint8_t> data) { return m_socketServer.broadcastBIN(data.data(), data.size()); }
3030

3131
private:
3232
void task();
3333
void handleWebSocketClientConnected(uint8_t socketId);
3434
void handleWebSocketClientDisconnected(uint8_t socketId);
35-
void handleWebSocketEvent(uint8_t socketId, WebSocketMessageType type, tcb::span<const uint8_t> payload);
35+
void handleWebSocketEvent(uint8_t socketId, WebSocketMessageType type, std::span<const uint8_t> payload);
3636

3737
AsyncWebServer m_webServer;
3838
WebSocketsServer m_socketServer;

include/captiveportal/Manager.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#pragma once
22

33
#include <cstdint>
4+
#include <span>
45
#include <string_view>
56

6-
#include "span.h"
7-
87
namespace OpenShock::CaptivePortal {
98
[[nodiscard]] bool Init();
109

@@ -16,8 +15,8 @@ namespace OpenShock::CaptivePortal {
1615
bool IsRunning();
1716

1817
bool SendMessageTXT(uint8_t socketId, std::string_view data);
19-
bool SendMessageBIN(uint8_t socketId, tcb::span<const uint8_t> data);
18+
bool SendMessageBIN(uint8_t socketId, std::span<const uint8_t> data);
2019

2120
bool BroadcastMessageTXT(std::string_view data);
22-
bool BroadcastMessageBIN(tcb::span<const uint8_t> data);
21+
bool BroadcastMessageBIN(std::span<const uint8_t> data);
2322
} // namespace OpenShock::CaptivePortal

include/http/HTTPRequestManager.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66

77
#include <functional>
88
#include <map>
9+
#include <span>
910
#include <string>
1011
#include <string_view>
1112

12-
#include "span.h"
13-
1413
namespace OpenShock::HTTP {
1514
enum class RequestResult : uint8_t {
1615
InternalError, // Internal error
@@ -31,7 +30,11 @@ namespace OpenShock::HTTP {
3130
T data;
3231

3332
Response(RequestResult r, int c, T d)
34-
: result(r), code(c), data(std::move(d)) {}
33+
: result(r)
34+
, code(c)
35+
, data(std::move(d))
36+
{
37+
}
3538

3639
inline const char* ResultToString() const
3740
{
@@ -65,11 +68,11 @@ namespace OpenShock::HTTP {
6568
using GotContentLengthCallback = std::function<bool(int contentLength)>;
6669
using DownloadCallback = std::function<bool(std::size_t offset, const uint8_t* data, std::size_t len)>;
6770

68-
Response<std::size_t> Download(std::string_view url, const std::map<String, String>& headers, GotContentLengthCallback contentLengthCallback, DownloadCallback downloadCallback, tcb::span<const uint16_t> acceptedCodes, uint32_t timeoutMs = 10'000);
69-
Response<std::string> GetString(std::string_view url, const std::map<String, String>& headers, tcb::span<const uint16_t> acceptedCodes, uint32_t timeoutMs = 10'000);
71+
Response<std::size_t> Download(std::string_view url, const std::map<String, String>& headers, GotContentLengthCallback contentLengthCallback, DownloadCallback downloadCallback, std::span<const uint16_t> acceptedCodes, uint32_t timeoutMs = 10'000);
72+
Response<std::string> GetString(std::string_view url, const std::map<String, String>& headers, std::span<const uint16_t> acceptedCodes, uint32_t timeoutMs = 10'000);
7073

7174
template<typename T>
72-
Response<T> GetJSON(std::string_view url, const std::map<String, String>& headers, JsonParser<T> jsonParser, tcb::span<const uint16_t> acceptedCodes, uint32_t timeoutMs = 10'000)
75+
Response<T> GetJSON(std::string_view url, const std::map<String, String>& headers, JsonParser<T> jsonParser, std::span<const uint16_t> acceptedCodes, uint32_t timeoutMs = 10'000)
7376
{
7477
auto response = GetString(url, headers, acceptedCodes, timeoutMs);
7578
if (response.result != RequestResult::Success) {
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#pragma once
22

3-
#include "span.h"
4-
53
#include <cstdint>
4+
#include <span>
65

76
namespace OpenShock::MessageHandlers::WebSocket {
8-
void HandleGatewayBinary(tcb::span<const uint8_t> data);
9-
void HandleLocalBinary(uint8_t socketId, tcb::span<const uint8_t> data);
7+
void HandleGatewayBinary(std::span<const uint8_t> data);
8+
void HandleLocalBinary(uint8_t socketId, std::span<const uint8_t> data);
109
}

include/serial/command_handlers/CommandEntry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ namespace OpenShock::SerialCmds {
5353
std::string_view m_name;
5454
std::vector<CommandEntry> m_commands;
5555
};
56-
} // namespace OpenShock::Serial
56+
} // namespace OpenShock::SerialCmds

0 commit comments

Comments
 (0)