[OpenWrt-Devel] [PATCH uqmi] Making smsc number optional

Sławomir Demeszko s.demeszko at wireless-instruments.com
Mon Dec 22 13:47:34 EST 2014


If smsc number is not provided before sending sms then
operator's default stored on simcard will be used.

Signed-off-by: Sławomir Demeszko <s.demeszko at wireless-instruments.com>
---
 commands-wms.c | 10 +++++++---
 commands-wms.h |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/commands-wms.c b/commands-wms.c
index 798e012..e3bcbc8 100644
--- a/commands-wms.c
+++ b/commands-wms.c
@@ -612,12 +612,12 @@ cmd_wms_send_message_prepare(struct qmi_dev *qmi, struct qmi_request *req, struc
 	unsigned char protocol_id = 0x00;
 	unsigned char dcs = 0x00;
 
-	if (!_send.smsc || !*_send.smsc || !_send.target || !*_send.target) {
+	if (!_send.target || !*_send.target) {
 		uqmi_add_error("Missing argument");
 		return QMI_CMD_EXIT;
 	}
 
-	if (strlen(_send.smsc) > 16 || strlen(_send.target) > 16 || strlen(arg) > 160) {
+	if ((_send.smsc && strlen(_send.smsc) > 16) || strlen(_send.target) > 16 || strlen(arg) > 160) {
 		uqmi_add_error("Argument too long");
 		return QMI_CMD_EXIT;
 	}
@@ -625,7 +625,11 @@ cmd_wms_send_message_prepare(struct qmi_dev *qmi, struct qmi_request *req, struc
 	if (_send.flash)
 		dcs |= 0x10;
 
-	cur += pdu_encode_number(cur, _send.smsc, true);
+	if (!_send.smsc || !*_send.smsc)
+		*(cur++) = 0;
+	else
+		cur += pdu_encode_number(cur, _send.smsc, true);
+
 	*(cur++) = first_octet;
 	*(cur++) = 0; /* reference */
 
diff --git a/commands-wms.h b/commands-wms.h
index 07191da..83e6614 100644
--- a/commands-wms.h
+++ b/commands-wms.h
@@ -14,7 +14,7 @@
 		"  --get-message <id>:               Get SMS message at index <id>\n" \
 		"  --get-raw-message <id>:           Get SMS raw message contents at index <id>\n" \
 		"  --send-message <data>:            Send SMS message (use options below)\n" \
-		"    --send-message-smsc <nr>:       SMSC number (required)\n" \
+		"    --send-message-smsc <nr>:       SMSC number\n" \
 		"    --send-message-target <nr>:     Destination number (required)\n" \
 		"    --send-message-flash:           Send as Flash SMS\n" \
 
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list