diff mbox series

uim: add --uim-get-sim-state

Message ID 20210508000257.17188-1-arjunak234@gmail.com
State Changes Requested
Headers show
Series uim: add --uim-get-sim-state | expand

Commit Message

Arjun AK May 8, 2021, 12:02 a.m. UTC
From: Arjun <arjunak234@gmail.com>

This command will show whether a SIM card has been inserted and whether
a pin is required.

Signed-off-by: Arjun <arjunak234@gmail.com>
---
 commands-uim.c | 26 ++++++++++++++++++++++++++
 commands-uim.h |  4 +++-
 2 files changed, 29 insertions(+), 1 deletion(-)

Comments

Daniel Golle May 8, 2021, 1:03 a.m. UTC | #1
Hi Arjun,

On Sat, May 08, 2021 at 05:32:57AM +0530, Arjun AK wrote:
> From: Arjun <arjunak234@gmail.com>
> 
> This command will show whether a SIM card has been inserted and whether
> a pin is required.
> 
> Signed-off-by: Arjun <arjunak234@gmail.com>

Please follow our contribution guideline and use a full real name
to sign off your patch.

https://openwrt.org/submitting-patches#submission_guidelines

Apart from that and two very minor style/white-space issues the patch
looks good.

> ---
>  commands-uim.c | 26 ++++++++++++++++++++++++++
>  commands-uim.h |  4 +++-
>  2 files changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/commands-uim.c b/commands-uim.c
> index 859da68..03166a2 100644
> --- a/commands-uim.c
> +++ b/commands-uim.c
> @@ -54,3 +54,29 @@ cmd_uim_verify_pin2_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct
>  	qmi_set_uim_verify_pin_request(msg, &data);
>  	return QMI_CMD_REQUEST;
>  }
> +
> +
> +static void cmd_uim_get_sim_state_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg)
> +{
> +	struct qmi_uim_get_card_status_response res;
> +	qmi_parse_uim_get_card_status_response(msg, &res);
> +
> +	void * const array = blobmsg_open_array(&status, "sim_cards");
> +        if (res.data.card_status.cards_n > 0){

Please use tabs for intentation and add a space before the curly
bracket.

> +		void * const table = blobmsg_open_table(&status, NULL);
> +
> +		for (int i = 0; i < res.data.card_status.cards_n;i++){

Should be:
		for (int i = 0; i < res.data.card_status.cards_n; i++) {


> +				blobmsg_add_u32(&status, "state", res.data.card_status.cards[i].card_state);
> +				blobmsg_add_u32(&status, "upin_state", res.data.card_status.cards[i].upin_state);
> +		}
> +		blobmsg_close_table(&status, table);
> +	}
> +	blobmsg_close_array(&status, array);
> +}
> +
> +static enum qmi_cmd_result
> +cmd_uim_get_sim_state_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
> +{
> +	qmi_set_uim_get_card_status_request(msg);
> +	return QMI_CMD_REQUEST;
> +}
> diff --git a/commands-uim.h b/commands-uim.h
> index 86ebae4..02a49b1 100644
> --- a/commands-uim.h
> +++ b/commands-uim.h
> @@ -21,10 +21,12 @@
>  
>  #define __uqmi_uim_commands												\
>  	__uqmi_command(uim_verify_pin1, uim-verify-pin1, required, QMI_SERVICE_UIM), \
> -	__uqmi_command(uim_verify_pin2, uim-verify-pin2, required, QMI_SERVICE_UIM) \
> +	__uqmi_command(uim_verify_pin2, uim-verify-pin2, required, QMI_SERVICE_UIM), \
> +	__uqmi_command(uim_get_sim_state, uim-get-sim-state, no, QMI_SERVICE_UIM) \
>  
>  
>  #define uim_helptext \
>  		"  --uim-verify-pin1 <pin>:          Verify PIN1 (new devices)\n" \
>  		"  --uim-verify-pin2 <pin>:          Verify PIN2 (new devices)\n" \
> +		"  --uim-get-sim-state:                  Get current SIM state\n" \
>  
> -- 
> 2.20.1
> 
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Arjun AK May 24, 2021, 5:51 a.m. UTC | #2
Hi,
I believe I've made the required changes. Can this be merged in now?

-
Arjun

On May 8, 2021 12:02:57 AM UTC, Arjun AK <arjunak234@gmail.com> wrote:
>From: Arjun <arjunak234@gmail.com>
>
>This command will show whether a SIM card has been inserted and whether
>a pin is required.
>
>Signed-off-by: Arjun <arjunak234@gmail.com>
>---
> commands-uim.c | 26 ++++++++++++++++++++++++++
> commands-uim.h |  4 +++-
> 2 files changed, 29 insertions(+), 1 deletion(-)
>
>diff --git a/commands-uim.c b/commands-uim.c
>index 859da68..03166a2 100644
>--- a/commands-uim.c
>+++ b/commands-uim.c
>@@ -54,3 +54,29 @@ cmd_uim_verify_pin2_prepare(struct qmi_dev *qmi,
>struct qmi_request *req, struct
> 	qmi_set_uim_verify_pin_request(msg, &data);
> 	return QMI_CMD_REQUEST;
> }
>+
>+
>+static void cmd_uim_get_sim_state_cb(struct qmi_dev *qmi, struct
>qmi_request *req, struct qmi_msg *msg)
>+{
>+	struct qmi_uim_get_card_status_response res;
>+	qmi_parse_uim_get_card_status_response(msg, &res);
>+
>+	void * const array = blobmsg_open_array(&status, "sim_cards");
>+        if (res.data.card_status.cards_n > 0){
>+		void * const table = blobmsg_open_table(&status, NULL);
>+
>+		for (int i = 0; i < res.data.card_status.cards_n;i++){
>+				blobmsg_add_u32(&status, "state",
>res.data.card_status.cards[i].card_state);
>+				blobmsg_add_u32(&status, "upin_state",
>res.data.card_status.cards[i].upin_state);
>+		}
>+		blobmsg_close_table(&status, table);
>+	}
>+	blobmsg_close_array(&status, array);
>+}
>+
>+static enum qmi_cmd_result
>+cmd_uim_get_sim_state_prepare(struct qmi_dev *qmi, struct qmi_request
>*req, struct qmi_msg *msg, char *arg)
>+{
>+	qmi_set_uim_get_card_status_request(msg);
>+	return QMI_CMD_REQUEST;
>+}
>diff --git a/commands-uim.h b/commands-uim.h
>index 86ebae4..02a49b1 100644
>--- a/commands-uim.h
>+++ b/commands-uim.h
>@@ -21,10 +21,12 @@
> 
> #define __uqmi_uim_commands												\
>	__uqmi_command(uim_verify_pin1, uim-verify-pin1, required,
>QMI_SERVICE_UIM), \
>-	__uqmi_command(uim_verify_pin2, uim-verify-pin2, required,
>QMI_SERVICE_UIM) \
>+	__uqmi_command(uim_verify_pin2, uim-verify-pin2, required,
>QMI_SERVICE_UIM), \
>+	__uqmi_command(uim_get_sim_state, uim-get-sim-state, no,
>QMI_SERVICE_UIM) \
> 
> 
> #define uim_helptext \
> 		"  --uim-verify-pin1 <pin>:          Verify PIN1 (new devices)\n" \
> 		"  --uim-verify-pin2 <pin>:          Verify PIN2 (new devices)\n" \
>+		"  --uim-get-sim-state:                  Get current SIM state\n" \
>
Arjun AK June 1, 2021, 2:41 p.m. UTC | #3
On 24/05/21 11:21 am, Arjun wrote:
> Hi,
> I believe I've made the required changes. Can this be merged in now?
> 
> -
> Arjun
> 
> On May 8, 2021 12:02:57 AM UTC, Arjun AK <arjunak234@gmail.com> wrote:
>> From: Arjun <arjunak234@gmail.com>
>>
>> This command will show whether a SIM card has been inserted and whether
>> a pin is required.
>>
>> Signed-off-by: Arjun <arjunak234@gmail.com>
>> ---
>> commands-uim.c | 26 ++++++++++++++++++++++++++
>> commands-uim.h |  4 +++-
>> 2 files changed, 29 insertions(+), 1 deletion(-)
>>
>> diff --git a/commands-uim.c b/commands-uim.c
>> index 859da68..03166a2 100644
>> --- a/commands-uim.c
>> +++ b/commands-uim.c
>> @@ -54,3 +54,29 @@ cmd_uim_verify_pin2_prepare(struct qmi_dev *qmi,
>> struct qmi_request *req, struct
>> 	qmi_set_uim_verify_pin_request(msg, &data);
>> 	return QMI_CMD_REQUEST;
>> }
>> +
>> +
>> +static void cmd_uim_get_sim_state_cb(struct qmi_dev *qmi, struct
>> qmi_request *req, struct qmi_msg *msg)
>> +{
>> +	struct qmi_uim_get_card_status_response res;
>> +	qmi_parse_uim_get_card_status_response(msg, &res);
>> +
>> +	void * const array = blobmsg_open_array(&status, "sim_cards");
>> +        if (res.data.card_status.cards_n > 0){
>> +		void * const table = blobmsg_open_table(&status, NULL);
>> +
>> +		for (int i = 0; i < res.data.card_status.cards_n;i++){
>> +				blobmsg_add_u32(&status, "state",
>> res.data.card_status.cards[i].card_state);
>> +				blobmsg_add_u32(&status, "upin_state",
>> res.data.card_status.cards[i].upin_state);
>> +		}
>> +		blobmsg_close_table(&status, table);
>> +	}
>> +	blobmsg_close_array(&status, array);
>> +}
>> +
>> +static enum qmi_cmd_result
>> +cmd_uim_get_sim_state_prepare(struct qmi_dev *qmi, struct qmi_request
>> *req, struct qmi_msg *msg, char *arg)
>> +{
>> +	qmi_set_uim_get_card_status_request(msg);
>> +	return QMI_CMD_REQUEST;
>> +}
>> diff --git a/commands-uim.h b/commands-uim.h
>> index 86ebae4..02a49b1 100644
>> --- a/commands-uim.h
>> +++ b/commands-uim.h
>> @@ -21,10 +21,12 @@
>>
>> #define __uqmi_uim_commands												\
>> 	__uqmi_command(uim_verify_pin1, uim-verify-pin1, required,
>> QMI_SERVICE_UIM), \
>> -	__uqmi_command(uim_verify_pin2, uim-verify-pin2, required,
>> QMI_SERVICE_UIM) \
>> +	__uqmi_command(uim_verify_pin2, uim-verify-pin2, required,
>> QMI_SERVICE_UIM), \
>> +	__uqmi_command(uim_get_sim_state, uim-get-sim-state, no,
>> QMI_SERVICE_UIM) \
>>
>>
>> #define uim_helptext \
>> 		"  --uim-verify-pin1 <pin>:          Verify PIN1 (new devices)\n" \
>> 		"  --uim-verify-pin2 <pin>:          Verify PIN2 (new devices)\n" \
>> +		"  --uim-get-sim-state:                  Get current SIM state\n" \
>>

Can someone merge this in ?
-
Arjun
Arjun AK June 18, 2021, 11:42 p.m. UTC | #4
On 01/06/21 8:11 pm, Arjun AK wrote:
> On 24/05/21 11:21 am, Arjun wrote:
>> Hi,
>> I believe I've made the required changes. Can this be merged in now?
>>
>> -
>> Arjun
>>
>> On May 8, 2021 12:02:57 AM UTC, Arjun AK <arjunak234@gmail.com> wrote:
>>> From: Arjun <arjunak234@gmail.com>
>>>
>>> This command will show whether a SIM card has been inserted and whether
>>> a pin is required.
>>>
>>> Signed-off-by: Arjun <arjunak234@gmail.com>
>>> ---
>>> commands-uim.c | 26 ++++++++++++++++++++++++++
>>> commands-uim.h |  4 +++-
>>> 2 files changed, 29 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/commands-uim.c b/commands-uim.c
>>> index 859da68..03166a2 100644
>>> --- a/commands-uim.c
>>> +++ b/commands-uim.c
>>> @@ -54,3 +54,29 @@ cmd_uim_verify_pin2_prepare(struct qmi_dev *qmi,
>>> struct qmi_request *req, struct
>>>     qmi_set_uim_verify_pin_request(msg, &data);
>>>     return QMI_CMD_REQUEST;
>>> }
>>> +
>>> +
>>> +static void cmd_uim_get_sim_state_cb(struct qmi_dev *qmi, struct
>>> qmi_request *req, struct qmi_msg *msg)
>>> +{
>>> +    struct qmi_uim_get_card_status_response res;
>>> +    qmi_parse_uim_get_card_status_response(msg, &res);
>>> +
>>> +    void * const array = blobmsg_open_array(&status, "sim_cards");
>>> +        if (res.data.card_status.cards_n > 0){
>>> +        void * const table = blobmsg_open_table(&status, NULL);
>>> +
>>> +        for (int i = 0; i < res.data.card_status.cards_n;i++){
>>> +                blobmsg_add_u32(&status, "state",
>>> res.data.card_status.cards[i].card_state);
>>> +                blobmsg_add_u32(&status, "upin_state",
>>> res.data.card_status.cards[i].upin_state);
>>> +        }
>>> +        blobmsg_close_table(&status, table);
>>> +    }
>>> +    blobmsg_close_array(&status, array);
>>> +}
>>> +
>>> +static enum qmi_cmd_result
>>> +cmd_uim_get_sim_state_prepare(struct qmi_dev *qmi, struct qmi_request
>>> *req, struct qmi_msg *msg, char *arg)
>>> +{
>>> +    qmi_set_uim_get_card_status_request(msg);
>>> +    return QMI_CMD_REQUEST;
>>> +}
>>> diff --git a/commands-uim.h b/commands-uim.h
>>> index 86ebae4..02a49b1 100644
>>> --- a/commands-uim.h
>>> +++ b/commands-uim.h
>>> @@ -21,10 +21,12 @@
>>>
>>> #define 
>>> __uqmi_uim_commands                                                \
>>>     __uqmi_command(uim_verify_pin1, uim-verify-pin1, required,
>>> QMI_SERVICE_UIM), \
>>> -    __uqmi_command(uim_verify_pin2, uim-verify-pin2, required,
>>> QMI_SERVICE_UIM) \
>>> +    __uqmi_command(uim_verify_pin2, uim-verify-pin2, required,
>>> QMI_SERVICE_UIM), \
>>> +    __uqmi_command(uim_get_sim_state, uim-get-sim-state, no,
>>> QMI_SERVICE_UIM) \
>>>
>>>
>>> #define uim_helptext \
>>>         "  --uim-verify-pin1 <pin>:          Verify PIN1 (new 
>>> devices)\n" \
>>>         "  --uim-verify-pin2 <pin>:          Verify PIN2 (new 
>>> devices)\n" \
>>> +        "  --uim-get-sim-state:                  Get current SIM 
>>> state\n" \
>>>
> 
> Can someone merge this in ?
> -
> Arjun
> 
Anyone?

-
Arjun
diff mbox series

Patch

diff --git a/commands-uim.c b/commands-uim.c
index 859da68..03166a2 100644
--- a/commands-uim.c
+++ b/commands-uim.c
@@ -54,3 +54,29 @@  cmd_uim_verify_pin2_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct
 	qmi_set_uim_verify_pin_request(msg, &data);
 	return QMI_CMD_REQUEST;
 }
+
+
+static void cmd_uim_get_sim_state_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg)
+{
+	struct qmi_uim_get_card_status_response res;
+	qmi_parse_uim_get_card_status_response(msg, &res);
+
+	void * const array = blobmsg_open_array(&status, "sim_cards");
+        if (res.data.card_status.cards_n > 0){
+		void * const table = blobmsg_open_table(&status, NULL);
+
+		for (int i = 0; i < res.data.card_status.cards_n;i++){
+				blobmsg_add_u32(&status, "state", res.data.card_status.cards[i].card_state);
+				blobmsg_add_u32(&status, "upin_state", res.data.card_status.cards[i].upin_state);
+		}
+		blobmsg_close_table(&status, table);
+	}
+	blobmsg_close_array(&status, array);
+}
+
+static enum qmi_cmd_result
+cmd_uim_get_sim_state_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+	qmi_set_uim_get_card_status_request(msg);
+	return QMI_CMD_REQUEST;
+}
diff --git a/commands-uim.h b/commands-uim.h
index 86ebae4..02a49b1 100644
--- a/commands-uim.h
+++ b/commands-uim.h
@@ -21,10 +21,12 @@ 
 
 #define __uqmi_uim_commands												\
 	__uqmi_command(uim_verify_pin1, uim-verify-pin1, required, QMI_SERVICE_UIM), \
-	__uqmi_command(uim_verify_pin2, uim-verify-pin2, required, QMI_SERVICE_UIM) \
+	__uqmi_command(uim_verify_pin2, uim-verify-pin2, required, QMI_SERVICE_UIM), \
+	__uqmi_command(uim_get_sim_state, uim-get-sim-state, no, QMI_SERVICE_UIM) \
 
 
 #define uim_helptext \
 		"  --uim-verify-pin1 <pin>:          Verify PIN1 (new devices)\n" \
 		"  --uim-verify-pin2 <pin>:          Verify PIN2 (new devices)\n" \
+		"  --uim-get-sim-state:                  Get current SIM state\n" \