summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerin_yueh <erin_yueh@99fdad57-331a-0410-800a-d7fa5415bdb3>2008-02-26 08:57:39 +0000
committererin_yueh <erin_yueh@99fdad57-331a-0410-800a-d7fa5415bdb3>2008-02-26 08:57:39 +0000
commit33b13190e1e8925100a7d577ce9ee72344eff987 (patch)
tree1a248b3ff2e901ad5165d849264aaad69d068cf8
parent7d514fad9af90ea6c12e4bcab41176f5dd9de282 (diff)
gsmd: add vibrator at cmd (Sudharshan S)
git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@4115 99fdad57-331a-0410-800a-d7fa5415bdb3
-rw-r--r--include/gsmd/state.h1
-rw-r--r--include/gsmd/usock.h2
-rw-r--r--include/libgsmd/misc.h4
-rw-r--r--src/gsmd/usock.c33
-rw-r--r--src/libgsmd/libgsmd_phone.c12
-rw-r--r--src/util/shell.c22
6 files changed, 73 insertions, 1 deletions
diff --git a/include/gsmd/state.h b/include/gsmd/state.h
index 65659ef..7162b4f 100644
--- a/include/gsmd/state.h
+++ b/include/gsmd/state.h
@@ -13,6 +13,7 @@ struct gsmd_device_state {
unsigned int network_state_gsm;
unsigned int network_state_gprs;
} ciph_ind;
+ unsigned int vibrator;
unsigned int on;
unsigned int registered;
unsigned int ringing;
diff --git a/include/gsmd/usock.h b/include/gsmd/usock.h
index 7df22b2..bb03aa1 100644
--- a/include/gsmd/usock.h
+++ b/include/gsmd/usock.h
@@ -140,6 +140,8 @@ enum gsmd_msg_phone {
GSMD_PHONE_GET_REVISION = 6,
GSMD_PHONE_GET_SERIAL = 7,
GSMD_PHONE_GET_BATTERY = 8,
+ GSMD_PHONE_VIB_ENABLE = 9,
+ GSMD_PHONE_VIB_DISABLE = 10,
};
enum gsmd_msg_modem {
diff --git a/include/libgsmd/misc.h b/include/libgsmd/misc.h
index 884e294..9100260 100644
--- a/include/libgsmd/misc.h
+++ b/include/libgsmd/misc.h
@@ -73,4 +73,8 @@ extern int lgsm_voicemail_set(struct lgsm_handle *lh, const char *number);
extern int lgsm_voicemail_get(struct lgsm_handle *lh);
/* Get Battery Connection status and charge level */
extern int lgsm_get_battery(struct lgsm_handle *lh);
+
+/* Enable vibrator */
+extern int lgsm_phone_vibrator(struct lgsm_handle *lh, int enable);
+
#endif
diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c
index 119ed56..c7f8827 100644
--- a/src/gsmd/usock.c
+++ b/src/gsmd/usock.c
@@ -679,6 +679,32 @@ static int phone_get_battery_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
cmd -> id, sizeof(gbs), &gbs);
}
+static int phone_vibrator_enable_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+ struct gsmd_user *gu = ctx;
+ int ret = cmd->ret;
+
+ switch(ret) {
+ case 0:
+ gsmd_log(GSMD_DEBUG, "Vibrator enabled\n");
+ gu->gsmd->dev_state.vibrator = 1;
+ break;
+ default:
+ gsmd_log(GSMD_DEBUG, "AT+CVIB=1 operation failed\n");
+ break;
+ }
+
+ return gsmd_ucmd_submit(gu, GSMD_MSG_PHONE, GSMD_PHONE_VIB_ENABLE,
+ cmd->id, sizeof(ret), &ret);
+}
+
+static int phone_vibrator_disable_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+ int ret = cmd->ret;
+ return gsmd_ucmd_submit(ctx, GSMD_MSG_PHONE, GSMD_PHONE_VIB_DISABLE,
+ cmd->id, sizeof(ret), &ret);
+}
+
static int usock_rcv_phone(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
int len)
{
@@ -718,6 +744,13 @@ static int usock_rcv_phone(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
case GSMD_PHONE_GET_BATTERY:
cmd = atcmd_fill("AT+CBC", 6+1, &phone_get_battery_cb, gu, 0, NULL);
break;
+ case GSMD_PHONE_VIB_ENABLE:
+ cmd = atcmd_fill("AT+CVIB=1", 9+1, &phone_vibrator_enable_cb, gu, 0, NULL);
+ break;
+ case GSMD_PHONE_VIB_DISABLE:
+ cmd = atcmd_fill("AT+CVIB=0", 9+1, &phone_vibrator_disable_cb, gu, 0, NULL);
+ gu->gsmd->dev_state.vibrator = 0;
+ break;
default:
return -EINVAL;
}
diff --git a/src/libgsmd/libgsmd_phone.c b/src/libgsmd/libgsmd_phone.c
index 2c67e8e..5ad5e44 100644
--- a/src/libgsmd/libgsmd_phone.c
+++ b/src/libgsmd/libgsmd_phone.c
@@ -74,3 +74,15 @@ int lgsm_get_battery(struct lgsm_handle *lh)
{
return lgsm_send_simple(lh, GSMD_MSG_PHONE, GSMD_PHONE_GET_BATTERY);
}
+
+int lgsm_phone_vibrator(struct lgsm_handle *lh, int enable)
+{
+ int type;
+ if(enable)
+ type = GSMD_PHONE_VIB_ENABLE;
+ else
+ type = GSMD_PHONE_VIB_DISABLE;
+
+ return lgsm_send_simple(lh, GSMD_MSG_PHONE, type);
+}
+
diff --git a/src/util/shell.c b/src/util/shell.c
index af6f795..85aa902 100644
--- a/src/util/shell.c
+++ b/src/util/shell.c
@@ -428,6 +428,18 @@ static int phone_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
case GSMD_PHONE_GET_BATTERY:
printf("<BCS>: %d <BCL>: %d \n", bc->bcs, bc->bcl);
break;
+ case GSMD_PHONE_VIB_ENABLE:
+ if(*intresult)
+ printf("Vibrator enable failed: %i\n", *intresult);
+ else
+ printf("Vibrator enabled\n");
+ break;
+ case GSMD_PHONE_VIB_DISABLE:
+ if(*intresult)
+ printf("Vibrator disable failed: %i\n", *intresult);
+ else
+ printf("VIbrator disabled\n");
+ break;
default:
return -EINVAL;
}
@@ -534,7 +546,9 @@ static void shell_help(void)
"\tH\tHangup call\n"
"\tO\tAntenna Power On\n"
"\to\tAntenna Power Off\n"
- "\tM\tModem Power On\n"
+ "\tV\tVibrator Enable (CVIB=1)\n"
+ "\tv\tVibrator Disable (CVIB=0)\n"
+ "\tM\tModem Power On\n"
"\tm\tModem Power Off\n"
"\tr\tRegister to network\n"
"\tR\tRegister to given operator (R=number)\n"
@@ -666,6 +680,12 @@ int shell_main(struct lgsm_handle *lgsmh, int sync)
} else if (!strcmp(buf, "o")) {
printf("Power-Off\n");
lgsm_phone_power(lgsmh, 0);
+ } else if (!strcmp(buf, "V")) {
+ printf("Vibrator-Enable\n");
+ lgsm_phone_vibrator(lgsmh, 1);
+ } else if (!strcmp(buf, "v")) {
+ printf("Vibrator-Disable\n");
+ lgsm_phone_vibrator(lgsmh, 0);
} else if (!strcmp(buf, "r")) {
printf("Register\n");
lgsm_netreg_register(lgsmh, "\0 ");
personal git repositories of Harald Welte. Your mileage may vary