summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gsmd/usock.c42
-rw-r--r--src/libgsmd/libgsmd_phone.c4
-rw-r--r--src/libgsmd/libgsmd_pin.c2
-rw-r--r--src/util/shell.c10
4 files changed, 49 insertions, 9 deletions
diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c
index 2faf1fc..390f4bf 100644
--- a/src/gsmd/usock.c
+++ b/src/gsmd/usock.c
@@ -613,7 +613,7 @@ static int phone_powerdown_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
cmd->id, sizeof(ret), &ret);
}
-static int gsmd_get_manuf_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+static int phone_get_manuf_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
{
struct gsmd_user *gu = ctx;
@@ -624,7 +624,7 @@ static int gsmd_get_manuf_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
cmd->id, strlen(resp) + 1, resp);
}
-static int gsmd_get_model_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+static int phone_get_model_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
{
struct gsmd_user *gu = ctx;
@@ -635,7 +635,7 @@ static int gsmd_get_model_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
cmd->id, strlen(resp) + 1, resp);
}
-static int gsmd_get_revision_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+static int phone_get_revision_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
{
struct gsmd_user *gu = ctx;
@@ -646,7 +646,7 @@ static int gsmd_get_revision_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
cmd->id, strlen(resp) + 1, resp);
}
-static int gsmd_get_serial_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+static int phone_get_serial_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
{
struct gsmd_user *gu = ctx;
@@ -657,6 +657,28 @@ static int gsmd_get_serial_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
cmd->id, strlen(resp) + 1, resp);
}
+static int phone_get_battery_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+ struct gsmd_user *gu = ctx;
+ struct gsmd_battery_charge gbs;
+ struct gsm_extrsp *er;
+
+ DEBUGP("cmd = '%s', resp: '%s'\n", cmd->buf, resp);
+ er = extrsp_parse(gsmd_tallocs, resp);
+ if(!er)
+ return -ENOMEM;
+ /* +CBC: 0,0 */
+ if((er->num_tokens == 2) &&
+ er->tokens[0].type == GSMD_ECMD_RTT_NUMERIC &&
+ er->tokens[1].type == GSMD_ECMD_RTT_NUMERIC ) {
+ gbs.bcs = er->tokens[0].u.numeric;
+ gbs.bcl = er->tokens[1].u.numeric;
+ }
+ talloc_free(er);
+ return gsmd_ucmd_submit(gu, GSMD_MSG_PHONE, GSMD_PHONE_GET_BATTERY,
+ cmd -> id, sizeof(gbs), &gbs);
+}
+
static int usock_rcv_phone(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
int len)
{
@@ -679,21 +701,23 @@ static int usock_rcv_phone(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
break;
case GSMD_PHONE_GET_MANUF:
cmd = atcmd_fill("AT+CGMI", 7+1,
- &gsmd_get_manuf_cb, gu, 0, NULL);
+ &phone_get_manuf_cb, gu, 0, NULL);
break;
case GSMD_PHONE_GET_MODEL:
cmd = atcmd_fill("AT+CGMM", 7+1,
- &gsmd_get_model_cb, gu, 0, NULL);
+ &phone_get_model_cb, gu, 0, NULL);
break;
case GSMD_PHONE_GET_REVISION:
cmd = atcmd_fill("AT+CGMR", 7+1,
- &gsmd_get_revision_cb, gu, 0, NULL);
+ &phone_get_revision_cb, gu, 0, NULL);
break;
case GSMD_PHONE_GET_SERIAL:
cmd = atcmd_fill("AT+CGSN", 7+1,
- &gsmd_get_serial_cb, gu, 0, NULL);
+ &phone_get_serial_cb, gu, 0, NULL);
+ break;
+ case GSMD_PHONE_GET_BATTERY:
+ cmd = atcmd_fill("AT+CBC", 6+1, &phone_get_battery_cb, gu, 0, NULL);
break;
-
default:
return -EINVAL;
}
diff --git a/src/libgsmd/libgsmd_phone.c b/src/libgsmd/libgsmd_phone.c
index 18cd614..2c67e8e 100644
--- a/src/libgsmd/libgsmd_phone.c
+++ b/src/libgsmd/libgsmd_phone.c
@@ -70,3 +70,7 @@ int lgsm_get_serial(struct lgsm_handle *lh)
return lgsm_send_simple(lh, GSMD_MSG_PHONE, GSMD_PHONE_GET_SERIAL);
}
+int lgsm_get_battery(struct lgsm_handle *lh)
+{
+ return lgsm_send_simple(lh, GSMD_MSG_PHONE, GSMD_PHONE_GET_BATTERY);
+}
diff --git a/src/libgsmd/libgsmd_pin.c b/src/libgsmd/libgsmd_pin.c
index 8d50b67..98fcbcc 100644
--- a/src/libgsmd/libgsmd_pin.c
+++ b/src/libgsmd/libgsmd_pin.c
@@ -28,6 +28,8 @@
#include <gsmd/event.h>
#include <libgsmd/libgsmd.h>
+#include "lgsm_internals.h"
+
static const char *pin_type_names[__NUM_GSMD_PIN] = {
[GSMD_PIN_READY] = "READY",
[GSMD_PIN_SIM_PIN] = "SIM PIN",
diff --git a/src/util/shell.c b/src/util/shell.c
index 1bfff3e..af6f795 100644
--- a/src/util/shell.c
+++ b/src/util/shell.c
@@ -394,6 +394,8 @@ static int phone_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
{
char *payload = (char *)gmh + sizeof(*gmh);
int *intresult = (void *)gmh + sizeof(*gmh);
+ const struct gsmd_battery_charge *bc = (struct gsmd_battery_charge *)
+ ((void *) gmh + sizeof(*gmh));
switch (gmh->msg_subtype) {
case GSMD_PHONE_GET_IMSI:
@@ -423,6 +425,9 @@ static int phone_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
else
printf("Modem down\n");
break;
+ case GSMD_PHONE_GET_BATTERY:
+ printf("<BCS>: %d <BCL>: %d \n", bc->bcs, bc->bcl);
+ break;
default:
return -EINVAL;
}
@@ -568,6 +573,7 @@ static void shell_help(void)
"\tsn\tGet serial number\n"
"\tcs\tGet Call status\n"
"\tgp\tGet PIN status\n"
+ "\tcbc\tGet Battery status\n"
"\tRh\tRelease all held calls (+CHLD=0)\n"
"\tUDUB\tUser Determined User Busy (+CHLD=0)\n"
"\tRa\tRelease all active calls (+CHLD=1)\n"
@@ -987,6 +993,10 @@ int shell_main(struct lgsm_handle *lgsmh, int sync)
ptr = strchr(buf, '=');
lgsm_voice_fwd_erase(lgsmh, atoi(ptr+1));
pending_responses ++;
+ }else if ( !strncmp(buf, "cbc", 3)) {
+ printf("Battery Connection status and Battery Charge Level\n");
+ lgsm_get_battery(lgsmh);
+ pending_responses++;
}else {
printf("Unknown command `%s'\n", buf);
}
personal git repositories of Harald Welte. Your mileage may vary