2 /* Copyright (C) 2012 mbed.org, MIT License
4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice shall be included in all copies or
11 * substantial portions of the Software.
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 #ifndef LINKMONITOR_H_
21 #define LINKMONITOR_H_
27 #include "at/ATCommandsInterface.h"
29 /** Component to monitor link quality
32 class LinkMonitor
: protected IATCommandsProcessor
35 /** Create LinkMonitor instance
36 @param pIf Pointer to the ATCommandsInterface instance to use
38 LinkMonitor(ATCommandsInterface
* pIf
);
40 /** Initialize monitor
42 int init(bool gsm
= true);
44 /** Registration State
46 enum REGISTRATION_STATE
48 REGISTRATION_STATE_UNKNOWN
, //!< Unknown
49 REGISTRATION_STATE_REGISTERING
, //!< Registering
50 REGISTRATION_STATE_DENIED
, //!< Denied
51 REGISTRATION_STATE_NO_SIGNAL
, //!< No Signal
52 REGISTRATION_STATE_HOME_NETWORK
, //!< Registered on home network
53 REGISTRATION_STATE_ROAMING
//!< Registered on roaming network
60 BEARER_UNKNOWN
, //!< Unknown
61 BEARER_GSM
, //!< GSM (2G)
62 BEARER_EDGE
, //!< EDGE (2.5G)
63 BEARER_UMTS
, //!< UMTS (3G)
64 BEARER_HSPA
, //!< HSPA (3G+)
65 BEARER_LTE
//!< LTE (4G)
69 @param pRssi pointer to store the current RSSI in dBm, between -51 dBm and -113 dBm if known; -51 dBm means -51 dBm or more; -113 dBm means -113 dBm or less; 0 if unknown
70 @param pRegistrationState pointer to store the current registration state
71 @param pBearer pointer to store the current bearer
72 @return 0 on success, error code on failure
74 int getState(int* pRssi
, REGISTRATION_STATE
* pRegistrationState
, BEARER
* pBearer
);
76 /** Get my phone number
77 @param phoneNumber pointer to store the current phoneNumber
78 @return 0 on success, error code on failure
80 int getPhoneNumber(char* phoneNumber
);
82 //IATCommandsProcessor
83 virtual int onNewATResponseLine(ATCommandsInterface
* pInst
, const char* line
);
84 virtual int onNewEntryPrompt(ATCommandsInterface
* pInst
);
87 ATCommandsInterface
* m_pIf
;
91 REGISTRATION_STATE m_registrationState
;
93 char m_phoneNumber
[16];
96 #endif /* LINKMONITOR_H_ */