AT: Added AT response parsing engine
[hayes-ril.git] / hayes-ril.h
1 /**
2  * This file is part of hayes-ril.
3  *
4  * Copyright (C) 2012 Paul Kocialkowski <contact@paulk.fr>
5  * 
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #include <at.h>
20
21 #ifndef _HAYES_RIL_H_
22 #define _HAYES_RIL_H_
23
24 #define RIL_DEVICE_LOCK(ril_device_p) pthread_mutex_lock(&(ril_device_p->handlers->transport->mutex));
25 #define RIL_DEVICE_UNLOCK(ril_device_p) pthread_mutex_unlock(&(ril_device_p->handlers->transport->mutex));
26
27 #define DEV_GSM         RIL_DEVICE_TYPE_GSM
28 #define DEV_CDMA        RIL_DEVICE_TYPE_CDMA
29
30 extern struct ril_device *ril_device;
31
32 enum ril_device_type {
33         RIL_DEVICE_TYPE_GSM,
34         RIL_DEVICE_TYPE_CDMA
35 };
36
37 struct ril_device_power_handlers {
38         void *sdata;
39         int (*sdata_create)(void **sdata);
40         int (*sdata_destroy)(void *sdata);
41
42         int (*power_on)(void *sdata);
43         int (*power_off)(void *sdata);
44
45         int (*suspend)(void *sdata);
46         int (*resume)(void *sdata);
47
48         int (*boot)(void *sdata);
49 };
50
51 struct ril_device_transport_handlers {
52         void *sdata;
53         int (*sdata_create)(void **sdata);
54         int (*sdata_destroy)(void *sdata);
55
56         int (*open)(void *sdata);
57         int (*close)(void *sdata);
58
59         int (*send)(void *sdata, void **data, int length);
60         int (*recv)(void *sdata, void **data, int length);
61
62         int (*recv_poll)(void *sdata);
63
64         pthread_t recv_thread;
65         pthread_mutex_t mutex;
66 };
67
68 struct ril_device_handlers {
69         struct ril_device_power_handlers *power;
70         struct ril_device_transport_handlers *transport;
71 };
72
73 struct ril_device {
74         char *name;
75         void *sdata;
76
77         enum ril_device_type type;
78         struct ril_device_handlers *handlers;
79 };
80
81 // Device
82 void ril_device_register(struct ril_device **ril_device_p);
83 int ril_device_init(struct ril_device *ril_device_p);
84 int ril_device_deinit(struct ril_device *ril_device_p);
85
86 int ril_device_data_create(struct ril_device *ril_device_p);
87 int ril_device_data_destroy(struct ril_device *ril_device_p);
88 int ril_device_boot(struct ril_device *ril_device_p);
89 int ril_device_boot(struct ril_device *ril_device_p);
90 int ril_device_power_on(struct ril_device *ril_device_p);
91 int ril_device_power_off(struct ril_device *ril_device_p);
92 int ril_device_open(struct ril_device *ril_device_p);
93 int ril_device_close(struct ril_device *ril_device_p);
94 int ril_device_send(struct ril_device *ril_device_p, void *data, int length);
95 int ril_device_recv(struct ril_device *ril_device_p, void **data, int length);
96 int ril_device_recv_poll(struct ril_device *ril_device_p);
97 int ril_device_recv_thread_start(struct ril_device *ril_device_p);
98
99 #endif