modem.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. *
  3. * oFono - Open Source Telephony
  4. *
  5. * Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. *
  20. */
  21. #ifndef __OFONO_MODEM_H
  22. #define __OFONO_MODEM_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. #include <ofono/types.h>
  27. struct ofono_modem;
  28. enum ofono_modem_type {
  29. OFONO_MODEM_TYPE_HARDWARE = 0,
  30. OFONO_MODEM_TYPE_HFP,
  31. OFONO_MODEM_TYPE_SAP,
  32. OFONO_MODEM_TYPE_TEST,
  33. };
  34. typedef void (*ofono_modem_online_cb_t)(const struct ofono_error *error,
  35. void *data);
  36. typedef ofono_bool_t (*ofono_modem_compare_cb_t)(struct ofono_modem *modem,
  37. void *user_data);
  38. struct ofono_modem_driver {
  39. const char *name;
  40. enum ofono_modem_type modem_type;
  41. /* Detect existence of device and initialize any device-specific data
  42. * structures */
  43. int (*probe)(struct ofono_modem *modem);
  44. /* Destroy data structures allocated during probe and cleanup */
  45. void (*remove)(struct ofono_modem *modem);
  46. /* Power up device */
  47. int (*enable)(struct ofono_modem *modem);
  48. /* Power down device */
  49. int (*disable)(struct ofono_modem *modem);
  50. /* Enable or disable cellular radio */
  51. void (*set_online)(struct ofono_modem *modem, ofono_bool_t online,
  52. ofono_modem_online_cb_t callback, void *data);
  53. /* Populate the atoms available without SIM / Locked SIM */
  54. void (*pre_sim)(struct ofono_modem *modem);
  55. /* Populate the atoms that are available with SIM / Unlocked SIM*/
  56. void (*post_sim)(struct ofono_modem *modem);
  57. /* Populate the atoms available online */
  58. void (*post_online)(struct ofono_modem *modem);
  59. };
  60. void ofono_modem_add_interface(struct ofono_modem *modem,
  61. const char *interface);
  62. void ofono_modem_remove_interface(struct ofono_modem *modem,
  63. const char *interface);
  64. const char *ofono_modem_get_path(struct ofono_modem *modem);
  65. void ofono_modem_set_data(struct ofono_modem *modem, void *data);
  66. void *ofono_modem_get_data(struct ofono_modem *modem);
  67. struct ofono_modem *ofono_modem_create(const char *name, const char *type);
  68. int ofono_modem_register(struct ofono_modem *modem);
  69. ofono_bool_t ofono_modem_is_registered(struct ofono_modem *modem);
  70. void ofono_modem_remove(struct ofono_modem *modem);
  71. void ofono_modem_reset(struct ofono_modem *modem);
  72. void ofono_modem_set_powered(struct ofono_modem *modem, ofono_bool_t powered);
  73. ofono_bool_t ofono_modem_get_powered(struct ofono_modem *modem);
  74. ofono_bool_t ofono_modem_get_online(struct ofono_modem *modem);
  75. ofono_bool_t ofono_modem_get_emergency_mode(struct ofono_modem *modem);
  76. void ofono_modem_set_name(struct ofono_modem *modem, const char *name);
  77. void ofono_modem_set_driver(struct ofono_modem *modem, const char *type);
  78. int ofono_modem_set_string(struct ofono_modem *modem,
  79. const char *key, const char *value);
  80. const char *ofono_modem_get_string(struct ofono_modem *modem, const char *key);
  81. int ofono_modem_set_integer(struct ofono_modem *modem,
  82. const char *key, int value);
  83. int ofono_modem_get_integer(struct ofono_modem *modem, const char *key);
  84. int ofono_modem_set_boolean(struct ofono_modem *modem,
  85. const char *key, ofono_bool_t value);
  86. ofono_bool_t ofono_modem_get_boolean(struct ofono_modem *modem,
  87. const char *key);
  88. int ofono_modem_driver_register(const struct ofono_modem_driver *);
  89. void ofono_modem_driver_unregister(const struct ofono_modem_driver *);
  90. struct ofono_modem *ofono_modem_find(ofono_modem_compare_cb_t func,
  91. void *user_data);
  92. #ifdef __cplusplus
  93. }
  94. #endif
  95. #endif /* __OFONO_MODEM_H */