+/*
+ * uqmi -- tiny QMI support implementation
+ *
+ * Copyright (C) 2014-2015 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ */
+
#include "qmi-message.h"
#define MIN(a,b) (((a)<(b))?(a):(b))
fprintf(stderr, " %02x", c);
dest += len;
if (*escape) {
+ *escape = false;
switch(c) {
case 0x0A:
*dest = 0x0C;
str++;
}
- return len;
+ return lower ? len : (len + 1);
}
static int
}
for (i = 0; str[i]; i++) {
- if (str[i] >= '0' || str[i] <= '9')
+ if (str[i] >= '0' && str[i] <= '9')
continue;
ascii = true;
dest[len++] = 0;
len += pdu_encode_7bit_str(&dest[len], str);
- dest[0] = len - 1;
+ dest[0] = strlen(str);
return len;
}
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;
}
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 */