SMSInterface.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* SMSInterface.h */
  2. /* Copyright (C) 2012 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 ISMSINTERFACE_H_
  20. #define ISMSINTERFACE_H_
  21. #include "core/fwk.h"
  22. #include "rtos.h"
  23. #include "at/ATCommandsInterface.h"
  24. #define MAX_SM 8
  25. /** Component to use the Short Messages Service (SMS)
  26. *
  27. */
  28. class ISMSInterface
  29. {
  30. public:
  31. /** Initialize interface
  32. Configure SMS commands & register for SMS-related unsolicited result codes
  33. */
  34. virtual int init() = 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 send(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 space 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 get(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 getCount(size_t* pCount) = 0;
  53. };
  54. #endif /* ISMSINTERFACE_H_ */