CellularModem.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* CellularModem.h */
  2. /* Copyright (C) 2013 mbed.org, MIT License
  3. *
  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:
  9. *
  10. * The above copyright notice and this permission notice shall be included in all copies or
  11. * substantial portions of the Software.
  12. *
  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.
  18. */
  19. #ifndef CELLULARMODEM_H_
  20. #define CELLULARMODEM_H_
  21. #include "core/fwk.h"
  22. #include "at/ATCommandsInterface.h"
  23. class CellularModem
  24. {
  25. public:
  26. //Internet-related functions
  27. /** Open a 3G internet connection
  28. @return 0 on success, error code on failure
  29. */
  30. virtual int connect(const char* apn = NULL, const char* user = NULL, const char* password = NULL) = 0;
  31. /** Close the internet connection
  32. @return 0 on success, error code on failure
  33. */
  34. virtual int disconnect() = 0;
  35. /** Send a SM
  36. @param number The receiver's phone number
  37. @param message The message to send
  38. @return 0 on success, error code on failure
  39. */
  40. virtual int sendSM(const char* number, const char* message) = 0;
  41. /** Receive a SM
  42. @param number Pointer to a buffer to store the sender's phone number (must be at least 17 characters-long, including the sapce for the null-terminating char)
  43. @param message Pointer to a buffer to store the the incoming message
  44. @param maxLength Maximum message length that can be stored in buffer (including null-terminating character)
  45. @return 0 on success, error code on failure
  46. */
  47. virtual int getSM(char* number, char* message, size_t maxLength) = 0;
  48. /** Get the number of SMs in the incoming box
  49. @param pCount pointer to store the number of unprocessed SMs on
  50. @return 0 on success, error code on failure
  51. */
  52. virtual int getSMCount(size_t* pCount) = 0;
  53. /** Get the ATCommandsInterface instance
  54. @return Pointer to the ATCommandsInterface instance
  55. */
  56. virtual ATCommandsInterface* getATCommandsInterface() = 0;
  57. /** Switch power on or off
  58. In order to use this function, a pin name must have been entered in the constructor
  59. @param enable true to switch the dongle on, false to switch it off
  60. @return 0 on success, error code on failure
  61. */
  62. virtual int power(bool enable) = 0;
  63. };
  64. #endif /* CELLULARMODEM_H_ */