diff options
-rw-r--r-- | include/gsmd/usock.h | 1 | ||||
-rw-r--r-- | include/libgsmd/misc.h | 3 | ||||
-rw-r--r-- | src/gsmd/usock.c | 10 | ||||
-rw-r--r-- | src/libgsmd/libgsmd_phone.c | 19 | ||||
-rw-r--r-- | src/util/libgsmd-tool.c | 2 | ||||
-rw-r--r-- | src/util/shell.c | 5 |
6 files changed, 39 insertions, 1 deletions
diff --git a/include/gsmd/usock.h b/include/gsmd/usock.h index ba50cbd..4ffe09d 100644 --- a/include/gsmd/usock.h +++ b/include/gsmd/usock.h @@ -142,6 +142,7 @@ enum gsmd_msg_phone { GSMD_PHONE_VIB_ENABLE = 9, GSMD_PHONE_VIB_DISABLE = 10, GSMD_PHONE_POWER_STATUS = 11, + GSMD_PHONE_GSMD_LOGLEVEL= 12, }; enum gsmd_msg_modem { diff --git a/include/libgsmd/misc.h b/include/libgsmd/misc.h index 54e2940..ae266d7 100644 --- a/include/libgsmd/misc.h +++ b/include/libgsmd/misc.h @@ -80,4 +80,7 @@ extern int lgsm_phone_vibrator(struct lgsm_handle *lh, int enable); /* Get Antenna Power status */ extern int lgsm_get_power_status(struct lgsm_handle *lh); +/* Set the gsmd loglevel at runtime */ +extern int lgsm_set_gsmd_loglevel(struct lgsm_handle *lh, u_int8_t loglevel); + #endif diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c index 13c3bb1..f258fd6 100644 --- a/src/gsmd/usock.c +++ b/src/gsmd/usock.c @@ -43,6 +43,8 @@ #include <gsmd/ts0707.h> #include <gsmd/sms.h> +extern int loglevel; + static void *__ucmd_ctx, *__gu_ctx; struct gsmd_ucmd *ucmd_alloc(int extra_size) @@ -765,6 +767,14 @@ static int usock_rcv_phone(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, cmd = atcmd_fill("AT+CVIB=0", 9+1, &phone_vibrator_disable_cb, gu, 0, NULL); gu->gsmd->dev_state.vibrator = 0; break; + case GSMD_PHONE_GSMD_LOGLEVEL: + if (gph->len < 1) + return -EINVAL; + gsmd_log(GSMD_NOTICE, "Setting loglevel to %u on client " + "request\n", gph->data[0]); + loglevel = gph->data[0]; + return 0; + break; default: return -EINVAL; } diff --git a/src/libgsmd/libgsmd_phone.c b/src/libgsmd/libgsmd_phone.c index a67642a..9f6569c 100644 --- a/src/libgsmd/libgsmd_phone.c +++ b/src/libgsmd/libgsmd_phone.c @@ -1,6 +1,7 @@ /* libgsmd phone related functions * * (C) 2006-2007 by OpenMoko, Inc. + * (C) 2013 by Harald Welte * Written by Harald Welte <laforge@openmoko.org> * All Rights Reserved * @@ -90,4 +91,20 @@ int lgsm_phone_vibrator(struct lgsm_handle *lh, int enable) return lgsm_send_simple(lh, GSMD_MSG_PHONE, type); } - + +int lgsm_set_gsmd_loglevel(struct lgsm_handle *lh, u_int8_t loglevel) +{ + struct gsmd_msg_hdr *gmh; + int rc; + + gmh = lgsm_gmh_fill(GSMD_MSG_PHONE, GSMD_PHONE_GSMD_LOGLEVEL, 1); + if (!gmh) + return -ENOMEM; + + gmh->data[0] = loglevel; + + rc = lgsm_send(lh, gmh); + + lgsm_gmh_free(gmh); + return rc; +} diff --git a/src/util/libgsmd-tool.c b/src/util/libgsmd-tool.c index 653139b..5fb1eca 100644 --- a/src/util/libgsmd-tool.c +++ b/src/util/libgsmd-tool.c @@ -1,6 +1,7 @@ /* libgsmd tool * * (C) 2006-2007 by OpenMoko, Inc. + * (C) 2013 by Harald Welte * Written by Harald Welte <laforge@openmoko.org> * All Rights Reserved * @@ -102,6 +103,7 @@ int main(int argc, char **argv) int mode = MODE_NONE, shellwait = 0; printf("libgsm-tool - (C) 2006-2007 by Harald Welte and OpenMoko, Inc.\n" + " (C) 2012-2013 by Harald Welte\n" "This program is Free Software and has ABSOLUTELY NO WARRANTY\n\n"); while (1) { diff --git a/src/util/shell.c b/src/util/shell.c index 6b461be..f1333dc 100644 --- a/src/util/shell.c +++ b/src/util/shell.c @@ -604,6 +604,7 @@ static void shell_help(void) "\tCFQ\tQuery the status of call forwarding (CFQ=reason)\n" "\tCFR\tRegister call forwarding (CFR=reason,number)\n" "\tCFe\tErase a record of call forwarding (CFe=reason)\n" + "\tlog=N\tSet gsmd Log Level (1=debug, 8=fatal)\n" "\tq\tQuit\n" ); } @@ -1024,6 +1025,10 @@ int shell_main(struct lgsm_handle *lgsmh, int sync) printf("Battery Connection status and Battery Charge Level\n"); lgsm_get_battery(lgsmh); pending_responses++; + } else if (!strncmp(buf, "log=", 4)) { + int gsmd_loglevel = atoi(buf+4); + lgsm_set_gsmd_loglevel(lgsmh, gsmd_loglevel); + pending_responses++; }else { printf("Unknown command `%s'\n", buf); } |