-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathCellularConnectionHandler.h
71 lines (50 loc) · 2.13 KB
/
CellularConnectionHandler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
This file is part of the Arduino_ConnectionHandler library.
Copyright (c) 2024 Arduino SA
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef ARDUINO_CELLULAR_CONNECTION_HANDLER_H_
#define ARDUINO_CELLULAR_CONNECTION_HANDLER_H_
/******************************************************************************
INCLUDE
******************************************************************************/
#include "ConnectionHandlerInterface.h"
#if defined(ARDUINO_PORTENTA_C33) || defined(ARDUINO_PORTENTA_H7_M7)
#include <Arduino_Cellular.h>
#elif defined(ARDUINO_OPTA)
#include <Arduino_OptaCellular.h>
#endif
#ifndef BOARD_HAS_CELLULAR
#error "Board doesn't support CELLULAR"
#endif
/******************************************************************************
CLASS DECLARATION
******************************************************************************/
class CellularConnectionHandler : public ConnectionHandler
{
public:
CellularConnectionHandler(const char * pin, const char * apn, const char * login, const char * pass, bool const keep_alive = true);
virtual unsigned long getTime() override;
virtual Client & getClient() override { return _gsm_client; };
virtual UDP & getUDP() override;
protected:
virtual NetworkConnectionState update_handleInit () override;
virtual NetworkConnectionState update_handleConnecting () override;
virtual NetworkConnectionState update_handleConnected () override;
virtual NetworkConnectionState update_handleDisconnecting() override;
virtual NetworkConnectionState update_handleDisconnected () override;
private:
const char * _pin;
const char * _apn;
const char * _login;
const char * _pass;
#if defined(ARDUINO_OPTA)
ArduinoCellular &_cellular = CellularExpansion::getCellular();
#else
ArduinoCellular _cellular;
#endif
TinyGsmClient _gsm_client = _cellular.getNetworkClient();
};
#endif /* #ifndef ARDUINO_CELLULAR_CONNECTION_HANDLER_H_ */