summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/gsm/files/027_phonebook-find-and-read-range-support.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-connectivity/gsm/files/027_phonebook-find-and-read-range-support.patch')
-rw-r--r--meta/recipes-connectivity/gsm/files/027_phonebook-find-and-read-range-support.patch425
1 files changed, 0 insertions, 425 deletions
diff --git a/meta/recipes-connectivity/gsm/files/027_phonebook-find-and-read-range-support.patch b/meta/recipes-connectivity/gsm/files/027_phonebook-find-and-read-range-support.patch
deleted file mode 100644
index c94e4b2035..0000000000
--- a/meta/recipes-connectivity/gsm/files/027_phonebook-find-and-read-range-support.patch
+++ /dev/null
@@ -1,425 +0,0 @@
1Upstream-Status: Inappropriate [not used]
2
3From: Sean Chiang <sean_chiang@openmoko.com>
4Subject: [PATCH] Improvement for find and read phonebooks in gsmd
5
6This patch is an improvement for find and read phonebooks.
7After clients make a request to find / read phonebooks, then clients
8should make a request to retrieve all the records.
9
10Signed-off-by: Jim Huang <jserv@openmoko.org>
11---
12 include/gsmd/gsmd.h | 3
13 include/gsmd/usock.h | 20 +++-
14 include/libgsmd/phonebook.h | 6 +
15 src/gsmd/usock.c | 184 +++++++++++++++++++++++++++++++++++-----
16 src/libgsmd/libgsmd_phonebook.c | 48 ++++++++++
17 5 files changed, 238 insertions(+), 23 deletions(-)
18
19Index: gsm/include/libgsmd/phonebook.h
20===================================================================
21--- gsm.orig/include/libgsmd/phonebook.h 2007-08-31 16:15:29.000000000 +0800
22+++ gsm/include/libgsmd/phonebook.h 2007-09-17 23:48:41.000000000 +0800
23@@ -106,4 +106,10 @@
24 /* Get the location range/nlength/tlength supported */
25 extern int lgsm_pb_get_support(struct lgsm_handle *lh);
26
27+/* Retrieve the records of READRG request */
28+extern int lgsm_pb_retrieve_readrg(struct lgsm_handle *lh, int num);
29+
30+/* Retrieve the records of FIND request */
31+extern int lgsm_pb_retrieve_find(struct lgsm_handle *lh, int num);
32+
33 #endif
34Index: gsm/include/gsmd/gsmd.h
35===================================================================
36--- gsm.orig/include/gsmd/gsmd.h 2007-08-31 16:15:29.000000000 +0800
37+++ gsm/include/gsmd/gsmd.h 2007-09-17 23:48:41.000000000 +0800
38@@ -92,6 +92,9 @@
39 struct gsmd *gsmd;
40 struct gsmd_fd gfd; /* the socket */
41 u_int32_t subscriptions; /* bitmaks of subscribed event groups */
42+
43+ struct llist_head pb_readrg_list; /* our READRG phonebook list */
44+ struct llist_head pb_find_list; /* our FIND phonebook list */
45 };
46
47 #define GSMD_DEBUG 1 /* debugging information */
48Index: gsm/include/gsmd/usock.h
49===================================================================
50--- gsm.orig/include/gsmd/usock.h 2007-08-31 16:15:29.000000000 +0800
51+++ gsm/include/gsmd/usock.h 2007-09-17 23:48:56.000000000 +0800
52@@ -194,6 +194,8 @@
53 GSMD_PHONEBOOK_GET_SUPPORT = 6,
54 GSMD_PHONEBOOK_LIST_STORAGE = 7,
55 GSMD_PHONEBOOK_SET_STORAGE = 8,
56+ GSMD_PHONEBOOK_RETRIEVE_READRG = 9,
57+ GSMD_PHONEBOOK_RETRIEVE_FIND = 10,
58 };
59
60 /* Type-of-Address, Numbering-Plan-Identification field, GSM 03.40, 9.1.2.5 */
61@@ -431,7 +433,6 @@
62 char text[GSMD_PB_TEXT_MAXLEN+1];
63 } __attribute__ ((packed));
64
65-
66 /* Refer to GSM 07.07 subclause 8.13 */
67 /* FIXME: the tlength depends on SIM, use +CPBR=? to get */
68 struct gsmd_phonebook_find {
69@@ -471,8 +472,18 @@
70 char opname_longalpha[16];
71 };
72
73+/* Refer to GSM 07.07 subclause 8.11 */
74+struct gsmd_phonebook_mem {
75+ u_int8_t type[3];
76+ u_int8_t pad;
77+ u_int16_t used;
78+ u_int16_t total;
79+} __attribute__ ((packed));
80+
81 struct gsmd_phonebook_storage {
82- char storage[3];
83+ /* FIXME the amount of phonebook storage should be dynamic */
84+ u_int8_t num;
85+ struct gsmd_phonebook_mem mem[20];
86 } __attribute__ ((packed));
87
88 /* Subscriber number information from 3GPP TS 07.07, Clause 7.1 */
89@@ -517,6 +528,11 @@
90 char buf[];
91 } __attribute__ ((packed));
92
93+struct gsmd_phonebooks {
94+ struct llist_head list;
95+ struct gsmd_phonebook pb;
96+} __attribute__ ((packed));
97+
98 extern struct gsmd_ucmd *ucmd_alloc(int extra_size);
99 extern int usock_init(struct gsmd *g);
100 extern void usock_cmd_enqueue(struct gsmd_ucmd *ucmd, struct gsmd_user *gu);
101Index: gsm/src/libgsmd/libgsmd_phonebook.c
102===================================================================
103--- gsm.orig/src/libgsmd/libgsmd_phonebook.c 2007-08-31 16:15:29.000000000 +0800
104+++ gsm/src/libgsmd/libgsmd_phonebook.c 2007-09-17 23:48:41.000000000 +0800
105@@ -33,7 +33,7 @@
106 gmh->data[2] = '\0';
107
108 rc = lgsm_send(lh, gmh);
109- if (rc < gmh->len + 3) {
110+ if (rc < gmh->len + sizeof(*gmh)) {
111 lgsm_gmh_free(gmh);
112 return -EIO;
113 }
114@@ -177,3 +177,49 @@
115 {
116 return lgsm_send_simple(lh, GSMD_MSG_PHONEBOOK, GSMD_PHONEBOOK_GET_SUPPORT);
117 }
118+
119+int lgsm_pb_retrieve_readrg(struct lgsm_handle *lh, int num)
120+{
121+ struct gsmd_msg_hdr *gmh;
122+ int rc;
123+
124+ gmh = lgsm_gmh_fill(GSMD_MSG_PHONEBOOK,
125+ GSMD_PHONEBOOK_RETRIEVE_READRG, sizeof(int));
126+ if (!gmh)
127+ return -ENOMEM;
128+
129+ *(int *)(gmh->data) = num;
130+
131+ rc = lgsm_send(lh, gmh);
132+ if (rc < gmh->len + sizeof(*gmh)) {
133+ lgsm_gmh_free(gmh);
134+ return -EIO;
135+ }
136+
137+ lgsm_gmh_free(gmh);
138+
139+ return 0;
140+}
141+
142+int lgsm_pb_retrieve_find(struct lgsm_handle *lh, int num)
143+{
144+ struct gsmd_msg_hdr *gmh;
145+ int rc;
146+
147+ gmh = lgsm_gmh_fill(GSMD_MSG_PHONEBOOK,
148+ GSMD_PHONEBOOK_RETRIEVE_FIND, sizeof(int));
149+ if (!gmh)
150+ return -ENOMEM;
151+
152+ *(int *)(gmh->data) = num;
153+
154+ rc = lgsm_send(lh, gmh);
155+ if (rc < gmh->len + sizeof(*gmh)) {
156+ lgsm_gmh_free(gmh);
157+ return -EIO;
158+ }
159+
160+ lgsm_gmh_free(gmh);
161+
162+ return 0;
163+}
164Index: gsm/src/gsmd/usock.c
165===================================================================
166--- gsm.orig/src/gsmd/usock.c 2007-08-31 16:15:30.000000000 +0800
167+++ gsm/src/gsmd/usock.c 2007-09-17 23:53:34.000000000 +0800
168@@ -1035,21 +1035,56 @@
169
170 static int phonebook_find_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
171 {
172- struct gsmd_user *gu = ctx;
173- struct gsmd_ucmd *ucmd;
174-
175+ struct gsmd_user *gu = ctx;
176+ struct gsmd_ucmd *ucmd;
177+ struct gsmd_phonebooks *gps;
178+ char *fcomma, *lcomma, *ptr1, *ptr2 = NULL;
179+ int *num;
180+
181 DEBUGP("resp: %s\n", resp);
182
183- /* FIXME: using link list, also we need to handle the case of
184- * no query result */
185- ucmd = gsmd_ucmd_fill(strlen(resp) + 1, GSMD_MSG_PHONEBOOK,
186+ /*
187+ * [+CPBF: <index1>,<number>,<type>,<text>[[...]
188+ * <CR><LF>+CPBF: <index2>,<unmber>,<type>,<text>]]
189+ */
190+ ucmd = gsmd_ucmd_fill(sizeof(int), GSMD_MSG_PHONEBOOK,
191 GSMD_PHONEBOOK_FIND, 0);
192 if (!ucmd)
193 return -ENOMEM;
194
195- strcpy(ucmd->buf, resp);
196+ num = (int*) ucmd->buf;
197+
198+ *num = 0;
199+
200+ ptr1 = strtok(resp, "\n");
201+
202+ while (ptr1) {
203+ gps = (struct gsmd_phonebooks *) malloc(sizeof(struct gsmd_phonebooks));
204+ ptr2 = strchr(ptr1, ' ');
205+ gps->pb.index = atoi(ptr2+1);
206+
207+ fcomma = strchr(ptr1, '"');
208+ lcomma = strchr(fcomma+1, '"');
209+ strncpy(gps->pb.numb, fcomma + 1, (lcomma-fcomma-1));
210+ gps->pb.numb[(lcomma - fcomma) - 1] = '\0';
211+
212+ gps->pb.type = atoi(lcomma + 2);
213+
214+ ptr2 = strrchr(ptr1, ',');
215+ fcomma = ptr2 + 1;
216+ lcomma = strchr(fcomma + 1, '"');
217+ strncpy(gps->pb.text, fcomma + 1, (lcomma - fcomma - 1));
218+ gps->pb.text[(lcomma - fcomma) - 1] = '\0';
219+
220+ llist_add_tail(&gps->list, &gu->pb_find_list);
221+
222+ (*num)++;
223+
224+ ptr1 = strtok(NULL, "\n");
225+ }
226
227 usock_cmd_enqueue(ucmd, gu);
228+
229 return 0;
230 }
231
232@@ -1102,22 +1137,51 @@
233 {
234 struct gsmd_user *gu = ctx;
235 struct gsmd_ucmd *ucmd;
236+ struct gsmd_phonebooks *gps;
237+ char *fcomma, *lcomma, *ptr1, *ptr2 = NULL;
238+ int *num;
239
240 DEBUGP("resp: %s\n", resp);
241
242 /*
243- * +CPBR: 4,"1234",129,"6C5F745E7965"
244- * +CPBR: 5,"5678",129,"800062115BB6"
245- * +CPBR: 6,"7890",129,"810280AA591A"
246- * +CPBR: 8,"36874",129,"005300650061006E"
247- *
248+ * [+CPBR: <index1>,<number>,<type>,<text>[[...]
249+ * <CR><LF>+CPBR: <index2>,<unmber>,<type>,<text>]]
250 */
251- ucmd = gsmd_ucmd_fill(strlen(resp)+1, GSMD_MSG_PHONEBOOK,
252+ ucmd = gsmd_ucmd_fill(sizeof(int), GSMD_MSG_PHONEBOOK,
253 GSMD_PHONEBOOK_READRG, 0);
254 if (!ucmd)
255 return -ENOMEM;
256
257- strcpy(ucmd->buf, resp);
258+ num = (int*) ucmd->buf;
259+
260+ *num = 0;
261+
262+ ptr1 = strtok(resp, "\n");
263+
264+ while(ptr1) {
265+ gps = (struct gsmd_phonebooks *) malloc(sizeof(struct gsmd_phonebooks));
266+ ptr2 = strchr(ptr1, ' ');
267+ gps->pb.index = atoi(ptr2+1);
268+
269+ fcomma = strchr(ptr1, '"');
270+ lcomma = strchr(fcomma+1, '"');
271+ strncpy(gps->pb.numb, fcomma + 1, (lcomma-fcomma-1));
272+ gps->pb.numb[(lcomma - fcomma) - 1] = '\0';
273+
274+ gps->pb.type = atoi(lcomma + 2);
275+
276+ ptr2 = strrchr(ptr1, ',');
277+ fcomma = ptr2 + 1;
278+ lcomma = strchr(fcomma + 1, '"');
279+ strncpy(gps->pb.text, fcomma + 1, (lcomma - fcomma - 1));
280+ gps->pb.text[(lcomma - fcomma) - 1] = '\0';
281+
282+ llist_add_tail(&gps->list, &gu->pb_readrg_list);
283+
284+ (*num)++;
285+
286+ ptr1 = strtok(NULL, "\n");
287+ }
288
289 usock_cmd_enqueue(ucmd, gu);
290
291@@ -1209,22 +1273,38 @@
292 static int phonebook_list_storage_cb(struct gsmd_atcmd *cmd,
293 void *ctx, char *resp)
294 {
295- /* +CPBS: ("EN","BD","FD","DC","LD","RC","LR","MT","AD",
296- * "SM","SD","MC","LM","AF","ON","UD") */
297 /* TODO; using link list ; need to handle command error */
298 struct gsmd_user *gu = ctx;
299 struct gsmd_ucmd *ucmd;
300+ struct gsmd_phonebook_storage *gps;
301+ char *ptr;
302
303 DEBUGP("resp: %s\n", resp);
304
305- ucmd = gsmd_ucmd_fill(strlen(resp) + 1,
306+ /*
307+ * +CPBS: (<storage>s)
308+ */
309+
310+ ucmd = gsmd_ucmd_fill(sizeof(*gps),
311 GSMD_MSG_PHONEBOOK,
312 GSMD_PHONEBOOK_LIST_STORAGE, 0);
313
314 if (!ucmd)
315 return -ENOMEM;
316
317- strcpy(ucmd->buf, resp);
318+ gps = (struct gsmd_phonebook_storage *) ucmd->buf;
319+ gps->num = 0;
320+
321+ if (!strncmp(resp, "+CPBS", 5)) {
322+ char* delim = "(,";
323+ ptr = strpbrk(resp, delim);
324+ while ( ptr ) {
325+ strncpy(gps->mem[gps->num].type, ptr+2, 2);
326+ gps->mem[gps->num].type[2] = '\0';
327+ ptr = strpbrk(ptr+2, delim);
328+ gps->num++;
329+ }
330+ }
331
332 usock_cmd_enqueue(ucmd, gu);
333
334@@ -1235,11 +1315,13 @@
335 struct gsmd_msg_hdr *gph,int len)
336 {
337 struct gsmd_atcmd *cmd = NULL;
338+ struct gsmd_ucmd *ucmd = NULL;
339 struct gsmd_phonebook_readrg *gpr;
340 struct gsmd_phonebook *gp;
341 struct gsmd_phonebook_find *gpf;
342- int *index;
343- int atcmd_len;
344+ struct gsmd_phonebooks *cur, *cur2;
345+ int *index, *num;
346+ int atcmd_len, i;
347 char *storage;
348 char buf[1024];
349
350@@ -1343,6 +1425,66 @@
351 cmd = atcmd_fill("AT+CPBR=?", 9+1,
352 &phonebook_get_support_cb, gu, gph->id);
353 break;
354+ case GSMD_PHONEBOOK_RETRIEVE_READRG:
355+ if (len < sizeof(*gph) + sizeof(int))
356+ return -EINVAL;
357+
358+ num = (int *) ((void *)gph + sizeof(*gph));
359+
360+ ucmd = gsmd_ucmd_fill(sizeof(struct gsmd_phonebook)*(*num),
361+ GSMD_MSG_PHONEBOOK,
362+ GSMD_PHONEBOOK_RETRIEVE_READRG, 0);
363+ if (!ucmd)
364+ return -ENOMEM;
365+
366+ gp = (struct gsmd_phonebook*) ucmd->buf;
367+
368+ if (!llist_empty(&gu->pb_readrg_list)) {
369+
370+ llist_for_each_entry_safe(cur, cur2,
371+ &gu->pb_readrg_list, list) {
372+ gp->index = cur->pb.index;
373+ strcpy(gp->numb, cur->pb.numb);
374+ gp->type = cur->pb.type;
375+ strcpy(gp->text, cur->pb.text);
376+ gp++;
377+
378+ llist_del(&cur->list);
379+ free(cur);
380+ }
381+ }
382+
383+ usock_cmd_enqueue(ucmd, gu);
384+
385+ break;
386+ case GSMD_PHONEBOOK_RETRIEVE_FIND:
387+ if (len < sizeof(*gph) + sizeof(int))
388+ return -EINVAL;
389+
390+ num = (int *) ((void *)gph + sizeof(*gph));
391+
392+ ucmd = gsmd_ucmd_fill(sizeof(struct gsmd_phonebook)*(*num), GSMD_MSG_PHONEBOOK,
393+ GSMD_PHONEBOOK_RETRIEVE_FIND, 0);
394+ if (!ucmd)
395+ return -ENOMEM;
396+
397+ gp = (struct gsmd_phonebook*) ucmd->buf;
398+
399+ if (!llist_empty(&gu->pb_find_list)) {
400+ llist_for_each_entry_safe(cur, cur2, &gu->pb_find_list, list) {
401+ gp->index = cur->pb.index;
402+ strcpy(gp->numb, cur->pb.numb);
403+ gp->type = cur->pb.type;
404+ strcpy(gp->text, cur->pb.text);
405+ gp++;
406+
407+ llist_del(&cur->list);
408+ free(cur);
409+ }
410+ }
411+
412+ usock_cmd_enqueue(ucmd, gu);
413+ break;
414 default:
415 return -EINVAL;
416 }
417@@ -1468,6 +1610,8 @@
418 newuser->gsmd = g;
419 newuser->subscriptions = 0xffffffff;
420 INIT_LLIST_HEAD(&newuser->finished_ucmds);
421+ INIT_LLIST_HEAD(&newuser->pb_readrg_list);
422+ INIT_LLIST_HEAD(&newuser->pb_find_list);
423
424 llist_add(&newuser->list, &g->users);
425 gsmd_register_fd(&newuser->gfd);