comparison src/cs/services/atp/atp_gsm_bt_api.c @ 0:945cf7f506b2

src/cs: chipsetsw import from tcs211-fcmodem binary blobs and LCD demo files have been excluded, all line endings are LF only
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 25 Sep 2016 22:50:11 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:945cf7f506b2
1 /*******************************************************************************
2 *
3 * File Name : atp_gsm_bt_api.c
4 *
5 * This file handles all the interface between GSM AT command handler or Data handler
6 * and the BT protocol stack. It has 2 main functions:
7 * - get the events coming from Bluetooth ATP in direction of GSM, analyse them and
8 * call the proper function of atp_gsm_gsm_api.c
9 * - offer function to GSM so that GSM can use services of the BT PS
10 *
11 *
12 * Version number : 0.1 Date : 10-Jully-2000
13 *
14 * History : 0.1 - Created by E. Baissus
15 *
16 * Author : Eric Baissus : e-baissus@ti.com
17 *
18 * (C) Copyright 2000 by Texas Instruments Incorporated
19 *****************************************************************************/
20
21 #include "rv/rv_general.h"
22 #include "rvf/rvf_api.h"
23 #include "atp/atp_api.h"
24 #include "atp/atp_config.h"
25 #include "atp/atp_messages.h"
26 #include "atp/atp_gsm_bt_api.h"
27 #include "atp/atp_gsm_gsm_api.h"
28 #include "atp/atp_config.h"
29 #include "atp/bti_at.h"
30 #include "atp/atp_i.h"
31 #include "rvm/rvm_use_id_list.h"
32
33 #include <string.h>
34
35 /* Internal definitions */
36
37
38
39 typedef enum
40 {
41 ATP_ACTIVE , // Data exchange in the BT/GSM adapter is on going
42 ATP_NOT_ACTIVE // Data exchange in the BT/GSM adapter is not on going
43 } T_ATP_DATA_ACTIVITY;
44
45 typedef enum
46 {
47 CMD_PENDING, // GSM should be processing a command from BT
48 CMD_NOT_PENDING // GSM can handle a new command issued by BT
49 } T_ATP_GSM_CMD_STATUS;
50
51 typedef struct
52 {
53 UINT32 gsm_tx_data_left; // Number of data left to transmit to ATP
54 T_ATP_DATA_ACTIVITY atp_tx_data_activity; // Indicates if data exchange is on going from BT to GSM
55 T_ATP_GSM_CMD_STATUS cmd_status;
56 UINT32 bt_max_payload;
57 UINT16 tx_head_size;
58 UINT16 tx_trail_size;
59 } T_ATP_GSM_PORT_STRUCT;
60
61
62 /* Definition used only in this file */
63 typedef enum
64 {
65 ATP_GSM_OPEN_PORT_PENDING, // The adaptor is processing an open port
66 ATP_GSM_OPEN_PORT_NOT_PENDING // The adaptor is not processing an open port
67 } T_ATP_GSM_OPEN_PORT_PENDING;
68
69
70
71
72 /* Local variable */
73 static T_ATP_SW_ENTITY_ID atp_gsm_sw_id; /* Any entity needs to register to ATP and then get an id This id will be identify GSM for ATP */
74 static T_ATP_PORT_NB initiator_port_nb; /* Port number used by the SWE requesting a new port to GSM */
75 static T_ATP_SW_ENTITY_ID initiator_id; /* Initiator ID of the SWE requesting to open a port with GSM */
76 static T_ATP_GSM_OPEN_PORT_PENDING open_port_pending; /* Value can be : PORT_PENDING or PORT_NOT_PENDING
77 A port is said to be in PORT_PENDING when a new port
78 has been requested but this new port is not yet created
79 Only one port at a time can be in PORT_PENDING state
80 If open_port_pending is in PORT_PENDING state, then no
81 new port request is processed
82 */
83 static UINT8 current_nb_port; // Indicate number of port actually activated
84 static T_ATP_GSM_PORT_STRUCT * port_array[ATP_MAX_NB_OF_PORT_SUPPORTED_BY_GSM];
85 static UINT32 temp_bt_max_payload; // USed to store BT MFS before the port is actually open
86
87 /* Function definition */
88 static T_RV_RET atp_gsm_init_port(T_ATP_GSM_PORT_STRUCT * port_p);
89 static T_RV_RET atp_gsm_init_if(void);
90 static T_RV_RET atp_gsm_get_new_port_nb(UINT8 * port_nb);
91
92
93
94
95
96 /******************************************************************************
97 * Function name: atp_gsm_bt_event_handle
98 *
99 * Description : Main function used to split the events coming from ATP
100 * and call proper function of GSM side (see atp_gsm_gsm_api.c)
101 *
102 *
103 * Parameters : * ATP message
104 *
105 * Return : No return
106 *
107 *
108 * History : 0.1 (10-Jully-2000)
109 *
110 ******************************************************************************/
111 void atp_gsm_bt_event_handle(void * message_p)
112 {
113
114 T_RV_RET error = RV_OK;
115 T_BTI_PORT_NB port_nb = 0xFF;
116
117
118
119 switch(((T_ATP_MESSAGE *) message_p)->msg_id)
120 {
121 case ATP_OPEN_PORT_IND :
122 {
123 T_BTI_BT_PORT_INFO bt_port_info;
124 rvf_send_trace("ATP/GSM : Received a ATP_OPEN_PORT_IND from ATP ",50,
125 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
126
127 // Store initiator parameters
128 initiator_port_nb=(( T_ATP_OPEN_PORT_IND *) message_p)->initiator_port_nb;
129 initiator_id = (( T_ATP_OPEN_PORT_IND *) message_p)->initiator_id;
130
131 if ((open_port_pending == ATP_GSM_OPEN_PORT_PENDING) || (atp_gsm_get_new_port_nb(&port_nb)!= RV_OK))
132 {
133 // A port opening is pending : refuse to open a new port
134 T_ATP_PORT_INFO dummy_port_info;
135 T_ATP_NO_COPY_INFO dummy_no_copy_info;
136
137 rvf_send_trace("ATP/GSM : Failed to open a port : port opening was pending or max number of port has been reached",97,
138 NULL_PARAM,RV_TRACE_LEVEL_WARNING,ATP_USE_ID);
139
140 /* Initialise to avoid warning */
141 memset(&dummy_port_info,0,sizeof(dummy_port_info));
142 memset(&dummy_no_copy_info,0,sizeof(dummy_no_copy_info));
143
144 // Send a negative response to ATP
145 atp_open_port_rsp((( T_ATP_OPEN_PORT_IND *) message_p)->initiator_id,initiator_port_nb,atp_gsm_sw_id,0,
146 dummy_port_info,dummy_no_copy_info,NULL,OPEN_PORT_NOK);
147 rvf_free_buf( (( T_ATP_OPEN_PORT_IND *) message_p)->custom_info_p );
148 error=RV_NOT_SUPPORTED;
149 }
150
151 // Send open port indication to GSM
152 /////////////// Need to update data packet size
153 bt_port_info.optimal_bt_max_packet_size = ((T_ATP_CUSTOM_TO_GSM_INFO *) (( T_ATP_OPEN_PORT_IND *) message_p)->custom_info_p)->bt_max_payload; // DO NOT CARE ...
154 temp_bt_max_payload = bt_port_info.optimal_bt_max_packet_size; // Store temporaly the MFS
155 open_port_pending=ATP_GSM_OPEN_PORT_PENDING; // Now , an open port is pending
156 bti_at_open_port_ind(port_nb,bt_port_info);
157 rvf_free_buf( (( T_ATP_OPEN_PORT_IND *) message_p)->custom_info_p );
158 break;
159 };
160
161
162 case ATP_PORT_CLOSED :
163 { // A close_port has been issue on BT side
164 rvf_send_trace("ATP/GSM : Received a ATP_PORT_CLOSED from ATP ",50,
165 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
166
167 // Send close port indication to GSM
168 bti_at_close_port_ind((T_BTI_PORT_NB) ((T_ATP_PORT_CLOSED *) message_p)->port_nb);
169 break;
170 };
171
172
173 case ATP_TXT_CMD_RDY :
174 { // A command in text format has been issued by BT side
175 rvf_send_trace("ATP/GSM : Received a ATP_TXT_CMD_RDY from ATP",45,
176 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
177
178 if (((T_ATP_TXT_CMD_RDY *) message_p)->cmd_type == CMD_ABORT)
179 {
180 rvf_send_trace("ATP/GSM : An abort command is requested by ATP ",47,
181 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
182 port_array[((T_ATP_TXT_CMD_RDY *)message_p)->port_nb]->cmd_status = CMD_NOT_PENDING;
183 bti_at_abort_ind((T_BTI_PORT_NB) ((T_ATP_TXT_CMD_RDY *) message_p)->port_nb);
184 }
185 else
186 {
187 rvf_send_trace( ((T_ATP_TXT_CMD_RDY *) message_p)->txt_cmd_p,
188 (UINT8) strlen(((T_ATP_TXT_CMD_RDY *) message_p)->txt_cmd_p),
189 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
190 port_array[((T_ATP_TXT_CMD_RDY *)message_p)->port_nb]->cmd_status = CMD_PENDING;
191 bti_at_cmd_ind((T_BTI_PORT_NB) ((T_ATP_TXT_CMD_RDY *) message_p)->port_nb,
192 (char *) ((T_ATP_TXT_CMD_RDY *) message_p)->txt_cmd_p);
193 }
194
195 atp_free_buffer(((T_ATP_TXT_CMD_RDY *) message_p)->txt_cmd_p);
196 break;
197 };
198
199 case ATP_CMD_RDY :
200 { // A command in binary format has been issued by BT side
201 // This command is ignored since binary format not supported by GSM
202 rvf_send_trace("ATP/GSM : Ignored a ATP_CMD_RDY from ATP",40,
203 NULL_PARAM,RV_TRACE_LEVEL_WARNING, ATP_USE_ID);
204
205 atp_free_buffer(((T_ATP_CMD_RDY *) message_p)->cmd_info_p);
206
207 break;
208 };
209
210
211 case ATP_NO_COPY_DATA_RDY :
212 { // BT side issued a no copy format buffer to GSM
213 // This command is ignored and warning is raised
214 rvf_send_trace("ATP/GSM : Ignored a ATP_NO_COPY_DATA_RDY from ATP ",50,
215 NULL_PARAM,RV_TRACE_LEVEL_WARNING, ATP_USE_ID);
216
217 atp_free_buffer(((T_ATP_NO_COPY_DATA_RDY *) message_p)->atp_buffer_p);
218
219 break;
220 };
221
222
223
224 case ATP_DATA_RDY :
225 { // BT side has sent data to GSM
226 rvf_send_trace("ATP/GSM : Received a ATP_DATA_RDY from ATP . Nb of data = ",58,
227 (UINT32) ((T_ATP_DATA_RDY *)message_p)->nb_bytes,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
228
229 /* If GSM is not currently handling data exchange, call bti_data_rdy */
230 if (port_array[((T_ATP_DATA_RDY *)message_p)->port_nb]->atp_tx_data_activity == ATP_NOT_ACTIVE)
231 {
232 port_array[((T_ATP_DATA_RDY *)message_p)->port_nb]->atp_tx_data_activity =
233 ATP_ACTIVE;
234
235 rvf_send_trace("ATP/GSM : bti_data_ready_ind has been called by BT . Nb_Bytes = ",65,
236 (UINT32) ((T_ATP_DATA_RDY *)message_p)->nb_bytes ,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
237
238 bti_data_ready_ind((T_BTI_PORT_NB) ((T_ATP_DATA_RDY *)message_p)->port_nb,
239 (unsigned long) ((T_ATP_DATA_RDY *)message_p)->nb_bytes);
240
241 }
242 else
243 {
244 UINT8 * dummy_data_buffer = NULL;
245 UINT32 data_left,data_read;
246
247 ATP_SEND_TRACE("ATP/GSM : Wait before sending data to GSM since GSM is already fetching data",
248 RV_TRACE_LEVEL_DEBUG_LOW);
249
250 atp_get_data(atp_gsm_sw_id,((T_ATP_DATA_RDY *)message_p)->port_nb,(UINT8 *) dummy_data_buffer,
251 (UINT32) 0,&data_read,&data_left);
252
253 rvf_send_trace("ATP/GSM : Total number of data to fetch for GSM = ",51,
254 (UINT32) data_left,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
255 }
256
257 break;
258 };
259
260
261
262 case ATP_PORT_MODE_CHANGED :
263 { // BT side has issue a port mode changed (Data or Command)
264 rvf_send_trace("ATP/GSM : Received a ATP_PORT_MODE_CHANGED from ATP",51,
265 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
266
267 if( ((T_ATP_PORT_MODE_CHANGED *) message_p)->mode == ATP_PORT_DATA_MODE)
268 {
269 ATP_SEND_TRACE("ATP/GSM: switch to data mode",RV_TRACE_LEVEL_DEBUG_LOW);
270 ATP_SEND_TRACE("ATP/GSM: BT calls bti_data_ready_cnf in order to accept data from GSM",RV_TRACE_LEVEL_DEBUG_LOW);
271 bti_data_ready_cnf((T_BTI_PORT_NB) ((T_ATP_PORT_MODE_CHANGED *) message_p)->port_nb);
272 }
273 else
274 {
275 ATP_SEND_TRACE("ATP/GSM: port has been switched to command mode by BT",RV_TRACE_LEVEL_DEBUG_LOW);
276 }
277
278 break;
279 };
280
281
282 case ATP_SIGNAL_CHANGED :
283 { // BT side has issued a signal change
284 rvf_send_trace("ATP/GSM : Received a ATP_SIGNAL_CHANGED from ATP",48,
285 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
286
287 if ( ( (((T_ATP_SIGNAL_CHANGED *) message_p)->mask) & ATP_TX_FLOW_UNMASK) != 0)
288 {
289 // change on TX flow
290 if( ( (((T_ATP_SIGNAL_CHANGED *) message_p)->mask) &
291 (((T_ATP_SIGNAL_CHANGED *) message_p)->signal) ) == ATP_TX_FLOW_OFF)
292 {
293 // BT side has switch TX GSM flow to OFF
294 rvf_send_trace("ATP/GSM : ATP requested TX GSM Flow to be OFF",45,
295 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
296 }
297 else
298 {
299 // BT side has switch TX GSM flow to ON
300 rvf_send_trace("ATP/GSM : ATP requested TX GSM Flow to be ON",44,
301 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
302
303 if (port_array[((T_ATP_SIGNAL_CHANGED *) message_p)->port_nb]->gsm_tx_data_left != 0)
304 {
305 // Retry to send data to ATP
306 bti_data_ready_req( (T_BTI_PORT_NB) ((T_ATP_SIGNAL_CHANGED *) message_p)->port_nb,
307 port_array[((T_ATP_SIGNAL_CHANGED *) message_p)->port_nb]->gsm_tx_data_left);
308 }
309 }
310 break;
311 }
312
313 //////////////////////////////////////
314 // Otherwise, ignore the signal change
315 /////////////////////TO BE UPDATED !!! /////////////////
316 rvf_send_trace("ATP/GSM : Signal change has been ignored ",41,
317 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
318
319 break;
320 };
321
322
323 default:
324 {
325 rvf_send_trace("ATP/GSM : Unknown message received from ATP by ATP_GSM => ignored ",66,
326 NULL_PARAM,RV_TRACE_LEVEL_WARNING,ATP_USE_ID);
327 break;
328 };
329 }
330
331 /* Release ATP message buffer */
332 atp_free_message(message_p);
333
334 }
335
336
337
338
339 /******************************************************************************
340 * Function name: bti_at_init_req
341 *
342 * Description : This function is called by GSM to initialise GSM with ATP
343 *
344 *
345 * Parameters : None
346 *
347 * Return : BTI_AT_OK or BTI_AT_INTERNAL_ERR
348 *
349 * History : 0.1 (10-Jully-2000)
350 * : 0.2 (02-Jan-2001)
351 ******************************************************************************/
352 void bti_at_init_req(void)
353 {
354 T_ATP_ENTITY_MODE mode;
355 T_ATP_SW_ENTITY_NAME name;
356 T_ATP_CALLBACK return_path;
357
358 ATP_SEND_TRACE("ATP/GSM : bti_at_init_req has been called by GSM . ",
359 RV_TRACE_LEVEL_DEBUG_LOW);
360
361 /* Static variable initialisation */
362 atp_gsm_init_if();
363
364 /* Register GSM to ATP */
365 strcpy((char *) name,ATP_GSM_NAME);
366 return_path.callback_func = atp_gsm_bt_event_handle;
367 return_path.addr_id = RVF_INVALID_ADDR_ID;
368
369 mode.cmd_mode=TXT_MODE;
370 mode.cp_mode=COPY_ON;
371 mode.cmd_support_mode=CMD_SUPPORT_ON;
372
373 if(atp_reg(name,return_path,mode,&atp_gsm_sw_id)!=RV_OK)
374 {
375 rvf_send_trace("ATP_GSM: GSM entity registration failed ",39, NULL_PARAM ,
376 RV_TRACE_LEVEL_WARNING,ATP_USE_ID);
377 bti_at_init_cnf(BTI_NAK); // Failed registration
378 }
379 else
380 {
381 ATP_SEND_TRACE ("ATP/GSM: GSM entity registration succeeded ",RV_TRACE_LEVEL_DEBUG_LOW);
382 bti_at_init_cnf(BTI_ACK); // Succeeded registration
383 }
384 }
385
386
387
388
389 /******************************************************************************
390 * Function name: bti_at_deinit_ind
391 *
392 * Description : This function is called by GSM (?) to de-initialise GSM from ATP
393 *
394 *
395 * Parameters : None
396 *
397 * Return : BTI_AT_OK or BTI_AT_NOT_SUPPORTED
398 *
399 *
400 * History : 0.1 (10-Jully-2000)
401 *
402 ******************************************************************************/
403 void bti_at_deinit_req(void)
404 {
405 ATP_SEND_TRACE ("ATP_GSM: bti_at_deinit_req has been called by GSM ",RV_TRACE_LEVEL_DEBUG_LOW);
406 atp_dereg(atp_gsm_sw_id);
407 }
408
409
410
411 /******************************************************************************
412 * Function name: bti_at_deinit_res
413 *
414 * Description : This function is called by GSM to de-initialise GSM from ATP
415 *
416 *
417 * Parameters : None
418 *
419 * Return : BTI_AT_OK or BTI_AT_NOT_SUPPORTED
420 *
421 *
422 * History : 0.1 (10-Jully-2000)
423 *
424 ******************************************************************************/
425 void bti_at_deinit_res(void)
426 {
427 // DUMMY FUNCTION
428 }
429
430
431
432 /******************************************************************************
433 * Function name: bti_at_open_port_res
434 *
435 * Description : This function is called by GSM to accept or refuse
436 * an open port request issued by BT side
437 *
438 *
439 *
440 *
441 * History : 0.1 (10-Jully-2000)
442 * : 0.2 (02-Jan-2001)
443 ******************************************************************************/
444 void bti_at_open_port_res(T_BTI_PORT_NB gsm_port_nb,
445 T_BTI_GSM_PORT_INFO gsm_port_info,
446 T_BTI_ACK ack)
447 {
448
449 T_ATP_PORT_INFO port_info ;
450 T_ATP_NO_COPY_INFO no_copy_info ;
451 T_RV_RET return_status;
452 T_ATP_CUSTOM_FROM_GSM_INFO * custom_gsm_info_p;
453 T_ATP_OTHER_PORT_END_INFO other_end_info;
454
455 rvf_send_trace("ATP/GSM : bti_at_open_port_res has been called by GSM . Flag = ",43,
456 (UINT32) ack,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
457 rvf_send_trace("ATP/GSM : gsm_port_nb = ",24,
458 (UINT32) gsm_port_nb,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
459 rvf_send_trace("ATP/GSM : GSM indication for MFS = ",35,
460 (UINT32) gsm_port_info.optimal_gsm_max_packet_size,
461 RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
462
463 /* Get information on the other end port */
464 if (atp_get_info_on_port_end(initiator_id,(T_ATP_PORT_NB) initiator_port_nb,
465 &other_end_info) != RV_OK)
466 {
467 ATP_SEND_TRACE("ATP : Failed to get information on other end port ",
468 RV_TRACE_LEVEL_WARNING);
469 no_copy_info.tx_head_size = 0;
470 no_copy_info.tx_trail_size = 0;
471 }
472 else
473 {
474 no_copy_info.tx_head_size = other_end_info.no_copy_info.rx_head_size;
475 no_copy_info.tx_trail_size = other_end_info.no_copy_info.rx_trail_size;
476 }
477
478
479 /* Initialise port information */
480 no_copy_info.rx_head_mode = RX_HEADER_OFF; // COPY ON mode in RX
481 no_copy_info.tx_head_mode = TX_HEADER_OFF; // COPY OFF mode in TX for optimization
482
483
484 // no_copy_info.tx_head_mode = TX_HEADER_ON; // COPY OFF mode in TX for optimization
485 ////////// SHOULD BE REMOVED IN CASE GSM SEND DATA WITH HEADER AND TRAILER BIT //////
486 no_copy_info.tx_head_size = 0;
487 no_copy_info.tx_trail_size = 0;
488
489 no_copy_info.rx_mb = RVF_INVALID_MB_ID;
490 no_copy_info.tx_mb = RVF_INVALID_MB_ID;
491 no_copy_info.packet_mode = NORMAL_PACKET; /* No L2CAP packet... */
492
493 port_info.dce_mask[0]=0x0000; // Do not care, GSM is not in DCE_ON mode
494 port_info.ring_type=ATP_NO_RING_TYPE;
495 port_info.signal_mask=ATP_TX_FLOW_UNMASK;
496
497 /* Store custom info from GSM */
498 atp_get_buffer(sizeof(T_ATP_CUSTOM_FROM_GSM_INFO),(void **) &custom_gsm_info_p);
499 custom_gsm_info_p->custom_type = ATP_FROM_GSM_INFO;
500 custom_gsm_info_p ->optimal_gsm_max_packet_size = gsm_port_info.optimal_gsm_max_packet_size;
501
502 if (ack == BTI_ACK)
503 {
504 ATP_SEND_TRACE("ATP/GSM : GSM accepted to open a port ", RV_TRACE_LEVEL_DEBUG_LOW);
505 // Initialise a new port
506 atp_get_buffer(sizeof(T_ATP_GSM_PORT_STRUCT),(void **) &(port_array[gsm_port_nb]));
507
508 atp_gsm_init_port(port_array[gsm_port_nb]);
509 port_array[gsm_port_nb]->tx_head_size = no_copy_info.tx_head_size;
510 port_array[gsm_port_nb]->tx_trail_size = no_copy_info.tx_trail_size;
511
512 return_status = atp_open_port_rsp( initiator_id,
513 (T_ATP_PORT_NB) initiator_port_nb,
514 atp_gsm_sw_id,
515 (T_ATP_PORT_NB) gsm_port_nb,
516 port_info,
517 no_copy_info,
518 (T_ATP_CUSTOM_INFO *) custom_gsm_info_p,
519 OPEN_PORT_OK);
520 }
521 else
522 {
523 rvf_send_trace("ATP/GSM : GSM refused the open port ",36,
524 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
525
526 return_status = atp_open_port_rsp( initiator_id,
527 (T_ATP_PORT_NB) initiator_port_nb,
528 atp_gsm_sw_id,
529 (T_ATP_PORT_NB) gsm_port_nb,
530 port_info,
531 no_copy_info,
532 NULL,
533 OPEN_PORT_NOK);
534 }
535
536 if(return_status != RV_OK)
537 {
538 rvf_send_trace("ATP/GSM : Failed to open a port ",33,
539 NULL_PARAM,RV_TRACE_LEVEL_WARNING, ATP_USE_ID);
540 }
541
542 open_port_pending = ATP_GSM_OPEN_PORT_NOT_PENDING;
543 }
544
545
546
547
548 /******************************************************************************
549 * Function name: bti_at_close_port_res
550 *
551 * Description : Not used by BT PS - Port is always closed
552 *
553 * Parameters :
554 *
555 * Return : BTI_AT_OK
556 *
557 * History : 0.1 (10-Jully-2000)
558 *
559 ******************************************************************************/
560 void bti_at_close_port_res(T_BTI_PORT_NB gsm_port_nb)
561 {
562 rvf_send_trace("ATP/GSM : bti_at_close_port_res has been called by GSM . Port nb = ",67,
563 (UINT32) gsm_port_nb,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
564
565 /* Memory Deallocation */
566 rvf_free_buf(port_array[gsm_port_nb]);
567 port_array[gsm_port_nb]=NULL;
568 }
569
570
571
572 /******************************************************************************
573 * Function name: bti_at_cmd_res
574 *
575 * Description : This function is called by GSM to provide result to BT
576 *
577 * Parameters : gsm_port_nb = number of the gsm port
578 * cmd = command in text format
579 *
580 * Return : BTI_AT_OK or BTI_AT_NOT_SUPPORTED
581 *
582 *
583 * History : 0.1 (10-Jully-2000)
584 *
585 ******************************************************************************/
586 void bti_at_cmd_res(T_BTI_PORT_NB gsm_port_nb,
587 char * cmd)
588 {
589 T_ATP_TXT_CMD txt_buffer_p;
590
591 ATP_SEND_TRACE ("ATP/GSM : bti_at_cmd_res has been called by GSM . Result is : ",
592 RV_TRACE_LEVEL_DEBUG_LOW);
593 rvf_send_trace(cmd,(UINT8) strlen(cmd),
594 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
595
596 /* Create a BTF buffer and copy command into. The command must be 0-terminated */
597 atp_get_buffer(strlen(cmd) + 0x00000001,(void **) &txt_buffer_p);
598 strcpy(txt_buffer_p,cmd);
599
600 port_array[gsm_port_nb]->cmd_status = CMD_NOT_PENDING;
601 if (atp_send_txt_cmd(atp_gsm_sw_id,(T_ATP_PORT_NB) gsm_port_nb,
602 RESULT_CODE,(T_ATP_TXT_CMD) txt_buffer_p) != RV_OK)
603 {
604 rvf_send_trace("ATP/GSM : Error when sending a command to ATP ",46,
605 NULL_PARAM,RV_TRACE_LEVEL_WARNING, ATP_USE_ID);
606 }
607 }
608
609
610 /******************************************************************************
611 * Function name: bti_at_cmd_req
612 *
613 * Description : This function is called by GSM to provide preliminary result to BT
614 * The end of the result will be issed via bti_at_cmd_res
615 *
616 * Parameters : gsm_port_nb = number of the gsm port
617 * cmd = command in text format
618 *
619 * Return : BTI_AT_OK or BTI_AT_NOT_SUPPORTED
620 *
621 *
622 * History : 0.1 (10-Jully-2000)
623 *
624 ******************************************************************************/
625 void bti_at_cmd_req(T_BTI_PORT_NB gsm_port_nb,
626 char * cmd)
627 {
628
629 T_ATP_CMD_TYPE cmd_type;
630 T_ATP_TXT_CMD txt_buffer_p;
631 ATP_SEND_TRACE("ATP/GSM : bti_at_cmd_req has been called by GSM. Code is : ",
632 RV_TRACE_LEVEL_DEBUG_LOW);
633 rvf_send_trace(cmd,(UINT8) strlen(cmd),
634 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
635
636 /* Create a BTF buffer and copy command into. The command must be 0-terminated */
637 atp_get_buffer(strlen(cmd) + 0x00000001,(void **) &txt_buffer_p);
638 strcpy(txt_buffer_p,cmd);
639
640 if (port_array[gsm_port_nb]->cmd_status == CMD_PENDING)
641 {
642 cmd_type = PRELIMINARY_RESULT_CODE;
643 }
644 else
645 {
646 cmd_type = UNSOLICITED_RESULT;
647 }
648
649 if (atp_send_txt_cmd(atp_gsm_sw_id,(T_ATP_PORT_NB) gsm_port_nb,cmd_type,
650 (T_ATP_TXT_CMD) txt_buffer_p) != RV_OK)
651 {
652 rvf_send_trace("ATP/GSM : Error when sending a command to ATP ",46,
653 NULL_PARAM,RV_TRACE_LEVEL_WARNING, ATP_USE_ID);
654 }
655
656 bti_at_cmd_cnf(gsm_port_nb); // Accept new results
657 }
658
659
660
661 /******************************************************************************
662 * Function name: bti_at_abort_res
663 *
664 * Description : This function is called by GSM to comfirm a command abort
665 * NOT USED BY ATP YET
666 *
667 * Parameters : gsm_port_nb = number of the gsm port
668 *
669 * Return : BTI_AT_NOT_SUPPORTED
670 *
671 *
672 * History : 0.1 (10-Jully-2000)
673 *
674 ******************************************************************************/
675 void bti_at_abort_res(T_BTI_PORT_NB gsm_port_nb)
676 {
677 rvf_send_trace("ATP/GSM : bti_at_abort_res has been called by GSM . Ignored . Port nb = ",72,
678 (UINT32) gsm_port_nb,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
679
680 // Not implemented yet . Maybe usefull to send a commande back to indicate the abortion has succeede (or failed ...)
681 }
682
683
684 /******************************************************************************
685 * Function name: bti_data_ready_req
686 *
687 * Description : This function is called by GSM to indicate that data are
688 * available for BT PS.
689 *
690 *
691 * Parameters : gsm_port_nb = number of the gsm port
692 * nb_bytes_available = number of bytes of data available
693 *
694 * Return : None
695 *
696 * History : 0.1 (10-Jully-2000)
697 * 0.2 (01-Jan-2001)
698 *
699 ******************************************************************************/
700 void bti_data_ready_req (T_BTI_PORT_NB gsm_port_nb,
701 unsigned long nb_bytes_available)
702 {
703 UINT32 nb_bytes_left,nb_bytes_to_transmit;
704 UINT8 * data_buffer_p;
705
706 rvf_send_trace("ATP/GSM : data_ready_req has been called by GSM . Nb Bytes = ",61,
707 (UINT32) nb_bytes_available,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
708
709 rvf_send_trace("ATP/GSM : Port Number used by GSM = ",37,
710 (UINT32) gsm_port_nb,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
711
712 if (nb_bytes_available !=0)
713 {
714
715 nb_bytes_left= nb_bytes_available; // number of byte to transmit in this function
716
717 while(nb_bytes_left > 0)
718 {
719 if (nb_bytes_left > port_array[gsm_port_nb]->bt_max_payload) // Bigger than allowed MFS
720 {
721 nb_bytes_to_transmit = port_array[gsm_port_nb]->bt_max_payload;
722 }
723 else
724 {
725 nb_bytes_to_transmit = nb_bytes_left;
726 }
727
728
729 /* This code is removed because of an issue with header and trailer size
730 /* It is temporary remplaced by setting to 0 header and trailer */
731 /* atp_buffer_size = nb_bytes_to_transmit + port_array[(T_ATP_PORT_NB) gsm_port_nb]->tx_head_size+
732 // port_array[(T_ATP_PORT_NB) gsm_port_nb]->tx_trail_size;
733 //
734 // rvf_send_trace("ATP/GSM : Buffer_size to send to ATP = ",40,
735 // (UINT32) atp_buffer_size,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
736 //
737 // rvf_send_trace("ATP/GSM : tx_header size = ",27,
738 // (UINT32) port_array[(T_ATP_PORT_NB) gsm_port_nb]->tx_head_size,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
739 //
740 // rvf_send_trace("ATP/GSM : tx_trail size = ",27,
741 // (UINT32) port_array[(T_ATP_PORT_NB) gsm_port_nb]->tx_trail_size,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
742
743
744 if (atp_get_buffer_from_tx_mb(atp_gsm_sw_id,gsm_port_nb,atp_buffer_size,
745 (void **) &data_buffer_p) == RV_OK)
746 {
747 /* Copy GSM data
748 rvf_send_trace("ATP/GSM : BT calls bti_get_gsm_data and request nb Bytes = ",59,
749 (UINT32) nb_bytes_to_transmit,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
750
751 bti_get_gsm_data(gsm_port_nb,(char *) &(data_buffer_p[port_array[(T_ATP_PORT_NB) gsm_port_nb]->tx_head_size]),nb_bytes_to_transmit);
752 atp_no_copy_send_data(atp_gsm_sw_id,gsm_port_nb,data_buffer_p,nb_bytes_to_transmit);
753 nb_bytes_left -= nb_bytes_to_transmit;
754 port_array[gsm_port_nb]->gsm_tx_data_left = nb_bytes_left;
755 }
756 else
757 {
758 port_array[gsm_port_nb]->gsm_tx_data_left = nb_bytes_left;
759 nb_bytes_left = 0; // Flow control has been activated : wait for FLOW ON flag
760 } */
761
762 ///////// START REPLACEMENT CODE ////////////////
763
764
765 if (atp_get_buffer_from_tx_mb(atp_gsm_sw_id,gsm_port_nb,nb_bytes_to_transmit,
766 (void **) &data_buffer_p) == RV_OK)
767 {
768 /* Copy GSM data */
769 rvf_send_trace("ATP/GSM : BT calls bti_get_gsm_data and request nb Bytes = ",59,
770 (UINT32) nb_bytes_to_transmit,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
771
772 bti_get_gsm_data(gsm_port_nb,(char *) (data_buffer_p),nb_bytes_to_transmit);
773 atp_no_copy_send_data(atp_gsm_sw_id,gsm_port_nb,data_buffer_p,nb_bytes_to_transmit);
774 nb_bytes_left -= nb_bytes_to_transmit;
775 port_array[gsm_port_nb]->gsm_tx_data_left = nb_bytes_left;
776 }
777 else
778 {
779 port_array[gsm_port_nb]->gsm_tx_data_left = nb_bytes_left;
780 nb_bytes_left = 0; // Flow control has been activated : wait for FLOW ON flag
781 }
782
783 // for (i=0;i<nb_bytes_to_transmit;i++)
784 // {
785 // rvf_send_trace("ATP/GSM : byte received from GSM = ",
786 // 36, (UINT32) (data_buffer_p[i]) ,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
787 // }
788
789 }
790 ///////// END REPLACEMENT CODE ////////////////
791
792
793 if (port_array[gsm_port_nb]->gsm_tx_data_left == 0)
794 {
795 ATP_SEND_TRACE("ATP/GSM: BT got all the data from GSM . BT calls bti_data_ready_cnf ",RV_TRACE_LEVEL_DEBUG_LOW);
796 bti_data_ready_cnf(gsm_port_nb); // Acknowledge data copy to GSM
797 }
798 }
799 }
800
801
802
803
804
805
806 /******************************************************************************
807 * Function name: bti_get_bt_data
808 *
809 * Description : This function is called by GSM to get data from BT side .
810 * Copy is processed by BT side
811 *
812 * Parameters : gsm_port_nb = number of the gsm port
813 * data_buffer = pointer on a buffer in which data can be copied
814 * nb_bytes_to_copy = number of bytes to copy into data_buffer
815 *
816 * Return : None
817 *
818 *
819 * History : 0.1 (10-Jully-2000)
820 * 0.2 (01-Jan-2001)
821 *
822 ******************************************************************************/
823 void bti_get_bt_data (T_BTI_PORT_NB gsm_port_nb,
824 char * data_buffer,
825 unsigned long nb_bytes_to_copy)
826 {
827 UINT32 data_left,data_read;
828
829
830 rvf_send_trace("ATP/GSM : bti_get_bt_data has been called by GSM . Requested nb of data = ",
831 74, (UINT32) nb_bytes_to_copy ,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
832
833 if ( (atp_get_data(atp_gsm_sw_id,gsm_port_nb,(UINT8 *) data_buffer,
834 (UINT32) nb_bytes_to_copy,&data_read,&data_left) != RV_OK) ||
835 (data_read != (UINT32) nb_bytes_to_copy))
836 {
837 ATP_SEND_TRACE("ATP/GSM : Could not get data from BT for GSM",RV_TRACE_LEVEL_ERROR);
838 }
839
840 // for (i=0;i<nb_bytes_to_copy;i++)
841 // {
842 // rvf_send_trace("ATP/GSM : byte sent to GSM = ",
843 // 29, (UINT32) (data_buffer[i]) ,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
844 // }
845
846 }
847
848
849 /******************************************************************************
850 * Function name: bti_data_ready_res
851 *
852 * Description : This function is called by GSM to indicate that it can receive
853 * new data from BT PS
854 *
855 *
856 * Parameters : gsm_port_nb = number of the gsm port
857 *
858 * Return : None
859 *
860 * History : 0.1 (10-Jully-2000)
861 * 0.2 (01-Jan-2001)
862 *
863 ******************************************************************************/
864 void bti_data_ready_res (T_BTI_PORT_NB gsm_port_nb)
865 {
866 UINT8 * dummy_data_buffer = NULL;
867 UINT32 data_left,data_read;
868
869 rvf_send_trace("ATP/GSM : bti_data_ready_res has been called by GSM ",52,
870 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
871
872 rvf_send_trace("ATP/GSM : port_number = ",25,
873 (UINT32) gsm_port_nb,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
874
875 /* Use the function atp_get_data to check if there are still data to transmit */
876 if (atp_get_data(atp_gsm_sw_id,gsm_port_nb,(UINT8 *) dummy_data_buffer,
877 (UINT32) 0,&data_read,&data_left) != RV_OK)
878 {
879 ATP_SEND_TRACE("ATP/GSM : Could not get number of data to read from BT to GSM ",RV_TRACE_LEVEL_ERROR);
880 }
881 else
882 {
883 rvf_send_trace("ATP/GSM : data_left = ",22,
884 (UINT32) data_left,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
885
886
887 if (data_left != 0)
888 {
889 rvf_send_trace("ATP/GSM : bti_data_ready_ind has been called by BT . Nb_Bytes = ",65,
890 (UINT32) data_left ,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
891
892 bti_data_ready_ind(gsm_port_nb,(unsigned long) data_left);
893 }
894 else
895 {
896 port_array[gsm_port_nb]->atp_tx_data_activity =
897 ATP_NOT_ACTIVE;
898 ATP_SEND_TRACE("ATP/GSM : ATP is ready to send new data to GSM ."
899 ,RV_TRACE_LEVEL_DEBUG_LOW);
900
901 }
902 }
903 }
904
905
906 /******************************************************************************
907 * Function name: atp_gsm_init_if
908 *
909 * Description : This function initialise the GSM/BT adaptor
910 *
911 *
912 *
913 *
914 * Return : RV_OK
915 *
916 * History : 0.1 (10-Jully-2000)
917 *
918 ******************************************************************************/
919 T_RV_RET atp_gsm_init_if(void)
920 {
921 UINT8 i;
922
923 open_port_pending = ATP_GSM_OPEN_PORT_NOT_PENDING;
924 atp_gsm_sw_id = ATP_INVALID_SWE_ID;
925 initiator_id = ATP_INVALID_SWE_ID;
926 initiator_port_nb = (T_ATP_PORT_NB) 0xFF;
927 current_nb_port = 0;
928 for (i=0;i<ATP_MAX_NB_OF_PORT_SUPPORTED_BY_GSM;i++)
929 {
930 port_array[i]=NULL;
931 }
932
933 return RV_OK;
934 }
935
936
937
938 /******************************************************************************
939 * Function name: bti_at_signal_change_req
940 *
941 * Description : This function is called by GSM to provide a new signal line status
942 * to BT
943 *
944 *
945 * Parameters : gsm_port_nb = number of the gsm port
946 * dce_signal = signal value
947 * ring_type_1 = voice, data or fax
948 * ring_type_2 = not used
949 *
950 * Return : None
951 *
952 * History : 0.1 (01-Jan-2001)
953 *
954 ******************************************************************************/
955 void bti_at_signal_change_req (T_BTI_PORT_NB gsm_port_nb,
956 T_BTI_AT_DCE_SIGNAL dce_signal,
957 T_BTI_AT_RING_TYPE ring_type_1,
958 T_BTI_AT_RING_TYPE ring_type_2)
959 {
960 T_ATP_PORT_SIGNAL old_signal,new_signal = 0;
961 T_ATP_SIGNAL_CHANGE_MASK mask = 0 ;
962
963 ATP_SEND_TRACE("ATP/GSM : bti_at_signal_change_req has been called by GSM ",
964 RV_TRACE_LEVEL_DEBUG_LOW);
965
966 atp_get_signal(atp_gsm_sw_id,gsm_port_nb,&old_signal);
967
968 if ( (dce_signal & BTI_AT_RING_MASK) == BTI_AT_RING_ON) // RING is ON
969 {
970 if ( (old_signal & ATP_RI_UNMASK) == ATP_RI_0) // RING is ON and was previously OFF
971 {
972 T_ATP_RING_TYPE atp_ring_type;
973 T_ATP_SW_NB sender_sw_nb;
974 T_ATP_PORT_STRUCT * port_p;
975
976 switch (ring_type_1)
977 {
978
979 /* Transparent data */
980 case BTI_AT_RING_Async:
981 {
982 atp_ring_type = ATP_DATA_RING_TYPE;
983 ATP_SEND_TRACE("ATP/GSM : RING_OFF -> RING_ON (Transparent data) "
984 ,RV_TRACE_LEVEL_DEBUG_LOW);
985 break;
986 }
987
988 /* Non transparent data */
989 case BTI_AT_RING_RelAsync:
990 {
991 atp_ring_type = ATP_DATA_RING_TYPE;
992 ATP_SEND_TRACE("ATP/GSM : RING_OFF -> RING_ON (Non-transparent data) "
993 ,RV_TRACE_LEVEL_DEBUG_LOW);
994 break;
995 }
996
997 /* Fax */
998 case BTI_AT_RING_Fax:
999 {
1000 atp_ring_type = ATP_FAX_RING_TYPE;
1001 ATP_SEND_TRACE("ATP/GSM : RING_OFF -> RING_ON (Fax) "
1002 ,RV_TRACE_LEVEL_DEBUG_LOW);
1003 break;
1004 }
1005
1006 /* Voice */
1007 case BTI_AT_RING_Voice:
1008 {
1009 atp_ring_type = ATP_VOICE_RING_TYPE;
1010 ATP_SEND_TRACE("ATP/GSM : RING_OFF -> RING_ON (Voice) "
1011 ,RV_TRACE_LEVEL_DEBUG_LOW);
1012 break;
1013 }
1014
1015 /* Not used */
1016 default:
1017 {
1018 atp_ring_type = ATP_NO_RING_TYPE;
1019 ATP_SEND_TRACE("ATP/GSM : RING_OFF -> RING_ON (Meaningless) "
1020 ,RV_TRACE_LEVEL_DEBUG_LOW);
1021 break;
1022 }
1023 } // End of switch
1024
1025 /* Get the pointer on the port structure */
1026 if(atp_get_port(atp_gsm_sw_id,gsm_port_nb,&port_p,&sender_sw_nb) != RV_OK)
1027 {
1028 atp_error_switch(ATP_ERROR_FAILED_TO_HANDLE_SIGNAL,ATP_PARAM_ERROR,NULL);
1029 return; /* This port does not exist */
1030 }
1031 if (atp_ring_type & port_p->port_info[(~sender_sw_nb)].ring_type)
1032 {
1033 new_signal |= ATP_RI_1;
1034 mask |= ATP_RI_UNMASK;
1035 }
1036 }
1037 }
1038 else
1039 {
1040 if ( (old_signal & ATP_RI_UNMASK) == ATP_RI_1) // RING is OFF and was previously ON
1041 {
1042 T_ATP_RING_TYPE atp_ring_type;
1043 T_ATP_SW_NB sender_sw_nb;
1044 T_ATP_PORT_STRUCT * port_p;
1045
1046 switch (ring_type_1)
1047 {
1048 /* Transparent data */
1049 case BTI_AT_RING_Async:
1050 {
1051 atp_ring_type = ATP_DATA_RING_TYPE;
1052 ATP_SEND_TRACE("ATP/GSM : RING_ON -> RING_OFF (Transparent data) "
1053 ,RV_TRACE_LEVEL_DEBUG_LOW);
1054 break;
1055 }
1056
1057 /* Non transparent data */
1058 case BTI_AT_RING_RelAsync:
1059 {
1060 atp_ring_type = ATP_DATA_RING_TYPE;
1061 ATP_SEND_TRACE("ATP/GSM : RING_ON -> RING_OFF (Non-transparent data) "
1062 ,RV_TRACE_LEVEL_DEBUG_LOW);
1063 break;
1064 }
1065
1066 /* Fax */
1067 case BTI_AT_RING_Fax:
1068 {
1069 atp_ring_type = ATP_FAX_RING_TYPE;
1070 ATP_SEND_TRACE("ATP/GSM : RING_ON -> RING_OFF (Fax) "
1071 ,RV_TRACE_LEVEL_DEBUG_LOW);
1072 break;
1073 }
1074
1075 /* Voice */
1076 case BTI_AT_RING_Voice:
1077 {
1078 atp_ring_type = ATP_VOICE_RING_TYPE;
1079 ATP_SEND_TRACE("ATP/GSM : RING_ON -> RING_OFF (Voice) "
1080 ,RV_TRACE_LEVEL_DEBUG_LOW);
1081 break;
1082 }
1083
1084 /* Not used */
1085 default:
1086 {
1087 atp_ring_type = ATP_NO_RING_TYPE;
1088 ATP_SEND_TRACE("ATP/GSM : RING_ON -> RING_OFF (Meaningless) "
1089 ,RV_TRACE_LEVEL_DEBUG_LOW);
1090 break;
1091 }
1092 } // End of switch
1093
1094
1095 /* Get the pointer on the port structure */
1096 if(atp_get_port(atp_gsm_sw_id,gsm_port_nb,&port_p,&sender_sw_nb) != RV_OK)
1097 {
1098 atp_error_switch(ATP_ERROR_FAILED_TO_HANDLE_SIGNAL,ATP_PARAM_ERROR,NULL);
1099 return; /* This port does not exist */
1100 }
1101
1102 if (atp_ring_type & port_p->port_info[(~sender_sw_nb)].ring_type)
1103 {
1104 new_signal |= ATP_RI_0;
1105 mask |= ATP_RI_UNMASK;
1106 }
1107
1108
1109 }
1110 }
1111
1112 if ( (dce_signal & BTI_AT_DCD_MASK) == BTI_AT_DCD_ON) // DCD is ON
1113 {
1114 if ( (old_signal & ATP_DCD_UNMASK) == ATP_DCD_0) // DCD is ON and was previously OFF
1115 {
1116 new_signal |= ATP_DCD_1;
1117 mask |= ATP_DCD_UNMASK;
1118 ATP_SEND_TRACE("ATP/GSM : DCD_OFF -> DCD_ON ",
1119 RV_TRACE_LEVEL_DEBUG_LOW);
1120 }
1121 }
1122 else
1123 {
1124 if ( (old_signal & ATP_DCD_UNMASK) == ATP_DCD_1) // DCD is OFF and was previously ON
1125 {
1126 new_signal |= ATP_DCD_0;
1127 mask |= ATP_DCD_UNMASK;
1128 ATP_SEND_TRACE("ATP/GSM : DCD_ON -> DCD_OFF ",
1129 RV_TRACE_LEVEL_DEBUG_LOW);
1130 }
1131 }
1132 if (mask != 0x00)
1133 {
1134 atp_set_signal(atp_gsm_sw_id,gsm_port_nb,new_signal,mask);
1135 }
1136 }
1137
1138
1139
1140 /******************************************************************************
1141 * Function name: atp_gsm_init_port
1142 *
1143 * Description : This function initialise the variable related to a port
1144 *
1145 *
1146 *
1147 *
1148 * Return : RV_OK
1149 *
1150 * History : 0.1 (10-Jully-2000)
1151 *
1152 ******************************************************************************/
1153 T_RV_RET atp_gsm_init_port(T_ATP_GSM_PORT_STRUCT * port_p)
1154 {
1155 port_p->cmd_status = CMD_NOT_PENDING;
1156 port_p->gsm_tx_data_left = 0;
1157 port_p->atp_tx_data_activity = ATP_NOT_ACTIVE;
1158 port_p->bt_max_payload = temp_bt_max_payload;
1159 return RV_OK;
1160 }
1161
1162
1163 /******************************************************************************
1164 * Function name: atp_gsm_get_new_port_nb
1165 *
1166 * Description : Provide a new available port number if possible. Otherwise, return
1167 * error
1168 *
1169 *
1170 *
1171 * Return : RV_OK
1172 *
1173 * History : 0.1 (10-Jully-2000)
1174 *
1175 ******************************************************************************/
1176 T_RV_RET atp_gsm_get_new_port_nb(UINT8 * port_nb)
1177 {
1178 UINT8 i;
1179
1180 for(i=0;i<ATP_MAX_NB_OF_PORT_SUPPORTED_BY_GSM;i++)
1181 {
1182 if (port_array[i] == NULL)
1183 {
1184 *port_nb = i;
1185 return RV_OK;
1186 }
1187 }
1188 *port_nb = 0xFF;
1189 return RV_NOT_SUPPORTED;
1190 }