Skip to contentSkip to conversation

network: allow drivers to generate more specific error codes

PATCH In review Alexander Couzens 2 participants 5 messages Dec 5, 2017 – Dec 6, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 network: allow drivers to generate more specific error codes

For certain modems it's not clear if they support all actions or not. In such cases use CME errors which allows generate NotSupported messages.

---
 src/network.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/network.c +1 -1
index 6e69b078495f..ae3175d4a7e9 100644
@@ -222,7 +222,7 @@ static void register_callback(const struct ofono_error *error, void *data)
 	if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
 		reply = dbus_message_new_method_return(netreg->pending);
 	else
-		reply = __ofono_error_failed(netreg->pending);
+		reply = __ofono_error_from_error(error, netreg->pending);
 
 	__ofono_dbus_pending_reply(&netreg->pending, reply);
 
Signature · 1 line
2.15.1
#1 lore raw

PATCH 2/4 qmimodem: add define CALLBACK_WITH_CME_ERROR(cb, err, args..)

---
 drivers/qmimodem/util.h | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/qmimodem/util.h +9 -0
index cf053f0fe840..974160234af5 100644
@@ -39,6 +39,15 @@ static inline struct cb_data *cb_data_new(void *cb, void *data)
 	return ret;
 }
 
+#define CALLBACK_WITH_CME_ERROR(cb, err, args...)	\
+	do {						\
+		struct ofono_error cb_e;		\
+		cb_e.type = OFONO_ERROR_TYPE_CME;	\
+		cb_e.error = err;			\
+							\
+		cb(&cb_e, ##args);			\
+	} while (0)					\
+
 #define CALLBACK_WITH_FAILURE(cb, args...)		\
 	do {						\
 		struct ofono_error cb_e;		\
Signature · 1 line
2.15.1
#2 lore raw

PATCH 3/4 qmimodem: add translator qmi_error_to_ofono_cme()

In reply to Alexander Couzens

Translates qmi error codes into ofono cme errors

---
 drivers/qmimodem/qmi.c | 11 +++++++++++
 drivers/qmimodem/qmi.h |  2 ++
 2 files changed, 13 insertions(+)
drivers/qmimodem/qmi.c +11 -0
index a0632ca54025..90349db61964 100644
@@ -476,6 +476,17 @@ static const char *__error_to_string(uint16_t error)
 	return NULL;
 }
 
+int qmi_error_to_ofono_cme(int qmi_error) {
+	switch (qmi_error) {
+	case 0x0019:
+		return 4; /* Not Supported */
+	case 0x0052:
+		return 32; /* Access Denied */
+	default:
+		return -1;
+	}
+}
+
 static void __debug_msg(const char dir, const void *buf, size_t len,
 				qmi_debug_func_t function, void *user_data)
 {
drivers/qmimodem/qmi.h +2 -0
index b4955b40b1fb..4f2d5bdf59c5 100644
@@ -140,6 +140,8 @@ bool qmi_result_get_uint64(struct qmi_result *result, uint8_t type,
 							uint64_t *value);
 void qmi_result_print_tlvs(struct qmi_result *result);
 
+int qmi_error_to_ofono_cme(int qmi_error);
+
 struct qmi_service;
 
 typedef void (*qmi_result_func_t)(struct qmi_result *result, void *user_data);
Signature · 1 line
2.15.1
#3 lore raw

PATCH 4/4 qmimodem: convert register_net_cb errors into CMEs

In reply to Alexander Couzens

Certain modems doesn't support manual registering (gobi 2000). Translate the error code into ofono error to report a more detailed debug error message.

---
 drivers/qmimodem/network-registration.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/qmimodem/network-registration.c +3 -1
index c1760b83ee40..6c1f50ba0416 100644
@@ -332,6 +332,7 @@ static void register_net_cb(struct qmi_result *result, void *user_data)
 	struct cb_data *cbd = user_data;
 	ofono_netreg_register_cb_t cb = cbd->cb;
 	uint16_t error;
+	int cme_error;
 
 	DBG("");
 
@@ -341,7 +342,8 @@ static void register_net_cb(struct qmi_result *result, void *user_data)
 			goto done;
 		}
 
-		CALLBACK_WITH_FAILURE(cb, cbd->data);
+		cme_error = qmi_error_to_ofono_cme(error);
+		CALLBACK_WITH_CME_ERROR(cb, cme_error, cbd->data);
 		return;
 	}
 
Signature · 1 line
2.15.1
#4 lore raw
In reply to Alexander Couzens

Hi Alexander,

Quoted 7 lines · Alexander Couzens

For certain modems it's not clear if they support all actions or not. In such cases use CME errors which allows generate NotSupported messages.

---
  src/network.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

All 4 applied, thanks.

Regards,
-Denis