[PATCH] uqmi: wms - added storage to read text messages
Henrik Ginstmark
henrik at ginstmark.se
Sun Mar 13 12:17:17 PDT 2022
Today it's hard coded to read text messages from SIM card.
Not all devices store received text messages in SIM, they store
in me, QMI_WMS_STORAGE_TYPE_NV.
I have added a switch to choose sim or me for --list-messages,
--get-message and --delete-message.
Signed-off-by: Henrik Ginstmarh <henrik at ginstmark.se>
---
uqmi/src/commands-wms.c | 69 +++++++++++++++++++++++++++++++++--------
uqmi/src/commands-wms.h | 10 +++---
2 files changed, 61 insertions(+), 18 deletions(-)
diff --git a/uqmi/src/commands-wms.c b/uqmi/src/commands-wms.c
index a58fd6a..2bcc398 100644
--- a/uqmi/src/commands-wms.c
+++ b/uqmi/src/commands-wms.c
@@ -46,6 +46,14 @@ cmd_wms_list_messages_prepare(struct qmi_dev *qmi, struct qmi_request *req, stru
QMI_INIT(message_tag, QMI_WMS_MESSAGE_TAG_TYPE_MT_NOT_READ),
};
+ if (strcmp(arg, "sim") == 0) {
+ } else if (strcmp(arg, "me") == 0) {
+ qmi_set_ptr(&mreq, storage_type, QMI_WMS_STORAGE_TYPE_NV);
+ } else {
+ uqmi_add_error("Invalid value (sim or me)");
+ return QMI_CMD_EXIT;
+ }
+
qmi_set_wms_list_messages_request(msg, &mreq);
return QMI_CMD_REQUEST;
@@ -283,20 +291,37 @@ static void blobmsg_add_hex(struct blob_buf *buf, const char *name, unsigned con
static enum qmi_cmd_result
cmd_wms_delete_message_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
{
- char *err;
- int id;
-
- id = strtoul(arg, &err, 10);
- if (err && *err) {
- uqmi_add_error("Invalid message ID");
- return QMI_CMD_EXIT;
- }
-
static struct qmi_wms_delete_request mreq = {
QMI_INIT(memory_storage, QMI_WMS_STORAGE_TYPE_UIM),
QMI_INIT(message_mode, QMI_WMS_MESSAGE_MODE_GSM_WCDMA),
};
+ char *s;
+ int id;
+
+ s = strchr(arg, ',');
+ if (!s) {
+ uqmi_add_error("Invalid argument");
+ return QMI_CMD_EXIT;
+ }
+ s = strtok(s, ",");
+ if (!s) {
+ uqmi_add_error("No message id");
+ return QMI_CMD_EXIT;
+ }
+ id = strtoul(s, &s, 0);
+ if (s && *s) {
+ uqmi_add_error("Invalid message id");
+ return QMI_CMD_EXIT;
+ }
+ if (strcmp(strtok(arg, ","), "sim") == 0) {
+ } else if (strcmp(strtok(arg, ","), "me") == 0) {
+ qmi_set_ptr(&mreq, memory_storage, QMI_WMS_STORAGE_TYPE_NV);
+ } else {
+ uqmi_add_error("Invalid value (sim or me)");
+ return QMI_CMD_EXIT;
+ }
+
mreq.set.memory_index = 1;
mreq.data.memory_index = id;
@@ -449,12 +474,30 @@ cmd_wms_get_message_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct
),
QMI_INIT(message_mode, QMI_WMS_MESSAGE_MODE_GSM_WCDMA),
};
- char *err;
+
+ char *s;
int id;
- id = strtoul(arg, &err, 10);
- if (err && *err) {
- uqmi_add_error("Invalid message ID");
+ s = strchr(arg, ',');
+ if (!s) {
+ uqmi_add_error("Invalid argument");
+ return QMI_CMD_EXIT;
+ }
+ s = strtok(s, ",");
+ if (!s) {
+ uqmi_add_error("No message id");
+ return QMI_CMD_EXIT;
+ }
+ id = strtoul(s, &s, 0);
+ if (s && *s) {
+ uqmi_add_error("Invalid message id");
+ return QMI_CMD_EXIT;
+ }
+ if (strcmp(strtok(arg, ","), "sim") == 0) {
+ } else if (strcmp(strtok(arg, ","), "me") == 0) {
+ qmi_set_ptr(&mreq, message_memory_storage_id.storage_type, QMI_WMS_STORAGE_TYPE_NV);
+ } else {
+ uqmi_add_error("Invalid value (sim or me)");
return QMI_CMD_EXIT;
}
diff --git a/uqmi/src/commands-wms.h b/uqmi/src/commands-wms.h
index e28b97b..d79acd6 100644
--- a/uqmi/src/commands-wms.h
+++ b/uqmi/src/commands-wms.h
@@ -20,7 +20,7 @@
*/
#define __uqmi_wms_commands \
- __uqmi_command(wms_list_messages, list-messages, no, QMI_SERVICE_WMS), \
+ __uqmi_command(wms_list_messages, list-messages, required, QMI_SERVICE_WMS), \
__uqmi_command(wms_delete_message, delete-message, required, QMI_SERVICE_WMS), \
__uqmi_command(wms_get_message, get-message, required, QMI_SERVICE_WMS), \
__uqmi_command(wms_get_raw_message, get-raw-message, required, QMI_SERVICE_WMS), \
@@ -30,10 +30,10 @@
__uqmi_command(wms_send_message, send-message, required, QMI_SERVICE_WMS)
#define wms_helptext \
- " --list-messages: List SMS messages\n" \
- " --delete-message <id>: Delete SMS message at index <id>\n" \
- " --get-message <id>: Get SMS message at index <id>\n" \
- " --get-raw-message <id>: Get SMS raw message contents at index <id>\n" \
+ " --list-messages <storage>: List SMS messages <storage> (sim or me)\n" \
+ " --delete-message <storage>,<id>: Delete SMS message at index\n" \
+ " --get-message <storage>,<id>: Get SMS message at index\n" \
+ " --get-raw-message <storage>,<id>: Get SMS raw message contents at index\n" \
" --send-message <data>: Send SMS message (use options below)\n" \
" --send-message-smsc <nr>: SMSC number\n" \
" --send-message-target <nr>: Destination number (required)\n" \
--
2.34.1
More information about the openwrt-devel
mailing list