summaryrefslogtreecommitdiffstats
path: root/drivers/qmimodem
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2012-11-25 00:04:14 +0100
committerMarcel Holtmann <marcel@holtmann.org>2012-11-25 00:04:14 +0100
commit7feb9e2711711c3d86be2b15090b5cc4252788eb (patch)
tree0d2cbbeabaa76ae9e02d910637dfebfee597ea95 /drivers/qmimodem
parent196183a3e50bd0b86a7921a1ee7b241f0c9ad131 (diff)
downloadofono-7feb9e2711711c3d86be2b15090b5cc4252788eb.tar.bz2
qmimodem: Add helper for error message strings
Diffstat (limited to 'drivers/qmimodem')
-rw-r--r--drivers/qmimodem/qmi.c108
-rw-r--r--drivers/qmimodem/qmi.h1
2 files changed, 109 insertions, 0 deletions
diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index dd80f89a..b7b6198e 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -338,6 +338,103 @@ static const char *__service_type_to_string(uint8_t type)
return NULL;
}
+static const struct {
+ uint16_t err;
+ const char *str;
+} __error_table[] = {
+ { 0x0000, "NONE" },
+ { 0x0001, "MALFORMED_MSG" },
+ { 0x0002, "NO_MEMORY" },
+ { 0x0003, "INTERNAL" },
+ { 0x0004, "ABORTED" },
+ { 0x0005, "CLIENT_IDS_EXHAUSTED" },
+ { 0x0006, "UNABORTABLE_TRANSACTION" },
+ { 0x0007, "INVALID_CLIENT_ID" },
+ { 0x0008, "NO_THRESHOLDS" },
+ { 0x0009, "INVALID_HANDLE" },
+ { 0x000a, "INVALID_PROFILE" },
+ { 0x000b, "INVALID_PINID" },
+ { 0x000c, "INCORRECT_PIN" },
+ { 0x000d, "NO_NETWORK_FOUND" },
+ { 0x000e, "CALL_FAILED" },
+ { 0x000f, "OUT_OF_CALL" },
+ { 0x0010, "NOT_PROVISIONED" },
+ { 0x0011, "MISSING_ARG" },
+ { 0x0013, "ARG_TOO_LONG" },
+ { 0x0016, "INVALID_TX_ID" },
+ { 0x0017, "DEVICE_IN_USE" },
+ { 0x0018, "OP_NETWORK_UNSUPPORTED" },
+ { 0x0019, "OP_DEVICE_UNSUPPORTED" },
+ { 0x001a, "NO_EFFECT" },
+ { 0x001b, "NO_FREE_PROFILE" },
+ { 0x001c, "INVALID_PDP_TYPE" },
+ { 0x001d, "INVALID_TECH_PREF" },
+ { 0x001e, "INVALID_PROFILE_TYPE" },
+ { 0x001f, "INVALID_SERVICE_TYPE" },
+ { 0x0020, "INVALID_REGISTER_ACTION" },
+ { 0x0021, "INVALID_PS_ATTACH_ACTION" },
+ { 0x0022, "AUTHENTICATION_FAILED" },
+ { 0x0023, "PIN_BLOCKED" },
+ { 0x0024, "PIN_PERM_BLOCKED" },
+ { 0x0025, "UIM_NOT_INITIALIZED" },
+ { 0x0026, "MAX_QOS_REQUESTS_IN_USE" },
+ { 0x0027, "INCORRECT_FLOW_FILTER" },
+ { 0x0028, "NETWORK_QOS_UNAWARE" },
+ { 0x0029, "INVALID_QOS_ID/INVALID_ID" },
+ { 0x002a, "REQUESTED_NUM_UNSUPPORTED" },
+ { 0x002b, "INTERFACE_NOT_FOUND" },
+ { 0x002c, "FLOW_SUSPENDED" },
+ { 0x002d, "INVALID_DATA_FORMAT" },
+ { 0x002e, "GENERAL" },
+ { 0x002f, "UNKNOWN" },
+ { 0x0030, "INVALID_ARG" },
+ { 0x0031, "INVALID_INDEX" },
+ { 0x0032, "NO_ENTRY" },
+ { 0x0033, "DEVICE_STORAGE_FULL" },
+ { 0x0034, "DEVICE_NOT_READY" },
+ { 0x0035, "NETWORK_NOT_READY" },
+ { 0x0036, "CAUSE_CODE" },
+ { 0x0037, "MESSAGE_NOT_SENT" },
+ { 0x0038, "MESSAGE_DELIVERY_FAILURE" },
+ { 0x0039, "INVALID_MESSAGE_ID" },
+ { 0x003a, "ENCODING" },
+ { 0x003b, "AUTHENTICATION_LOCK" },
+ { 0x003c, "INVALID_TRANSACTION" },
+ { 0x0041, "SESSION_INACTIVE" },
+ { 0x0042, "SESSION_INVALID" },
+ { 0x0043, "SESSION_OWNERSHIP" },
+ { 0x0044, "INSUFFICIENT_RESOURCES" },
+ { 0x0045, "DISABLED" },
+ { 0x0046, "INVALID_OPERATION" },
+ { 0x0047, "INVALID_QMI_CMD" },
+ { 0x0048, "TPDU_TYPE" },
+ { 0x0049, "SMSC_ADDR" },
+ { 0x004a, "INFO_UNAVAILABLE" },
+ { 0x004b, "SEGMENT_TOO_LONG" },
+ { 0x004c, "SEGEMENT_ORDER" },
+ { 0x004d, "BUNDLING_NOT_SUPPORTED" },
+ { 0x004f, "POLICY_MISMATCH" },
+ { 0x0050, "SIM_FILE_NOT_FOUND" },
+ { 0x0051, "EXTENDED_INTERNAL" },
+ { 0x0052, "ACCESS_DENIED" },
+ { 0x0053, "HARDWARE_RESTRICTED" },
+ { 0x0054, "ACK_NOT_SENT" },
+ { 0x0055, "INJECT_TIMEOUT" },
+ { }
+};
+
+static const char *__error_to_string(uint16_t error)
+{
+ int i;
+
+ for (i = 0; __error_table[i].str; i++) {
+ if (__error_table[i].err == error)
+ return __error_table[i].str;
+ }
+
+ return NULL;
+}
+
static void __debug_msg(const char dir, const void *buf, size_t len,
qmi_debug_func_t function, void *user_data)
{
@@ -1262,6 +1359,17 @@ bool qmi_result_set_error(struct qmi_result *result, uint16_t *error)
return true;
}
+const char *qmi_result_get_error(struct qmi_result *result)
+{
+ if (!result)
+ return NULL;
+
+ if (result->result == 0x0000)
+ return NULL;
+
+ return __error_to_string(result->error);
+}
+
const void *qmi_result_get(struct qmi_result *result, uint8_t type,
uint16_t *length)
{
diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h
index 81cfac91..46742780 100644
--- a/drivers/qmimodem/qmi.h
+++ b/drivers/qmimodem/qmi.h
@@ -104,6 +104,7 @@ struct qmi_param *qmi_param_new_uint32(uint8_t type, uint32_t value);
struct qmi_result;
bool qmi_result_set_error(struct qmi_result *result, uint16_t *error);
+const char *qmi_result_get_error(struct qmi_result *result);
const void *qmi_result_get(struct qmi_result *result, uint8_t type,
uint16_t *length);