Re: [OpenWrt-Devel] [PATCH v2 00/25] ramips: massive code cleanups

2015-08-17 Thread Sławomir Demeszko

W dniu 17.08.2015 o 13:24, Piotr Dymacz pisze:
 It seems that there are some people who don't like the changes

Hi.

Don't bother that kind of people. There will be always someone who like mess. Cleanup is 
always good, especially for other people, who need to work with that code later. OpenWRT 
developers introduced some rules for patches due the same reason. Thanks for your work.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] i get no image for TL-WA7510

2015-08-13 Thread Sławomir Demeszko

W dniu 12.08.2015 o 21:29, smile...@gmail.com pisze:
 I miss not only the TL-WA7510 image. I missing also several images
 for other 4MB Flash-Router.

 Is there a Funktion in Openwrt which build images only if the image-size
 not excite the flash-size?

I found there is. I was also wonder for half day why image for my board was not 
created.
I think there should be at least a warning and option to bypass this check it would be 
helpful to estimate how many bytes we need to reclaim to fit.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] Fix missing dependencies for libuClibc++.so.0

2015-02-02 Thread Sławomir Demeszko
Compilation of packages written in C++, like smartmontools, unrar, etc.
fail with message:

Package smartmontools is missing dependencies for the following libraries:
libuClibc++.so.0

This is due unescaped ++ in argument for grep command.
---
 include/package-ipkg.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/package-ipkg.mk b/include/package-ipkg.mk
index 815aef0..b7dc0ad 100644
--- a/include/package-ipkg.mk
+++ b/include/package-ipkg.mk
@@ -66,7 +66,7 @@ ifneq ($(PKG_NAME),toolchain)
XARGS=$(XARGS); \
$(SCRIPT_DIR)/gen-dependencies.sh $$(IDIR_$(1)); \
) | while read FILE; do \
-   grep -qE ^FILE $(PKG_INFO_DIR)/$(1).provides 
|| \
+   grep -qxF FILE $(PKG_INFO_DIR)/$(1).provides || \
echo FILE  
$(PKG_INFO_DIR)/$(1).missing; \
done; \
if [ -f $(PKG_INFO_DIR)/$(1).missing ]; then \
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] Fix missing dependencies for libuClibc++.so.0

2015-02-02 Thread Sławomir Demeszko

On 02.02.2015 at 14:00, John Szakmeister wrote:

On Mon, Feb 2, 2015 at 6:24 AM, Sławomir Demeszko
s.demes...@wireless-instruments.com wrote:

Compilation of packages written in C++, like smartmontools, unrar, etc.
fail with message:

Package smartmontools is missing dependencies for the following libraries:
libuClibc++.so.0

This is due unescaped ++ in argument for grep command.

This may have been fixed by:

http://git.openwrt.org/?p=openwrt.git;a=commit;h=ff9be1ce29f457e018bbb64c7427ddcadcb93d5e


Yes, that fix works too, I didn't notice it. As side note -qxF is a bit better, it does 
not count \+ and few other characters preceded with backslash as special characters, but 
of course these combinations are rarely used in filenames.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] Fix missing dependencies for libuClibc++.so.0

2015-02-02 Thread Sławomir Demeszko

W dniu 02.02.2015 o 14:47, Sławomir Demeszko pisze:

On 02.02.2015 at 14:00, John Szakmeister wrote:

On Mon, Feb 2, 2015 at 6:24 AM, Sławomir Demeszko
s.demes...@wireless-instruments.com wrote:

Compilation of packages written in C++, like smartmontools, unrar, etc.
fail with message:

Package smartmontools is missing dependencies for the following libraries:
libuClibc++.so.0

This is due unescaped ++ in argument for grep command.

This may have been fixed by:
http://git.openwrt.org/?p=openwrt.git;a=commit;h=ff9be1ce29f457e018bbb64c7427ddcadcb93d5e


Yes, that fix works too, I didn't notice it. As side note -qxF is a bit better, it does 
not count \+ and few other characters preceded with backslash as special characters, 
but of course these combinations are rarely used in filenames.
I just tested and found that also a dot in filenames can be a problem. For example if we 
would have some.file.so then it matches also some2file.so and it could not detect 
missing dependency. So -qxF is a more than bit better.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] Fix possible fail to check for dependencies

2015-02-02 Thread Sławomir Demeszko
Few characters in filenames (a plus sign, a dot) can be interpreted
specially by grep. This can lead to the omission of missing package
dependency. For example if we would have some.file.so then it
matches also some2file.so. -F switch off special meaning
of any character and -x match against whole line.

Signed-off-by: Sławomir Demeszko s.demes...@wireless-instruments.com
---
 include/package-ipkg.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/package-ipkg.mk b/include/package-ipkg.mk
index 11edb9a..b7dc0ad 100644
--- a/include/package-ipkg.mk
+++ b/include/package-ipkg.mk
@@ -66,7 +66,7 @@ ifneq ($(PKG_NAME),toolchain)
XARGS=$(XARGS); \
$(SCRIPT_DIR)/gen-dependencies.sh $$(IDIR_$(1)); \
) | while read FILE; do \
-   grep -q ^FILE $(PKG_INFO_DIR)/$(1).provides 
|| \
+   grep -qxF FILE $(PKG_INFO_DIR)/$(1).provides || \
echo FILE  
$(PKG_INFO_DIR)/$(1).missing; \
done; \
if [ -f $(PKG_INFO_DIR)/$(1).missing ]; then \
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] Fix missing dependencies for libuClibc++.so.0

2015-02-02 Thread Sławomir Demeszko
I just updated working tree and created new patch Fix possible fail to check for 
dependencies:

https://patchwork.ozlabs.org/patch/435525/ This one can be cancelled.
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] network/znc: Package binaries appear to be broken by MIPS16

2015-01-20 Thread Sławomir Demeszko

19.01.2015 19:50, Oliver wrote:

I'll try 4.9 - out of interest, do you have any references to the bug in 4.8 
(C++ specific?)


Sorry, I do not remember where I read about that.
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] network/znc: Package binaries appear to be broken by MIPS16

2015-01-19 Thread Sławomir Demeszko

19.01.2015 at 09:04, Oliver wrote:
Having compiled an image yesterday with ZNC with a MIPS24kc target and MIPS16 enabled, I 
found that it would eventually crash after starting so I ran it in the console and found 
the segfault was due to an illegal hardware instruction - consequently I edited the 
Makefile to disable MIPS16 compilation for ZNC and reflashed it. This time there were no 
such issues. Can anyone else confirm this to be the case? Obviously it would be better 
if MIPS16 compilation could be fixed but I'm not able to get visibility into where the 
bad code is generated.
I remember there was a bug in gcc with version 4.8 and MIPS16 enabled, but I don't know if 
it was corrected. Did you tried other gcc versions: 4.6, 4.9?

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uqmi] Add command to specify preferred PLMN

2015-01-16 Thread Sławomir Demeszko
Signed-off-by: Sławomir Demeszko s.demes...@wireless-instruments.com
---
 commands-nas.c | 60 ++
 commands-nas.h |  6 ++
 2 files changed, 66 insertions(+)

diff --git a/commands-nas.c b/commands-nas.c
index 831e3f4..33477dd 100644
--- a/commands-nas.c
+++ b/commands-nas.c
@@ -1,6 +1,10 @@
 #include qmi-message.h
 
 static struct qmi_nas_set_system_selection_preference_request sel_req;
+static struct  {
+   bool mcc_is_set;
+   bool mnc_is_set;
+} plmn_code_flag;
 
 #define cmd_nas_do_set_system_selection_cb no_cb
 static enum qmi_cmd_result
@@ -99,6 +103,62 @@ cmd_nas_set_roaming_prepare(struct qmi_dev *qmi, struct 
qmi_request *req, struct
return do_sel_network();
 }
 
+#define cmd_nas_set_mcc_cb no_cb
+static enum qmi_cmd_result
+cmd_nas_set_mcc_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct 
qmi_msg *msg, char *arg)
+{
+   char *err;
+   int value = strtoul(arg, err, 10);
+   if (err  *err) {
+   uqmi_add_error(Invalid MCC value);
+   return QMI_CMD_EXIT;
+   }
+
+   sel_req.data.network_selection_preference.mcc = value;
+   plmn_code_flag.mcc_is_set = true;
+   return QMI_CMD_DONE;
+}
+
+#define cmd_nas_set_mnc_cb no_cb
+static enum qmi_cmd_result
+cmd_nas_set_mnc_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct 
qmi_msg *msg, char *arg)
+{
+   char *err;
+   int value = strtoul(arg, err, 10);
+   if (err  *err) {
+   uqmi_add_error(Invalid MNC value);
+   return QMI_CMD_EXIT;
+   }
+
+   sel_req.data.network_selection_preference.mnc = value;
+   plmn_code_flag.mnc_is_set = true;
+   return QMI_CMD_DONE;
+}
+
+#define cmd_nas_set_plmn_cb no_cb
+static enum qmi_cmd_result
+cmd_nas_set_plmn_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct 
qmi_msg *msg, char *arg)
+{
+   sel_req.set.network_selection_preference = 1;
+   sel_req.data.network_selection_preference.mode = 
QMI_NAS_NETWORK_SELECTION_PREFERENCE_AUTOMATIC;
+
+   if (!plmn_code_flag.mcc_is_set  plmn_code_flag.mnc_is_set) {
+   uqmi_add_error(No MCC value);
+   return QMI_CMD_EXIT;
+   }
+
+   if (plmn_code_flag.mcc_is_set  
sel_req.data.network_selection_preference.mcc) {
+   if (!plmn_code_flag.mnc_is_set) {
+   uqmi_add_error(No MNC value);
+   return QMI_CMD_EXIT;
+   } else {
+   sel_req.data.network_selection_preference.mode = 
QMI_NAS_NETWORK_SELECTION_PREFERENCE_MANUAL;
+   }
+   }
+
+   return do_sel_network();
+}
+
 #define cmd_nas_initiate_network_register_cb no_cb
 static enum qmi_cmd_result
 cmd_nas_initiate_network_register_prepare(struct qmi_dev *qmi, struct 
qmi_request *req, struct qmi_msg *msg, char *arg)
diff --git a/commands-nas.h b/commands-nas.h
index 4a4dace..d2bde7b 100644
--- a/commands-nas.h
+++ b/commands-nas.h
@@ -2,6 +2,9 @@
__uqmi_command(nas_do_set_system_selection, __set-system-selection, no, 
QMI_SERVICE_NAS), \
__uqmi_command(nas_set_network_modes, set-network-modes, required, 
CMD_TYPE_OPTION), \
__uqmi_command(nas_initiate_network_register, network-register, no, 
QMI_SERVICE_NAS), \
+   __uqmi_command(nas_set_plmn, set-plmn, no, QMI_SERVICE_NAS), \
+   __uqmi_command(nas_set_mcc, mcc, required, CMD_TYPE_OPTION), \
+   __uqmi_command(nas_set_mnc, mnc, required, CMD_TYPE_OPTION), \
__uqmi_command(nas_network_scan, network-scan, no, QMI_SERVICE_NAS), \
__uqmi_command(nas_get_signal_info, get-signal-info, no, 
QMI_SERVICE_NAS), \
__uqmi_command(nas_get_serving_system, get-serving-system, no, 
QMI_SERVICE_NAS), \
@@ -17,6 +20,9 @@
Available modes: any, off, 
only\n \
  --network-scan:   Initiate network scan\n \
  --network-register:   Initiate network 
register\n \
+ --set-plmn:   Register at specified 
network\n \
+   --mcc mcc:Mobile Country Code (0 - 
auto)\n \
+   --mnc mnc:Mobile Network Code\n \
  --get-signal-info:Get signal strength 
info\n \
  --get-serving-system: Get serving system info\n 
\
 
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v2 uqmi] Add command for listing device capabilities

2015-01-08 Thread Sławomir Demeszko
Signed-off-by: Sławomir Demeszko s.demes...@wireless-instruments.com
---

Sorry, it seems my compiler doesn't suport -Wtautological-compare option,
and I was not warned about this. This condition could be removed, but
as I read it is unspecified if enums are signed or unsigned, it depends
on compiler, so I cast it to signed for comparison. I can't test it,
but should get rid of the warning.

 commands-dms.c | 53 +
 commands-dms.h |  2 ++
 2 files changed, 55 insertions(+)

diff --git a/commands-dms.c b/commands-dms.c
index a677052..563b6d9 100644
--- a/commands-dms.c
+++ b/commands-dms.c
@@ -7,6 +7,59 @@ static struct {
char* puk;
 } dms_req_data;
 
+static void cmd_dms_get_capabilities_cb(struct qmi_dev *qmi, struct 
qmi_request *req, struct qmi_msg *msg)
+{
+   void *t, *networks;
+   int i;
+   struct qmi_dms_get_capabilities_response res;
+   const char *radio_cap[] = {
+   [QMI_DMS_RADIO_INTERFACE_CDMA20001X] = cdma1x,
+   [QMI_DMS_RADIO_INTERFACE_EVDO] = cdma1xevdo,
+   [QMI_DMS_RADIO_INTERFACE_GSM] = gsm,
+   [QMI_DMS_RADIO_INTERFACE_UMTS] = umts,
+   [QMI_DMS_RADIO_INTERFACE_LTE] = lte,
+   };
+   const char *service_cap[] = {
+   [QMI_DMS_DATA_SERVICE_CAPABILITY_NONE] = none,
+   [QMI_DMS_DATA_SERVICE_CAPABILITY_CS] = cs,
+   [QMI_DMS_DATA_SERVICE_CAPABILITY_PS] = ps,
+   [QMI_DMS_DATA_SERVICE_CAPABILITY_SIMULTANEOUS_CS_PS] = 
simultaneous_cs_ps,
+   [QMI_DMS_DATA_SERVICE_CAPABILITY_NON_SIMULTANEOUS_CS_PS] = 
non_simultaneous_cs_ps,
+   };
+
+   qmi_parse_dms_get_capabilities_response(msg, res);
+
+   t = blobmsg_open_table(status, NULL);
+
+   blobmsg_add_u32(status, max_tx_channel_rate, (int32_t) 
res.data.info.max_tx_channel_rate);
+   blobmsg_add_u32(status, max_rx_channel_rate, (int32_t) 
res.data.info.max_rx_channel_rate);
+   if ((int)res.data.info.data_service_capability = 0  
res.data.info.data_service_capability  ARRAY_SIZE(service_cap))
+   blobmsg_add_string(status, data_service, 
service_cap[res.data.info.data_service_capability]);
+
+   if(res.data.info.sim_capability == QMI_DMS_SIM_CAPABILITY_NOT_SUPPORTED)
+   blobmsg_add_string(status, sim, not supported);
+   else if(res.data.info.sim_capability == 
QMI_DMS_SIM_CAPABILITY_SUPPORTED)
+   blobmsg_add_string(status, sim, supported);
+
+   networks = blobmsg_open_array(status, networks);
+   for (i = 0; i  res.data.info.radio_interface_list_n; i++) {
+   if ((int)res.data.info.radio_interface_list[i] = 0  
res.data.info.radio_interface_list[i]  ARRAY_SIZE(radio_cap))
+   blobmsg_add_string(status, NULL, 
radio_cap[res.data.info.radio_interface_list[i]]);
+   else
+   blobmsg_add_string(status, NULL, unknown);
+   }
+   blobmsg_close_array(status, networks);
+
+   blobmsg_close_table(status, t);
+}
+
+static enum qmi_cmd_result
+cmd_dms_get_capabilities_prepare(struct qmi_dev *qmi, struct qmi_request *req, 
struct qmi_msg *msg, char *arg)
+{
+   qmi_set_dms_get_capabilities_request(msg);
+   return QMI_CMD_REQUEST;
+}
+
 static const char *get_pin_status(int status)
 {
static const char *pin_status[] = {
diff --git a/commands-dms.h b/commands-dms.h
index 925aea3..a370425 100644
--- a/commands-dms.h
+++ b/commands-dms.h
@@ -1,4 +1,5 @@
 #define __uqmi_dms_commands
\
+   __uqmi_command(dms_get_capabilities, get-capabilities, no, 
QMI_SERVICE_DMS), \
__uqmi_command(dms_get_pin_status, get-pin-status, no, 
QMI_SERVICE_DMS), \
__uqmi_command(dms_verify_pin1, verify-pin1, required, 
QMI_SERVICE_DMS), \
__uqmi_command(dms_verify_pin2, verify-pin2, required, 
QMI_SERVICE_DMS), \
@@ -18,6 +19,7 @@
__uqmi_command(dms_reset, reset-dms, no, QMI_SERVICE_DMS) \
 
 #define dms_helptext \
+ --get-capabilities:   List device 
capabilities\n \
  --get-pin-status: Get PIN verification 
status\n \
  --verify-pin1 pin:  Verify PIN1\n \
  --verify-pin2 pin:  Verify PIN2\n \
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uqmi] Add missing option for getting tdma signal strength

2015-01-08 Thread Sławomir Demeszko
Signed-off-by: Sławomir Demeszko s.demes...@wireless-instruments.com
---
 commands-nas.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/commands-nas.c b/commands-nas.c
index be06ee4..831e3f4 100644
--- a/commands-nas.c
+++ b/commands-nas.c
@@ -152,6 +152,11 @@ cmd_nas_get_signal_info_cb(struct qmi_dev *qmi, struct 
qmi_request *req, struct
blobmsg_add_u32(status, snr, (int32_t) 
res.data.lte_signal_strength.snr);
}
 
+   if (res.set.tdma_signal_strength) {
+   blobmsg_add_string(status, type, tdma);
+   blobmsg_add_u32(status, signal, (int32_t) 
res.data.tdma_signal_strength);
+   }
+
blobmsg_close_table(status, c);
 }
 
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uqmi] Add command for listing device capabilities

2015-01-08 Thread Sławomir Demeszko
Signed-off-by: Sławomir Demeszko s.demes...@wireless-instruments.com
---
 commands-dms.c | 53 +
 commands-dms.h |  2 ++
 2 files changed, 55 insertions(+)

diff --git a/commands-dms.c b/commands-dms.c
index a677052..fcb4b93 100644
--- a/commands-dms.c
+++ b/commands-dms.c
@@ -7,6 +7,59 @@ static struct {
char* puk;
 } dms_req_data;
 
+static void cmd_dms_get_capabilities_cb(struct qmi_dev *qmi, struct 
qmi_request *req, struct qmi_msg *msg)
+{
+   void *t, *networks;
+   int i;
+   struct qmi_dms_get_capabilities_response res;
+   const char *radio_cap[] = {
+   [QMI_DMS_RADIO_INTERFACE_CDMA20001X] = cdma1x,
+   [QMI_DMS_RADIO_INTERFACE_EVDO] = cdma1xevdo,
+   [QMI_DMS_RADIO_INTERFACE_GSM] = gsm,
+   [QMI_DMS_RADIO_INTERFACE_UMTS] = umts,
+   [QMI_DMS_RADIO_INTERFACE_LTE] = lte,
+   };
+   const char *service_cap[] = {
+   [QMI_DMS_DATA_SERVICE_CAPABILITY_NONE] = none,
+   [QMI_DMS_DATA_SERVICE_CAPABILITY_CS] = cs,
+   [QMI_DMS_DATA_SERVICE_CAPABILITY_PS] = ps,
+   [QMI_DMS_DATA_SERVICE_CAPABILITY_SIMULTANEOUS_CS_PS] = 
simultaneous_cs_ps,
+   [QMI_DMS_DATA_SERVICE_CAPABILITY_NON_SIMULTANEOUS_CS_PS] = 
non_simultaneous_cs_ps,
+   };
+
+   qmi_parse_dms_get_capabilities_response(msg, res);
+
+   t = blobmsg_open_table(status, NULL);
+
+   blobmsg_add_u32(status, max_tx_channel_rate, (int32_t) 
res.data.info.max_tx_channel_rate);
+   blobmsg_add_u32(status, max_rx_channel_rate, (int32_t) 
res.data.info.max_rx_channel_rate);
+   if (res.data.info.data_service_capability = 0  
res.data.info.data_service_capability  ARRAY_SIZE(service_cap))
+   blobmsg_add_string(status, data_service, 
service_cap[res.data.info.data_service_capability]);
+
+   if(res.data.info.sim_capability == QMI_DMS_SIM_CAPABILITY_NOT_SUPPORTED)
+   blobmsg_add_string(status, sim, not supported);
+   else if(res.data.info.sim_capability == 
QMI_DMS_SIM_CAPABILITY_SUPPORTED)
+   blobmsg_add_string(status, sim, supported);
+
+   networks = blobmsg_open_array(status, networks);
+   for (i = 0; i  res.data.info.radio_interface_list_n; i++) {
+   if (res.data.info.radio_interface_list[i] = 0  
res.data.info.radio_interface_list[i]  ARRAY_SIZE(radio_cap))
+   blobmsg_add_string(status, NULL, 
radio_cap[res.data.info.radio_interface_list[i]]);
+   else
+   blobmsg_add_string(status, NULL, unknown);
+   }
+   blobmsg_close_array(status, networks);
+
+   blobmsg_close_table(status, t);
+}
+
+static enum qmi_cmd_result
+cmd_dms_get_capabilities_prepare(struct qmi_dev *qmi, struct qmi_request *req, 
struct qmi_msg *msg, char *arg)
+{
+   qmi_set_dms_get_capabilities_request(msg);
+   return QMI_CMD_REQUEST;
+}
+
 static const char *get_pin_status(int status)
 {
static const char *pin_status[] = {
diff --git a/commands-dms.h b/commands-dms.h
index 925aea3..a370425 100644
--- a/commands-dms.h
+++ b/commands-dms.h
@@ -1,4 +1,5 @@
 #define __uqmi_dms_commands
\
+   __uqmi_command(dms_get_capabilities, get-capabilities, no, 
QMI_SERVICE_DMS), \
__uqmi_command(dms_get_pin_status, get-pin-status, no, 
QMI_SERVICE_DMS), \
__uqmi_command(dms_verify_pin1, verify-pin1, required, 
QMI_SERVICE_DMS), \
__uqmi_command(dms_verify_pin2, verify-pin2, required, 
QMI_SERVICE_DMS), \
@@ -18,6 +19,7 @@
__uqmi_command(dms_reset, reset-dms, no, QMI_SERVICE_DMS) \
 
 #define dms_helptext \
+ --get-capabilities:   List device 
capabilities\n \
  --get-pin-status: Get PIN verification 
status\n \
  --verify-pin1 pin:  Verify PIN1\n \
  --verify-pin2 pin:  Verify PIN2\n \
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uqmi] Fix logical expression which is always true

2014-12-22 Thread Sławomir Demeszko
Signed-off-by: Sławomir Demeszko s.demes...@wireless-instruments.com
---
 commands-wms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/commands-wms.c b/commands-wms.c
index 02874f0..1b4373f 100644
--- a/commands-wms.c
+++ b/commands-wms.c
@@ -560,7 +560,7 @@ pdu_encode_number(unsigned char *dest, const char *str, 
bool smsc)
}
 
for (i = 0; str[i]; i++) {
-   if (str[i] = '0' || str[i] = '9')
+   if (str[i] = '0'  str[i] = '9')
continue;
 
ascii = true;
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uqmi] Fix improper length of sms message stored in User Data Length field

2014-12-22 Thread Sławomir Demeszko
Signed-off-by: Sławomir Demeszko s.demes...@wireless-instruments.com
---
 commands-wms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/commands-wms.c b/commands-wms.c
index 1b4373f..798e012 100644
--- a/commands-wms.c
+++ b/commands-wms.c
@@ -591,7 +591,7 @@ pdu_encode_data(unsigned char *dest, const char *str)
 
dest[len++] = 0;
len += pdu_encode_7bit_str(dest[len], str);
-   dest[0] = len - 1;
+   dest[0] = strlen(str);
 
return len;
 }
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


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

2014-12-22 Thread Sławomir Demeszko
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.demes...@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@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uqmi] Fix encoding phone number on sending sms

2014-12-18 Thread Sławomir Demeszko
Return proper length of encoded phone number with odd count of digits,
without this patch number is encoded in memory but length returned
by function is not incremented and sms cannot be send.

Signed-off-by: Sławomir Demeszko s.demes...@wireless-instruments.com
---
 commands-wms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/commands-wms.c b/commands-wms.c
index b85cd70..02874f0 100644
--- a/commands-wms.c
+++ b/commands-wms.c
@@ -512,7 +512,7 @@ pdu_encode_semioctet(unsigned char *dest, const char *str)
str++;
}
 
-   return len;
+   return lower ? len : (len + 1);
 }
 
 static int
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uqmi 1/3] Added option for enabling and disabling protection of simcard by PIN

2014-12-17 Thread Sławomir Demeszko
Signed-off-by: Sławomir Demeszko s.demes...@wireless-instruments.com
---
 commands-dms.c | 53 +
 commands-dms.h |  7 +++
 2 files changed, 60 insertions(+)

diff --git a/commands-dms.c b/commands-dms.c
index ad5c89d..360e926 100644
--- a/commands-dms.c
+++ b/commands-dms.c
@@ -75,6 +75,59 @@ cmd_dms_verify_pin2_prepare(struct qmi_dev *qmi, struct 
qmi_request *req, struct
return QMI_CMD_REQUEST;
 }
 
+static struct qmi_dms_uim_set_pin_protection_request dms_pin_protection_req = {
+   QMI_INIT_SEQUENCE(info,
+   .pin_id = QMI_DMS_UIM_PIN_ID_PIN
+   )
+   };
+
+#define cmd_dms_set_pin_cb no_cb
+static enum qmi_cmd_result
+cmd_dms_set_pin_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct 
qmi_msg *msg, char *arg)
+{
+   qmi_set_ptr(dms_pin_protection_req, info.pin, arg);
+   return QMI_CMD_DONE;
+}
+
+static enum qmi_cmd_result
+cmd_dms_set_pin_protection_prepare(struct qmi_msg *msg, char *arg)
+{
+   if (!dms_pin_protection_req.data.info.pin) {
+   uqmi_add_error(Missing argument);
+   return QMI_CMD_EXIT;
+   }
+
+   int is_enabled;
+   if (strcasecmp(arg, disabled) == 0)
+   is_enabled = false;
+   else if (strcasecmp(arg, enabled) == 0)
+   is_enabled = true;
+   else {
+   uqmi_add_error(Invalid value (valid: disabled, enabled));
+   return QMI_CMD_EXIT;
+   }
+
+   qmi_set_ptr(dms_pin_protection_req, info.protection_enabled, 
is_enabled);
+   qmi_set_dms_uim_set_pin_protection_request(msg, 
dms_pin_protection_req);
+   return QMI_CMD_REQUEST;
+}
+
+#define cmd_dms_set_pin1_protection_cb no_cb
+static enum qmi_cmd_result
+cmd_dms_set_pin1_protection_prepare(struct qmi_dev *qmi, struct qmi_request 
*req, struct qmi_msg *msg, char *arg)
+{
+   qmi_set_ptr(dms_pin_protection_req, info.pin_id, 
QMI_DMS_UIM_PIN_ID_PIN);
+   return cmd_dms_set_pin_protection_prepare(msg, arg);
+}
+
+#define cmd_dms_set_pin2_protection_cb no_cb
+static enum qmi_cmd_result
+cmd_dms_set_pin2_protection_prepare(struct qmi_dev *qmi, struct qmi_request 
*req, struct qmi_msg *msg, char *arg)
+{
+   qmi_set_ptr(dms_pin_protection_req, info.pin_id, 
QMI_DMS_UIM_PIN_ID_PIN2);
+   return cmd_dms_set_pin_protection_prepare(msg, arg);
+}
+
 static struct qmi_dms_uim_unblock_pin_request dms_unlock_pin_req = {
QMI_INIT_SEQUENCE(info,
.pin_id = QMI_DMS_UIM_PIN_ID_PIN
diff --git a/commands-dms.h b/commands-dms.h
index 703b9f7..e214975 100644
--- a/commands-dms.h
+++ b/commands-dms.h
@@ -2,6 +2,9 @@
__uqmi_command(dms_get_pin_status, get-pin-status, no, 
QMI_SERVICE_DMS), \
__uqmi_command(dms_verify_pin1, verify-pin1, required, 
QMI_SERVICE_DMS), \
__uqmi_command(dms_verify_pin2, verify-pin2, required, 
QMI_SERVICE_DMS), \
+   __uqmi_command(dms_set_pin1_protection, set-pin1-protection, required, 
QMI_SERVICE_DMS), \
+   __uqmi_command(dms_set_pin2_protection, set-pin2-protection, required, 
QMI_SERVICE_DMS), \
+   __uqmi_command(dms_set_pin, pin, required, CMD_TYPE_OPTION), \
__uqmi_command(dms_unblock_pin1, unblock-pin1, no, QMI_SERVICE_DMS), \
__uqmi_command(dms_unblock_pin2, unblock-pin2, no, QMI_SERVICE_DMS), \
__uqmi_command(dms_set_puk, puk, required, CMD_TYPE_OPTION), \
@@ -16,6 +19,10 @@
  --get-pin-status: Get PIN verification 
status\n \
  --verify-pin1 pin:  Verify PIN1\n \
  --verify-pin2 pin:  Verify PIN2\n \
+ --set-pin1-protection state:Set PIN1 protection state 
(disabled, enabled)\n \
+   --pin pin:PIN1 needed to change 
state\n \
+ --set-pin2-protection state:Set PIN2 protection state 
(disabled, enabled)\n \
+   --pin pin2:   PIN2 needed to change 
state\n \
  --unblock-pin1:   Unblock PIN1\n \
--puk puk:PUK needed to unblock\n \
--new-pin new pin:New pin\n \
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uqmi 3/3] Added commands to change PIN code

2014-12-17 Thread Sławomir Demeszko
Signed-off-by: Sławomir Demeszko s.demes...@wireless-instruments.com
---
 commands-dms.c | 36 
 commands-dms.h |  8 
 2 files changed, 44 insertions(+)

diff --git a/commands-dms.c b/commands-dms.c
index 76144cf..277223d 100644
--- a/commands-dms.c
+++ b/commands-dms.c
@@ -136,6 +136,42 @@ cmd_dms_set_pin2_protection_prepare(struct qmi_dev *qmi, 
struct qmi_request *req
return cmd_dms_set_pin_protection_prepare(msg, arg);
 }
 
+static enum qmi_cmd_result
+cmd_dms_change_pin_prepare(struct qmi_msg *msg, char *arg)
+{
+   if (!dms_req_data.pin || !dms_req_data.new_pin) {
+   uqmi_add_error(Missing argument);
+   return QMI_CMD_EXIT;
+   }
+
+   static struct qmi_dms_uim_change_pin_request dms_change_pin_req = {
+   QMI_INIT_SEQUENCE(info,
+   .pin_id = dms_req_data.pin_id
+   ),
+   QMI_INIT_PTR(info.old_pin, dms_req_data.pin),
+   QMI_INIT_PTR(info.new_pin, dms_req_data.new_pin)
+   };
+
+   qmi_set_dms_uim_change_pin_request(msg, dms_change_pin_req);
+   return QMI_CMD_REQUEST;
+}
+
+#define cmd_dms_change_pin1_cb no_cb
+static enum qmi_cmd_result
+cmd_dms_change_pin1_prepare(struct qmi_dev *qmi, struct qmi_request *req, 
struct qmi_msg *msg, char *arg)
+{
+   dms_req_data.pin_id = QMI_DMS_UIM_PIN_ID_PIN;
+   return cmd_dms_change_pin_prepare(msg, arg);
+}
+
+#define cmd_dms_change_pin2_cb no_cb
+static enum qmi_cmd_result
+cmd_dms_change_pin2_prepare(struct qmi_dev *qmi, struct qmi_request *req, 
struct qmi_msg *msg, char *arg)
+{
+   dms_req_data.pin_id = QMI_DMS_UIM_PIN_ID_PIN2;
+   return cmd_dms_change_pin_prepare(msg, arg);
+}
+
 #define cmd_dms_set_new_pin_cb no_cb
 static enum qmi_cmd_result
 cmd_dms_set_new_pin_prepare(struct qmi_dev *qmi, struct qmi_request *req, 
struct qmi_msg *msg, char *arg)
diff --git a/commands-dms.h b/commands-dms.h
index e214975..925aea3 100644
--- a/commands-dms.h
+++ b/commands-dms.h
@@ -5,6 +5,8 @@
__uqmi_command(dms_set_pin1_protection, set-pin1-protection, required, 
QMI_SERVICE_DMS), \
__uqmi_command(dms_set_pin2_protection, set-pin2-protection, required, 
QMI_SERVICE_DMS), \
__uqmi_command(dms_set_pin, pin, required, CMD_TYPE_OPTION), \
+   __uqmi_command(dms_change_pin1, change-pin1, no, QMI_SERVICE_DMS), \
+   __uqmi_command(dms_change_pin2, change-pin2, no, QMI_SERVICE_DMS), \
__uqmi_command(dms_unblock_pin1, unblock-pin1, no, QMI_SERVICE_DMS), \
__uqmi_command(dms_unblock_pin2, unblock-pin2, no, QMI_SERVICE_DMS), \
__uqmi_command(dms_set_puk, puk, required, CMD_TYPE_OPTION), \
@@ -23,6 +25,12 @@
--pin pin:PIN1 needed to change 
state\n \
  --set-pin2-protection state:Set PIN2 protection state 
(disabled, enabled)\n \
--pin pin2:   PIN2 needed to change 
state\n \
+ --change-pin1:Change PIN1\n \
+   --pin old pin:Current PIN1\n \
+   --new-pin new pin:New pin\n \
+ --change-pin2:Change PIN2\n \
+   --pin old pin:Current PIN2\n \
+   --new-pin new pin:New pin\n \
  --unblock-pin1:   Unblock PIN1\n \
--puk puk:PUK needed to unblock\n \
--new-pin new pin:New pin\n \
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uqmi 2/3] Added shared struct to allow the same option names for different functions

2014-12-17 Thread Sławomir Demeszko
For example we can use one option --new-pin with commands unblock-pin
and with change-pin, without that we need to invent new name
for every new command.

Signed-off-by: Sławomir Demeszko s.demes...@wireless-instruments.com
---
 commands-dms.c | 64 +++---
 1 file changed, 39 insertions(+), 25 deletions(-)

diff --git a/commands-dms.c b/commands-dms.c
index 360e926..76144cf 100644
--- a/commands-dms.c
+++ b/commands-dms.c
@@ -1,5 +1,12 @@
 #include qmi-message.h
 
+static struct {
+   QmiDmsUimPinId pin_id;
+   char* pin;
+   char* new_pin;
+   char* puk;
+} dms_req_data;
+
 static const char *get_pin_status(int status)
 {
static const char *pin_status[] = {
@@ -75,24 +82,18 @@ cmd_dms_verify_pin2_prepare(struct qmi_dev *qmi, struct 
qmi_request *req, struct
return QMI_CMD_REQUEST;
 }
 
-static struct qmi_dms_uim_set_pin_protection_request dms_pin_protection_req = {
-   QMI_INIT_SEQUENCE(info,
-   .pin_id = QMI_DMS_UIM_PIN_ID_PIN
-   )
-   };
-
 #define cmd_dms_set_pin_cb no_cb
 static enum qmi_cmd_result
 cmd_dms_set_pin_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct 
qmi_msg *msg, char *arg)
 {
-   qmi_set_ptr(dms_pin_protection_req, info.pin, arg);
+   dms_req_data.pin = arg;
return QMI_CMD_DONE;
 }
 
 static enum qmi_cmd_result
 cmd_dms_set_pin_protection_prepare(struct qmi_msg *msg, char *arg)
 {
-   if (!dms_pin_protection_req.data.info.pin) {
+   if (!dms_req_data.pin) {
uqmi_add_error(Missing argument);
return QMI_CMD_EXIT;
}
@@ -107,7 +108,14 @@ cmd_dms_set_pin_protection_prepare(struct qmi_msg *msg, 
char *arg)
return QMI_CMD_EXIT;
}
 
-   qmi_set_ptr(dms_pin_protection_req, info.protection_enabled, 
is_enabled);
+   struct qmi_dms_uim_set_pin_protection_request dms_pin_protection_req = {
+   QMI_INIT_SEQUENCE(info,
+   .pin_id = dms_req_data.pin_id
+   ),
+   QMI_INIT_PTR(info.pin, dms_req_data.pin),
+   QMI_INIT_PTR(info.protection_enabled, is_enabled)
+   };
+
qmi_set_dms_uim_set_pin_protection_request(msg, 
dms_pin_protection_req);
return QMI_CMD_REQUEST;
 }
@@ -116,7 +124,7 @@ cmd_dms_set_pin_protection_prepare(struct qmi_msg *msg, 
char *arg)
 static enum qmi_cmd_result
 cmd_dms_set_pin1_protection_prepare(struct qmi_dev *qmi, struct qmi_request 
*req, struct qmi_msg *msg, char *arg)
 {
-   qmi_set_ptr(dms_pin_protection_req, info.pin_id, 
QMI_DMS_UIM_PIN_ID_PIN);
+   dms_req_data.pin_id = QMI_DMS_UIM_PIN_ID_PIN;
return cmd_dms_set_pin_protection_prepare(msg, arg);
 }
 
@@ -124,21 +132,15 @@ cmd_dms_set_pin1_protection_prepare(struct qmi_dev *qmi, 
struct qmi_request *req
 static enum qmi_cmd_result
 cmd_dms_set_pin2_protection_prepare(struct qmi_dev *qmi, struct qmi_request 
*req, struct qmi_msg *msg, char *arg)
 {
-   qmi_set_ptr(dms_pin_protection_req, info.pin_id, 
QMI_DMS_UIM_PIN_ID_PIN2);
+   dms_req_data.pin_id = QMI_DMS_UIM_PIN_ID_PIN2;
return cmd_dms_set_pin_protection_prepare(msg, arg);
 }
 
-static struct qmi_dms_uim_unblock_pin_request dms_unlock_pin_req = {
-   QMI_INIT_SEQUENCE(info,
-   .pin_id = QMI_DMS_UIM_PIN_ID_PIN
-   )
-   };
-
 #define cmd_dms_set_new_pin_cb no_cb
 static enum qmi_cmd_result
 cmd_dms_set_new_pin_prepare(struct qmi_dev *qmi, struct qmi_request *req, 
struct qmi_msg *msg, char *arg)
 {
-   qmi_set_ptr(dms_unlock_pin_req, info.new_pin, arg);
+   dms_req_data.new_pin = arg;
return QMI_CMD_DONE;
 }
 
@@ -146,7 +148,7 @@ cmd_dms_set_new_pin_prepare(struct qmi_dev *qmi, struct 
qmi_request *req, struct
 static enum qmi_cmd_result
 cmd_dms_set_puk_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct 
qmi_msg *msg, char *arg)
 {
-   qmi_set_ptr(dms_unlock_pin_req, info.puk, arg);
+   dms_req_data.puk = arg;
return QMI_CMD_DONE;
 }
 
@@ -154,13 +156,19 @@ cmd_dms_set_puk_prepare(struct qmi_dev *qmi, struct 
qmi_request *req, struct qmi
 static enum qmi_cmd_result
 cmd_dms_unblock_pin1_prepare(struct qmi_dev *qmi, struct qmi_request *req, 
struct qmi_msg *msg, char *arg)
 {
-   qmi_set_ptr(dms_unlock_pin_req, info.pin_id, QMI_DMS_UIM_PIN_ID_PIN);
-
-   if (!dms_unlock_pin_req.data.info.puk || 
!dms_unlock_pin_req.data.info.new_pin) {
+   if (!dms_req_data.puk || !dms_req_data.new_pin) {
uqmi_add_error(Missing argument);
return QMI_CMD_EXIT;
}
 
+   struct qmi_dms_uim_unblock_pin_request dms_unlock_pin_req = {
+   QMI_INIT_SEQUENCE(info,
+   .pin_id = QMI_DMS_UIM_PIN_ID_PIN
+   ),
+   QMI_INIT_PTR(info.puk, dms_req_data.puk),
+   QMI_INIT_PTR(info.new_pin, dms_req_data.new_pin

[OpenWrt-Devel] [PATCH uqmi] Add support for 16-bit reference number in concatenated SMS.

2014-12-17 Thread Sławomir Demeszko
Signed-off-by: Sławomir Demeszko s.demes...@wireless-instruments.com
---
 commands-wms.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/commands-wms.c b/commands-wms.c
index 47d4d76..6ac52eb 100644
--- a/commands-wms.c
+++ b/commands-wms.c
@@ -179,11 +179,16 @@ static int decode_udh(const unsigned char *data)
break;
 
switch (type) {
-   case 0:
+   case 0x00:
blobmsg_add_u32(status, concat_ref, (uint32_t) 
val[0]);
blobmsg_add_u32(status, concat_part, (uint32_t) 
val[2]);
blobmsg_add_u32(status, concat_parts, (uint32_t) 
val[1]);
break;
+   case 0x08:
+   blobmsg_add_u32(status, concat_ref, (uint32_t) 
(val[0]  8 | val[1]));
+   blobmsg_add_u32(status, concat_part, (uint32_t) 
val[3]);
+   blobmsg_add_u32(status, concat_parts, (uint32_t) 
val[2]);
+   break;
default:
break;
}
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uqmi] Add mandatory field to Initiate Network Register

2014-12-17 Thread Sławomir Demeszko
According to json data Action field in Initiate Network Register
is mandatory. I get Missing argument from qmi without it.

Signed-off-by: Sławomir Demeszko s.demes...@wireless-instruments.com
---
 commands-nas.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/commands-nas.c b/commands-nas.c
index ccc58ab..7c433ed 100644
--- a/commands-nas.c
+++ b/commands-nas.c
@@ -103,7 +103,10 @@ cmd_nas_set_roaming_prepare(struct qmi_dev *qmi, struct 
qmi_request *req, struct
 static enum qmi_cmd_result
 cmd_nas_initiate_network_register_prepare(struct qmi_dev *qmi, struct 
qmi_request *req, struct qmi_msg *msg, char *arg)
 {
-   static struct qmi_nas_initiate_network_register_request register_req;
+   static struct qmi_nas_initiate_network_register_request register_req = {
+   QMI_INIT(action, 
QMI_NAS_NETWORK_REGISTER_TYPE_AUTOMATIC)
+   };
+
qmi_set_nas_initiate_network_register_request(msg, register_req);
return QMI_CMD_REQUEST;
 }
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uqmi 1/2] Separation of decoding User Data Header from decoding 7 bit message

2014-12-08 Thread Sławomir Demeszko
It is preparation for supporting 8 bit and 16 bit encoding. Moving out
this code from decode_7bit_field() allows to reuse it in caller
function where other than 7 bit decoding will take place.

Signed-off-by: Sławomir Demeszko s.demes...@wireless-instruments.com
---
 commands-wms.c | 48 +++-
 1 file changed, 23 insertions(+), 25 deletions(-)

diff --git a/commands-wms.c b/commands-wms.c
index 5f159ce..9760d85 100644
--- a/commands-wms.c
+++ b/commands-wms.c
@@ -158,13 +158,13 @@ pdu_decode_7bit_str(char *dest, const unsigned char 
*data, int data_len, int bit
return len;
 }
 
-static void decode_udh(const unsigned char *data)
+static int decode_udh(const unsigned char *data)
 {
const unsigned char *end;
-   unsigned int type, len;
+   unsigned int type, len, udh_len;
 
-   len = *(data++);
-   end = data + len;
+   udh_len = *(data++);
+   end = data + udh_len;
while (data  end) {
const unsigned char *val;
 
@@ -185,29 +185,15 @@ static void decode_udh(const unsigned char *data)
break;
}
}
+
+   return udh_len + 1;
 }
 
-static void decode_7bit_field(char *name, const unsigned char *data, int 
data_len, bool udh)
+static void decode_7bit_field(char *name, const unsigned char *data, int 
data_len, int bit_offset)
 {
-   const unsigned char *udh_start;
-   char *dest;
-   int pos_offset = 0;
-
-   if (udh) {
-   int len = data[0] + 1;
-
-   udh_start = data;
-   data += len;
-   data_len -= len;
-   pos_offset = len % 7;
-   }
-
-   dest = blobmsg_alloc_string_buffer(status, name, 3 * (data_len * 8 / 
7) + 2);
-   pdu_decode_7bit_str(dest, data, data_len, pos_offset);
+   char *dest = blobmsg_alloc_string_buffer(status, name, 3 * (data_len * 
8 / 7) + 2);
+   pdu_decode_7bit_str(dest, data, data_len, bit_offset);
blobmsg_add_string_buffer(status);
-
-   if (udh)
-   decode_udh(udh_start);
 }
 
 static char *pdu_add_semioctet(char *str, char val)
@@ -375,8 +361,20 @@ static void cmd_wms_get_message_cb(struct qmi_dev *qmi, 
struct qmi_request *req,
data += 7;
}
 
-   cur_len = *(data++);
-   decode_7bit_field(text, data, end - data, !!(first  0x40));
+   data++;
+   int bit_offset = 0;
+
+   /* User Data Header */
+   if (first  0x40) {
+   int udh_len = decode_udh(data);
+   data += udh_len;
+   bit_offset = udh_len % 7;
+   }
+
+   if (data = end)
+   goto error;
+
+   decode_7bit_field(text, data, end - data, bit_offset);
blobmsg_close_table(status, c);
 
return;
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uqmi 2/2] Added support for 8 bit and 16 bit encoded SMS messages

2014-12-08 Thread Sławomir Demeszko
Message is presented as string of hexadecimal pairs in JSON output.

Signed-off-by: Sławomir Demeszko s.demes...@wireless-instruments.com
---
 commands-wms.c | 32 ++--
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/commands-wms.c b/commands-wms.c
index 9760d85..74f50aa 100644
--- a/commands-wms.c
+++ b/commands-wms.c
@@ -239,6 +239,15 @@ static void wms_decode_address(char *name, unsigned char 
*data, int len)
blobmsg_add_string_buffer(status);
 }
 
+static void blobmsg_add_hex(struct blob_buf *buf, const char *name, unsigned 
const char *data, int len)
+{
+   char* str = blobmsg_alloc_string_buffer(buf, name, len * 2 + 1);
+   for (int i = 0; i  len; i++) {
+   str += sprintf(str, %02x, data[i]);
+   }
+   blobmsg_add_string_buffer(buf);
+}
+
 #define cmd_wms_delete_message_cb no_cb
 static enum qmi_cmd_result
 cmd_wms_delete_message_prepare(struct qmi_dev *qmi, struct qmi_request *req, 
struct qmi_msg *msg, char *arg)
@@ -318,10 +327,6 @@ static void cmd_wms_get_message_cb(struct qmi_dev *qmi, 
struct qmi_request *req,
/* Data Encoding */
dcs = *(data++);
 
-   /* only 7-bit encoding supported for now */
-   if (dcs  0x0c)
-   goto error;
-
if (dcs  0x10)
blobmsg_add_u32(status, class, (dcs  3));
 
@@ -374,9 +379,24 @@ static void cmd_wms_get_message_cb(struct qmi_dev *qmi, 
struct qmi_request *req,
if (data = end)
goto error;
 
-   decode_7bit_field(text, data, end - data, bit_offset);
-   blobmsg_close_table(status, c);
+   switch(dcs  0x0c) {
+   case 0x00:
+   /* 7 bit GSM alphabet */
+   decode_7bit_field(text, data, end - data, bit_offset);
+   break;
+   case 0x04:
+   /* 8 bit data */
+   blobmsg_add_hex(status, data, data, end - data);
+   break;
+   case 0x08:
+   /* 16 bit UCS-2 string */
+   blobmsg_add_hex(status, ucs-2, data, end - data);
+   break;
+   default:
+   goto error;
+   }
 
+   blobmsg_close_table(status, c);
return;
 
 error:
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uqmi] Fix character @ added at end of received messages

2014-12-08 Thread Sławomir Demeszko
If 7 bit message encoded on 8 bit cells has one last bit occupying
whole byte it need to be padded with 7 zero bits. To not mistake
these last 7 bits with a character with code 0 (@) we need to check
length from User Data Length field and not rely on actual length
of received data. An example can be message abcdefg encoded
as 61 f1 98 5c 36 9f 01, it is decoded as abcdefg@.

Signed-off-by: Sławomir Demeszko s.demes...@wireless-instruments.com
---
It depends on my last patches from today.

 commands-wms.c | 23 ---
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/commands-wms.c b/commands-wms.c
index 74f50aa..47d4d76 100644
--- a/commands-wms.c
+++ b/commands-wms.c
@@ -1,5 +1,8 @@
 #include qmi-message.h
 
+#define MIN(a,b) (((a)(b))?(a):(b))
+#define CEILDIV(x,y) (((x) + (y) - 1) / (y))
+
 static void cmd_wms_list_messages_cb(struct qmi_dev *qmi, struct qmi_request 
*req, struct qmi_msg *msg)
 {
struct qmi_wms_list_messages_response res;
@@ -191,8 +194,9 @@ static int decode_udh(const unsigned char *data)
 
 static void decode_7bit_field(char *name, const unsigned char *data, int 
data_len, int bit_offset)
 {
-   char *dest = blobmsg_alloc_string_buffer(status, name, 3 * (data_len * 
8 / 7) + 2);
-   pdu_decode_7bit_str(dest, data, data_len, bit_offset);
+   char *dest = blobmsg_alloc_string_buffer(status, name, 3 * data_len + 
2);
+   pdu_decode_7bit_str(dest, data, CEILDIV(data_len * 7, 8), bit_offset);
+   dest[data_len] = 0;
blobmsg_add_string_buffer(status);
 }
 
@@ -366,12 +370,13 @@ static void cmd_wms_get_message_cb(struct qmi_dev *qmi, 
struct qmi_request *req,
data += 7;
}
 
-   data++;
+   int message_len = *(data++);
+   int udh_len = 0;
int bit_offset = 0;
 
/* User Data Header */
if (first  0x40) {
-   int udh_len = decode_udh(data);
+   udh_len = decode_udh(data);
data += udh_len;
bit_offset = udh_len % 7;
}
@@ -382,15 +387,19 @@ static void cmd_wms_get_message_cb(struct qmi_dev *qmi, 
struct qmi_request *req,
switch(dcs  0x0c) {
case 0x00:
/* 7 bit GSM alphabet */
-   decode_7bit_field(text, data, end - data, bit_offset);
+   message_len = message_len - CEILDIV(udh_len * 8, 7);
+   message_len = MIN(message_len, CEILDIV((end - data) * 
8, 7));
+   decode_7bit_field(text, data, message_len, 
bit_offset);
break;
case 0x04:
/* 8 bit data */
-   blobmsg_add_hex(status, data, data, end - data);
+   message_len = MIN(message_len - udh_len, end - data);
+   blobmsg_add_hex(status, data, data, message_len);
break;
case 0x08:
/* 16 bit UCS-2 string */
-   blobmsg_add_hex(status, ucs-2, data, end - data);
+   message_len = MIN(message_len - udh_len, end - data);
+   blobmsg_add_hex(status, ucs-2, data, message_len);
break;
default:
goto error;
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [uqmi] SEGFAULT on reading Unicode sms messages

2014-11-27 Thread Sławomir Demeszko
I was trying to read (by command --get-message) sms text message coded
in 16 bit Unicode which is not supported yet in uqmi, but program does
not end cleanly, I got segfault:

Program received signal SIGSEGV, Segmentation fault.
blobmsg_check_attr (attr=attr@entry=0x60d038, name=name@entry=false)
at 
/home/wirouter/Projects/OpenWRT/x86/build_dir/target-x86_64_uClibc-0.9.33.2/libubox-2014-11-23/blobmsg.c:49
49  if (hdr-name[blobmsg_namelen(hdr)] != 0)
(gdb) bt
#0  blobmsg_check_attr (attr=attr@entry=0x60d038, name=name@entry=false)
at 
/home/wirouter/Projects/OpenWRT/x86/build_dir/target-x86_64_uClibc-0.9.33.2/libubox-2014-11-23/blobmsg.c:49
#1  0x779e911b in blobmsg_format_element (s=s@entry=0x7fffea48, 
attr=attr@entry=0x60d038, array=array@entry=false, head=false)
at 
/home/wirouter/Projects/OpenWRT/x86/build_dir/target-x86_64_uClibc-0.9.33.2/libubox-2014-11-23/blobmsg_json.c:221
#2  0x779e9609 in blobmsg_format_json_with_cb (attr=0x60d038, 
list=list@entry=false, cb=cb@entry=0x0, priv=priv@entry=0x0, indent=optimized 
out)
at 
/home/wirouter/Projects/OpenWRT/x86/build_dir/target-x86_64_uClibc-0.9.33.2/libubox-2014-11-23/blobmsg_json.c:316
#3  0x00403377 in blobmsg_format_json_indent (list=false, 
indent=optimized out, attr=optimized out)
at 
/home/wirouter/Projects/OpenWRT/x86/staging_dir/target-x86_64_uClibc-0.9.33.2/usr/include/libubox/blobmsg_json.h:42
#4  uqmi_print_result (data=optimized out) at 
/home/wirouter/Projects/OpenWRT/x86/build_dir/target-x86_64_uClibc-0.9.33.2/wi-uqmi-2014-11-20/commands.c:176
#5  __uqmi_run_commands (qmi=qmi@entry=0x60b580 dev.8732, 
option=option@entry=false)
at 
/home/wirouter/Projects/OpenWRT/x86/build_dir/target-x86_64_uClibc-0.9.33.2/wi-uqmi-2014-11-20/commands.c:218
#6  0x004033cb in uqmi_run_commands (qmi=qmi@entry=0x60b580 dev.8732)
at 
/home/wirouter/Projects/OpenWRT/x86/build_dir/target-x86_64_uClibc-0.9.33.2/wi-uqmi-2014-11-20/commands.c:236
#7  0x004012df in main (argc=5, argv=0x7fffed58) at 
/home/wirouter/Projects/OpenWRT/x86/build_dir/target-x86_64_uClibc-0.9.33.2/wi-uqmi-2014-11-20/main.c:126

This is a raw message read by --get-raw-message (phone number is masked):

07 91 ** ** ** ** ** f* 04 0b 91 ** ** ** ** ** f* 00 08 41 11 02 41 42 15 40 
08 01 04 01 06 01 18 01 41

I figured out that cause of this lies in function cmd_wms_get_message_cb().
There is a call for blobmsg_open_table() and blobmsg_close_table()
at the end, but in meantime there is also return from function when readed
data is invalid or not supported, like Unicode, so blobmsg_close_table()
is not invoked. Propossed patch using goto follows. But still program
returns 0 meaning SUCCESS, I don't known how to handle this.
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uqmi] SEGFAULT on reading Unicode sms messages

2014-11-27 Thread Sławomir Demeszko
Added complementary blobmsg_close_table() before returning from function
on error.
---
 commands-wms.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/commands-wms.c b/commands-wms.c
index 9b9aac3..da4aeaf 100644
--- a/commands-wms.c
+++ b/commands-wms.c
@@ -270,7 +270,7 @@ static void cmd_wms_get_message_cb(struct qmi_dev *qmi, 
struct qmi_request *req,
 
cur_len = *(data++);
if (data + cur_len = end)
-   return;
+   goto error;
 
if (cur_len) {
wms_decode_address(smsc, data, cur_len - 1);
@@ -278,7 +278,7 @@ static void cmd_wms_get_message_cb(struct qmi_dev *qmi, 
struct qmi_request *req,
}
 
if (data + 3 = end)
-   return;
+   goto error;
 
first = *(data++);
sent = (first  0x3) == 1;
@@ -287,7 +287,7 @@ static void cmd_wms_get_message_cb(struct qmi_dev *qmi, 
struct qmi_request *req,
 
cur_len = *(data++);
if (data + cur_len = end)
-   return;
+   goto error;
 
if (cur_len) {
cur_len = (cur_len + 1) / 2;
@@ -296,18 +296,18 @@ static void cmd_wms_get_message_cb(struct qmi_dev *qmi, 
struct qmi_request *req,
}
 
if (data + 3 = end)
-   return;
+   goto error;
 
/* Protocol ID */
if (*(data++) != 0)
-   return;
+   goto error;
 
/* Data Encoding */
dcs = *(data++);
 
/* only 7-bit encoding supported for now */
if (dcs  0x0c)
-   return;
+   goto error;
 
if (dcs  0x10)
blobmsg_add_u32(status, class, (dcs  3));
@@ -317,7 +317,7 @@ static void cmd_wms_get_message_cb(struct qmi_dev *qmi, 
struct qmi_request *req,
data++;
} else {
if (data + 6 = end)
-   return;
+   goto error;
 
str = blobmsg_alloc_string_buffer(status, timestamp, 32);
 
@@ -351,6 +351,12 @@ static void cmd_wms_get_message_cb(struct qmi_dev *qmi, 
struct qmi_request *req,
cur_len = *(data++);
decode_7bit_field(text, data, end - data, !!(first  0x40));
blobmsg_close_table(status, c);
+
+   return;
+
+error:
+   blobmsg_close_table(status, c);
+   fprintf(stderr, There was an error reading message.\n);
 }
 
 static enum qmi_cmd_result
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Need help understanding Ralink's dts config file and how it works

2014-11-25 Thread Sławomir Demeszko

On  23.11.2014 17:05, Md Mahbubur Rasheed wrote:

Hi, I am also currently working on board with this chip, and answers to your question will 
be helpful for me too. I can share my knowledge, but don't treat this as an axiom, I am 
begginer in this subject too and I could be wrong.



1. Why a single SoC has so many  built in ethernet controllers/

 drivers (MT7530, RT2880, MT7620)? If a doesn't have any external
 ethernet controller, then which one should we use?
I think that MT7530 is a name of internal or external switch and driver for it. RT2880 is 
an older SoC created by Ralink which was taken few years ago by Mediatek and few things 
are compatible with MT7620A, so drivers stay the same. And MT7620 is actual name of SoC. 
In .dts files we define among others things which device are comatible to already 
supported devices, that way if there isn't more specific driver for certain device, less 
specific or general can be used.



But configurations, such as-  ethernet@1010 , pinctrl etc remain

 as foggy as it was 12 hours ago.
As I know ethernet@1010 is only a name. Real address of register of device is passed 
by reg field. But also included in name for convience.



2. How (and where) is the WAN  port (i.e. phy4) mapped to gigabit bus

 rgmii? Is it possible to map WAN port as a gigabit port? Or it always
 remains 100Mbps port?
Electrical WAN or LAN (opposed to virtual defined in /etc/config/network) depends on 
connection on board and usually all mechanical ports are connected to 100Mbps ports of 
internal switch (by internal EPHY component). MT7620A has 5 that ports and 2x 1Gbps, but 
these two are RGMII ports and need additional chip (a PHY) to be possible for connection 
of external devices.



3. In the following code, when  should we use gmac and when ephy?

 gsw@1011 { ralink,port4 = gmac; };
I guess that ephy means that specified SoC port is connected to some external EPHY 
chip by RGMII or other interface and gmac not.



4. what does the following code  do? pinctrl { state_default: pinctrl0

 { gpio { ralink,group = i2c, uartf; ralink,function = gpio; };
 }; };
I am also don't know. Some info can be found at kernel 
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt and parent directory.



Finally, the MT7620A  programming guide describes the registers, but

 it doesn't explain the configurations or provides examples. I tried
 to use dts files for other routers to understand, but it was not much
 fruitful either. Is there any resource explaining the structure and
 programming model?
I think that almost everything about SoC itself is defined already in mt7620a.dtsi and 
implemented in drivers, so we not need to worry about all these internal stuff. But SoC 
can be connected on board with different configurations, using different protocols, 
different external chips and that depends on specific board. We do not always have access 
to documentation how board is contructed and I think other developers use method of trial 
and error, or by tracking paths on board, or by analyzing original firmware. Quite 
detailed documentation is in kernel sources at Documentation/devicetree. Here is a link: 
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uqmi] Add command --get-msisdn for getting phone number

2014-11-18 Thread Sławomir Demeszko
---
For two SIM cards from the same operator (Plus GSM) I get error message:
Not provisioned, when try to get MSISDN. Real phone with these cards
inserted also cannot display a phone number. I can make calls normally.
And other two (different operators) works correctly.
Is anybody know why this happens?

 commands-dms.c | 16 
 commands-dms.h |  2 ++
 2 files changed, 18 insertions(+)

diff --git a/commands-dms.c b/commands-dms.c
index 563321e..ad5c89d 100644
--- a/commands-dms.c
+++ b/commands-dms.c
@@ -159,6 +159,22 @@ cmd_dms_get_imsi_prepare(struct qmi_dev *qmi, struct 
qmi_request *req, struct qm
return QMI_CMD_REQUEST;
 }
 
+static void cmd_dms_get_msisdn_cb(struct qmi_dev *qmi, struct qmi_request 
*req, struct qmi_msg *msg)
+{
+   struct qmi_dms_get_msisdn_response res;
+
+   qmi_parse_dms_get_msisdn_response(msg, res);
+   if (res.data.msisdn)
+   blobmsg_add_string(status, NULL, res.data.msisdn);
+}
+
+static enum qmi_cmd_result
+cmd_dms_get_msisdn_prepare(struct qmi_dev *qmi, struct qmi_request *req, 
struct qmi_msg *msg, char *arg)
+{
+   qmi_set_dms_get_msisdn_request(msg);
+   return QMI_CMD_REQUEST;
+}
+
 #define cmd_dms_reset_cb no_cb
 static enum qmi_cmd_result
 cmd_dms_reset_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct 
qmi_msg *msg, char *arg)
diff --git a/commands-dms.h b/commands-dms.h
index 1f21b13..c20d007 100644
--- a/commands-dms.h
+++ b/commands-dms.h
@@ -8,6 +8,7 @@
__uqmi_command(dms_set_new_pin, new-pin, required, CMD_TYPE_OPTION), \
__uqmi_command(dms_get_iccid, get-iccid, no, QMI_SERVICE_DMS), \
__uqmi_command(dms_get_imsi, get-imsi, no, QMI_SERVICE_DMS), \
+   __uqmi_command(dms_get_msisdn, get-msisdn, no, QMI_SERVICE_DMS), \
__uqmi_command(dms_set_operating_mode, set-device-operating-mode, 
required, QMI_SERVICE_DMS), \
__uqmi_command(dms_reset, reset-dms, no, QMI_SERVICE_DMS) \
 
@@ -23,6 +24,7 @@
--new-pin new pin:New pin\n \
  --get-iccid:  Get the ICCID\n \
  --get-imsi:   Get International Mobile 
Subscriber ID\n \
+  --get-msisdn: Get the MSISDN (telephone number)\n \
  --reset-dms:  Reset the DMS service\n \
  --set-device-operating-mode m   Set the device operating 
mode\n \
(modes: online, low_power, 
factory_test, offline\n \
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH uqmi] Fix improper part number in multipart SMS text messages

2014-11-18 Thread Sławomir Demeszko
Received multipart SMS messages has part number always one too high.
---
 commands-wms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/commands-wms.c b/commands-wms.c
index 01e6867..9b9aac3 100644
--- a/commands-wms.c
+++ b/commands-wms.c
@@ -178,7 +178,7 @@ static void decode_udh(const unsigned char *data)
switch (type) {
case 0:
blobmsg_add_u32(status, concat_ref, (uint32_t) 
val[0]);
-   blobmsg_add_u32(status, concat_part, (uint32_t) 
val[2] + 1);
+   blobmsg_add_u32(status, concat_part, (uint32_t) 
val[2]);
blobmsg_add_u32(status, concat_parts, (uint32_t) 
val[1]);
break;
default:
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel