From d01f9a23390237d19da0a23ef2498ab56f734b23 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sat, 24 Jul 2010 13:50:15 +0000 Subject: [PATCH] Hopefully fixed contacts creation and modification --- src/modem.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/modem.c b/src/modem.c index 9ad2216..f06a25e 100644 --- a/src/modem.c +++ b/src/modem.c @@ -205,16 +205,19 @@ int gsm_modem_contact_edit(GSMModem * gsmm, unsigned int index, { int ret; char const cmd[] = "AT+CPBW="; + unsigned int type = 129; size_t len; char * buf; if(name == NULL || number == NULL) return gsm_event(gsmm->gsm, GSM_EVENT_TYPE_ERROR, GSM_ERROR_CONTACT_EDIT_FAILED, NULL); - len = sizeof(cmd) + 11 + 1 + strlen(name) + 1 + strlen(number); + len = sizeof(cmd) + 11 + 2 + strlen(number) + 2 + 11 + 2 + strlen(name) + + 1; if((buf = malloc(len)) == NULL) return 1; - snprintf(buf, len, "%s%u,%s,%s", cmd, index, name, number); + snprintf(buf, len, "%s%u,\"%s\",%u,\"%s\"", cmd, index, number, type, + name); ret = gsm_queue_with_error(gsmm->gsm, buf, GSM_ERROR_CONTACT_EDIT_FAILED); free(buf); @@ -228,16 +231,17 @@ int gsm_modem_contact_new(GSMModem * gsmm, char const * name, { int ret; char const cmd[] = "AT+CPBW="; + unsigned int type = 129; size_t len; char * buf; if(name == NULL || number == NULL) return gsm_event(gsmm->gsm, GSM_EVENT_TYPE_ERROR, GSM_ERROR_CONTACT_NEW_FAILED, NULL); - len = sizeof(cmd) + 1 + strlen(name) + 1 + strlen(number); + len = sizeof(cmd) + 2 + strlen(number) + 2 + 11 + 2 + strlen(name) + 1; if((buf = malloc(len)) == NULL) return 1; - snprintf(buf, len, "%s,%s,%s", cmd, name, number); + snprintf(buf, len, "%s,\"%s\",%u,\"%s\"", cmd, number, type, name); ret = gsm_queue_with_error(gsmm->gsm, buf, GSM_ERROR_CONTACT_NEW_FAILED); free(buf);