2 * This file is part of hayes-ril.
4 * Copyright (C) 2012 Paul Kocialkowski <contact@paulk.fr>
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <telephony/ril.h>
21 #ifndef _HAYES_RIL_AT_H_
22 #define _HAYES_RIL_AT_H_
28 #define AT_SYNC_LOCK() pthread_mutex_lock(&(at_responses_handling.sync_mutex));
29 #define AT_SYNC_UNLOCK() pthread_mutex_unlock(&(at_responses_handling.sync_mutex));
30 #define AT_ASYNC_LOCK() pthread_mutex_lock(&(at_responses_handling.async_mutex));
31 #define AT_ASYNC_UNLOCK() pthread_mutex_unlock(&(at_responses_handling.async_mutex));
32 #define AT_RESPONSES_LOCK() pthread_mutex_lock(&(at_responses_handling.responses_mutex));
33 #define AT_RESPONSES_UNLOCK() pthread_mutex_unlock(&(at_responses_handling.responses_mutex));
34 #define AT_RESPONSES_QUEUE_LOCK() pthread_mutex_lock(&(at_responses_handling.responses_queue_mutex));
35 #define AT_RESPONSES_QUEUE_UNLOCK() pthread_mutex_unlock(&(at_responses_handling.responses_queue_mutex));
37 #define AT_PARSE_SINGLE_QUOTE (1 << 0)
38 #define AT_PARSE_DOUBLE_QUOTE (1 << 1)
41 * Variables structures
68 AT_STATUS_INTERNAL_ERROR,
73 AT_RESPONSE_UNHANDELD_REASON_DATA,
74 AT_RESPONSE_UNHANDELD_REASON_STATUS,
75 AT_RESPONSE_HANDLED_OK,
76 AT_RESPONSE_HANDLED_ERROR,
79 struct at_responses_queue {
80 struct at_response **responses;
84 typedef int (*at_async_request_cb)(struct at_response *response, void *data, RIL_Token t);
86 struct at_async_request {
95 at_async_request_cb func;
98 struct at_async_queue {
99 struct at_async_request **requests;
103 struct at_responses_handling {
104 pthread_mutex_t responses_queue_mutex;
105 struct at_responses_queue responses_queue;
106 pthread_mutex_t responses_mutex;
108 struct at_async_queue async_queue;
109 pthread_mutex_t async_mutex;
111 struct at_request *sync_request;
112 struct at_response *sync_response;
113 pthread_mutex_t sync_mutex;
121 int at_strings_compare(char *major, char *minor);
122 int at_commands_compare(char *major, char *minor);
123 void at_string_clean(char *string, int length);
124 int at_status_error(int status);
126 // Responses structures processing
127 int at_responses_process(struct at_response ***responses_p, char *data, int length);
128 void at_response_free(struct at_response *response);
129 void at_responses_free(struct at_response **responses, int responses_count);
131 // Responses handling
132 void at_responses_handling_init(void);
135 int at_response_queue(struct at_response *response);
136 struct at_response *at_response_dequeue(void);
139 int at_request_expect_to_func(char *command, void *data, RIL_Token t, at_async_request_cb func);
140 int at_response_expect_to_func(struct at_response *response);
143 int at_request_expect_status(struct at_request *request);
144 int at_response_expect_status(struct at_response *response);
145 int at_expect_status(struct at_request *request);
148 int at_request_send(struct at_request *request);
149 struct at_request *at_request_create(char *command, char *data);
150 void at_request_free(struct at_request *request);
153 int at_send(char *command, char *data);
154 int at_send_command(char *command);
155 int at_send_expect_status(char *command, char *data);
156 int at_send_expect_to_func(char *command, char *data, void *pdata, RIL_Token t, at_async_request_cb func);