@@ -40,6 +40,10 @@ enum ofono_modem_type {
OFONO_MODEM_TYPE_TEST,
};
+enum ofono_modem_capability {
+ OFONO_MODEM_CAPABILITY_LTE = 0x1,
+};
+
typedef void (*ofono_modem_online_cb_t)(const struct ofono_error *error,
void *data);
@@ -134,6 +138,16 @@ ofono_bool_t ofono_modem_get_emergency_mode(struct ofono_modem *modem);
void ofono_modem_set_name(struct ofono_modem *modem, const char *name);
void ofono_modem_set_driver(struct ofono_modem *modem, const char *type);
+/*
+ * Set the capabilities of the modem. This method should be called in
+ * the driver probe() method if the capability information can be obtained
+ * early, for example using the model information, or vid/pid of the device.
+ *
+ * Otherwise, it should be called prior to setting the device powered.
+ */
+void ofono_modem_set_capabilities(struct ofono_modem *modem,
+ unsigned int capabilities);
+
int ofono_modem_set_string(struct ofono_modem *modem,
const char *key, const char *value);
const char *ofono_modem_get_string(struct ofono_modem *modem, const char *key);
@@ -88,6 +88,7 @@ struct ofono_modem {
void *driver_data;
char *driver_type;
char *name;
+ unsigned int capabilities;
};
struct ofono_devinfo {
@@ -162,6 +163,22 @@ static char **get_interfaces(struct ofono_modem *modem)
return interfaces;
}
+static char **get_capabilities(struct ofono_modem *modem)
+{
+ char **capabilities;
+ unsigned int i = 0;
+
+ if (!modem->capabilities)
+ return NULL;
+
+ capabilities = l_new(char *, __builtin_popcount(modem->capabilities));
+
+ if (modem->capabilities & OFONO_MODEM_CAPABILITY_LTE)
+ capabilities[i++] = "lte";
+
+ return capabilities;
+}
+
unsigned int __ofono_modem_callid_next(struct ofono_modem *modem)
{
unsigned int i;
@@ -849,6 +866,7 @@ void __ofono_modem_append_properties(struct ofono_modem *modem,
dbus_bool_t emergency = ofono_modem_get_emergency_mode(modem);
const char *strtype;
const char *system_path;
+ char **capabilities;
ofono_dbus_dict_append(dict, "Online", DBUS_TYPE_BOOLEAN,
&modem->online);
@@ -910,6 +928,13 @@ void __ofono_modem_append_properties(struct ofono_modem *modem,
strtype = modem_type_to_string(modem->driver->modem_type);
ofono_dbus_dict_append(dict, "Type", DBUS_TYPE_STRING, &strtype);
+
+ capabilities = get_capabilities(modem);
+ if (capabilities) {
+ ofono_dbus_dict_append_array(dict, "Capabilities",
+ DBUS_TYPE_STRING, &capabilities);
+ l_free(capabilities);
+ }
}
static DBusMessage *modem_get_properties(DBusConnection *conn,
@@ -1237,6 +1262,19 @@ void ofono_modem_set_powered(struct ofono_modem *modem, ofono_bool_t powered)
modem->timeout = 0;
}
+ if (powered && powered != modem->powered) {
+ char **capabilities = get_capabilities(modem);
+
+ if (capabilities) {
+ ofono_dbus_signal_array_property_changed(conn,
+ modem->path,
+ OFONO_MODEM_INTERFACE,
+ "Capabilities", DBUS_TYPE_STRING,
+ &capabilities);
+ l_free(capabilities);
+ }
+ }
+
if (modem->powered_pending != modem->powered &&
modem->pending != NULL) {
DBusMessage *reply;
@@ -1874,6 +1912,17 @@ void ofono_modem_set_driver(struct ofono_modem *modem, const char *type)
modem->driver_type = l_strdup(type);
}
+void ofono_modem_set_capabilities(struct ofono_modem *modem,
+ unsigned int capabilities)
+{
+ if (!modem)
+ return;
+
+ DBG("%u", capabilities);
+
+ modem->capabilities = capabilities;
+}
+
struct ofono_modem *ofono_modem_create(const char *name, const char *type)
{
struct ofono_modem *modem;