|
16 | 16 | INCLUDE
|
17 | 17 | ******************************************************************************/
|
18 | 18 |
|
19 |
| -#include "Arduino_ConnectionHandler.h" |
20 | 19 | #include "GenericConnectionHandler.h"
|
| 20 | +#include "Arduino_ConnectionHandler.h" |
21 | 21 |
|
22 | 22 | void GenericConnectionHandler::updateSetting(const models::NetworkSetting& s) {
|
23 | 23 |
|
24 | 24 | switch(s.type) {
|
25 |
| - #if defined(BOARD_HAS_WIFI) |
26 |
| - case WIFI: |
27 |
| - _ch = new WiFiConnectionHandler(); |
28 |
| - break; |
29 |
| - #endif |
| 25 | + // #if defined(BOARD_HAS_WIFI) |
| 26 | + // case NetworkAdapter::WIFI: |
| 27 | + // _ch = new WiFiConnectionHandler(); |
| 28 | + // break; |
| 29 | + // #endif |
30 | 30 |
|
31 | 31 | #if defined(BOARD_HAS_ETHERNET)
|
32 |
| - case ETHERNET: |
| 32 | + case NetworkAdapter::ETHERNET: |
33 | 33 | _ch = new EthernetConnectionHandler();
|
34 | 34 | break;
|
35 | 35 | #endif
|
36 | 36 |
|
37 |
| - #if defined(BOARD_HAS_NB) |
38 |
| - case NB: |
39 |
| - _ch = new NBConnectionHandler(); |
40 |
| - break; |
41 |
| - #endif |
42 |
| - |
43 |
| - #if defined(BOARD_HAS_GSM) |
44 |
| - case GSM: |
45 |
| - _ch = new GSMConnectionHandler(); |
46 |
| - break; |
47 |
| - #endif |
48 |
| - |
49 |
| - #if defined(BOARD_HAS_CATM1_NBIOT) |
50 |
| - case CATM1: |
51 |
| - _ch = new CatM1ConnectionHandler(); |
52 |
| - break; |
53 |
| - #endif |
54 |
| - |
55 |
| - #if defined(BOARD_HAS_CELLULAR) |
56 |
| - case CELL: |
57 |
| - _ch = new CellularConnectionHandler(); |
58 |
| - break; |
59 |
| - #endif |
60 |
| - |
61 |
| - #if defined(BOARD_HAS_NOTECARD) // FIXME understand how to adapt it to the settings structure |
62 |
| - case NOTECARD: |
63 |
| - _ch = new NotecardConnectionHandler(); |
64 |
| - break; |
65 |
| - #endif |
| 37 | + // #if defined(BOARD_HAS_NB) |
| 38 | + // case NetworkAdapter::NB: |
| 39 | + // _ch = new NBConnectionHandler(); |
| 40 | + // break; |
| 41 | + // #endif |
| 42 | + |
| 43 | + // #if defined(BOARD_HAS_GSM) |
| 44 | + // case NetworkAdapter::GSM: |
| 45 | + // _ch = new GSMConnectionHandler(); |
| 46 | + // break; |
| 47 | + // #endif |
| 48 | + |
| 49 | + // #if defined(BOARD_HAS_CATM1_NBIOT) |
| 50 | + // case NetworkAdapter::CATM1: |
| 51 | + // _ch = new CatM1ConnectionHandler(); |
| 52 | + // break; |
| 53 | + // #endif |
| 54 | + |
| 55 | + // #if defined(BOARD_HAS_CELLULAR) |
| 56 | + // case NetworkAdapter::CELL: |
| 57 | + // _ch = new CellularConnectionHandler(); |
| 58 | + // break; |
| 59 | + // #endif |
| 60 | + |
| 61 | + // #if defined(BOARD_HAS_NOTECARD) // FIXME understand how to adapt it to the settings structure |
| 62 | + // case NOTECARD: |
| 63 | + // _ch = new NotecardConnectionHandler(); |
| 64 | + // break; |
| 65 | + // #endif |
66 | 66 |
|
67 | 67 | default:
|
68 | 68 | Debug.print(DBG_ERROR, "Network adapter not supported by this platform: %d", s.type);
|
69 | 69 | return;
|
70 | 70 | }
|
| 71 | + _interface = s.type; |
71 | 72 | _ch->updateSetting(s);
|
72 | 73 | }
|
73 | 74 |
|
74 | 75 | NetworkConnectionState GenericConnectionHandler::update_handleInit() {
|
75 |
| - return _ch != nullptr ? _ch->update_handleInit() : INIT; |
| 76 | + return _ch != nullptr ? _ch->update_handleInit() : NetworkConnectionState::INIT; |
76 | 77 | }
|
77 | 78 |
|
78 |
| -NetworkConnectionState GenericConnectionHandler::update_handleDisconnecting() { |
79 |
| - return _ch != nullptr ? _ch->update_handleDisconnecting() : INIT; |
| 79 | +NetworkConnectionState GenericConnectionHandler::update_handleConnecting() { |
| 80 | + return _ch != nullptr ? _ch->update_handleConnecting() : NetworkConnectionState::INIT; |
80 | 81 | }
|
81 | 82 |
|
82 | 83 | NetworkConnectionState GenericConnectionHandler::update_handleConnected() {
|
83 |
| - return _ch != nullptr ? _ch->update_handleConnected() : INIT; |
| 84 | + return _ch != nullptr ? _ch->update_handleConnected() : NetworkConnectionState::INIT; |
84 | 85 | }
|
85 | 86 |
|
86 | 87 | NetworkConnectionState GenericConnectionHandler::update_handleDisconnecting() {
|
87 |
| - return _ch != nullptr ? _ch->update_handleDisconnecting() : INIT; |
| 88 | + return _ch != nullptr ? _ch->update_handleDisconnecting() : NetworkConnectionState::INIT; |
88 | 89 | }
|
89 | 90 |
|
90 | 91 | NetworkConnectionState GenericConnectionHandler::update_handleDisconnected() {
|
91 |
| - return _ch != nullptr ? _ch->update_handleDisconnected() : INIT; |
| 92 | + return _ch != nullptr ? _ch->update_handleDisconnected() : NetworkConnectionState::INIT; |
| 93 | +} |
| 94 | + |
| 95 | +unsigned long GenericConnectionHandler::getTime() { // FIXME _ch may be nullptr |
| 96 | + return _ch->getTime(); |
| 97 | +} |
| 98 | + |
| 99 | +Client & GenericConnectionHandler::getClient() { // FIXME _ch may be nullptr |
| 100 | + return _ch->getClient(); |
| 101 | +} |
| 102 | + |
| 103 | +UDP & GenericConnectionHandler::getUDP() { // FIXME _ch may be nullptr |
| 104 | + return _ch->getUDP(); |
92 | 105 | }
|
0 commit comments