@@ -22,10 +22,40 @@ namespace arduino { namespace net {
22
22
// - middleware definition: between TCPclient and the user there are multiple middleware layers
23
23
// that act as layer 5/6 of iso/osi stack, TLS is one of them (are there any others?)
24
24
// - sort of client embedding, which may be more flexible
25
- // - I always instantiate a TCPClient, but if I need Http, I will add it as middleware to the current instance
25
+ // + I always instantiate a TCPClient, but if I need Http, I will add it as middleware to the current instance
26
26
// + If HttpClient has different specifics from a TCPClient they might be hard to expose
27
27
// - It could be nice to have an explicit connectSSL in client which enables SSL
28
28
29
+ // We can make this Client available to platforms with enough resources.
30
+
31
+ /* The idea of client factories is that they are going to be defined by the platform, so that depending on the network stack
32
+ * implementation one can make use of a generic TCP client. For instance zephyr or mbed core can apply an implementation
33
+ * that is not dependant on the network interface that is being used. on other cores, on which local routing is not implemented
34
+ * the client is bound to the interface, thus depending on which one is the default interface one has to select the proper class
35
+ *
36
+ * Example zephyr, this can be placed in the library SocketWrapper:
37
+ *
38
+ * void __setClientFactory() __attribute__((constructor)) {
39
+ * TCPClientConnect::setFactory([]() {
40
+ * new ZephyrClient()
41
+ * );
42
+ * });
43
+ * }
44
+ *
45
+ * Example Mbed os, this can be placed in the library Ethernet:
46
+ *
47
+ * void __setClientFactory() __attribute__((constructor)) {
48
+ * // check that there is no other factory already defined. First defined First used
49
+ * if(TCPClientConnect::factory != nullptr) {
50
+ * TCPClientConnect::setFactory([]() {
51
+ * return unique_ptr(
52
+ * new EthernetClient()
53
+ * );
54
+ * });
55
+ * }
56
+ * }
57
+ */
58
+
29
59
class TCPClientConnect : public ClientConnect {
30
60
public:
31
61
@@ -43,7 +73,7 @@ class TCPClientConnect: public ClientConnect {
43
73
uint8_t connected () override ;
44
74
operator bool () override ;
45
75
46
- protected:
76
+ protected: // TODO should this be private?
47
77
// the factory should provide a way to allocate and deallocate the client
48
78
// there should be a default factory that uses to use the default network interface
49
79
static std::function<std::unique_ptr<Client>()> _factory;
0 commit comments