comparison chipsetsw/services/atp/atp_spp_api.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 /*******************************************************************************
2 *
3 * File Name : atp_spp_apif.c
4 *
5 * Functions Handling the interface between ATP and SPP SW entity
6 *
7 * (C) Texas Instruments, all rights reserved
8 *
9 * Version number : 0.1 Date : 16-Marsh-2000
10 *
11 * History : 0.1 - Created by E. Baissus
12 * 0.9 - Updated based on new SPP version and reviewed
13 *
14 * Author : Eric Baissus : e-baissus@ti.com
15 *
16 * (C) Copyright 2000 by Texas Instruments Incorporated, All Rights Reserved
17 ******************************************************************************/
18
19 #include "rv/rv_general.h"
20 #include "rvf/rvf_api.h"
21 #include "atp/atp_i.h"
22 #include "atp/atp_api.h"
23 #include "spp_general.h"
24 #include "atp/atp_config.h"
25 #include "atp/atp_spp_api.h"
26 #include "atp/atp_messages.h"
27 #include "spp_structs.h"
28 #include "spp_messages.h"
29 #include "spp_up_interface.h"
30 #include "atp/atp_spp_api_i.h"
31 #include "l2cap_data_hdlr.h" /* For L2CAP data handling */
32 #include "rvm/rvm_use_id_list.h"
33 #include <string.h>
34
35 /* Local variable */
36 static T_ATP_SW_ENTITY_ID atp_spp_sw_id;
37 static T_RVF_MB_ID spp_if_mb;
38 static T_RVF_ADDR_ID spp_addr_id = RVF_INVALID_ADDR_ID;
39 static T_ATP_SPP_PENDING_PORT_INFO pending_port_info[ATP_SPP_MAX_PENDING_PORT]; /* contains intermediate information during open port procedure */
40
41
42
43 /******************************************************************************
44 * Function name: atp_spp_from_spp_if_ft
45 *
46 * Description : Main function used to split the events coming from SPP
47 * and to forward to ATP
48 *
49 *
50 * Parameters : * message
51 *
52 * Return : Standard error
53 * RV_OK if OK
54 *
55 * History : 0.1 (17-Marsh-2000)
56 *
57 ******************************************************************************/
58 void atp_spp_from_spp_if_ft(void * message_p)
59 {
60
61 T_RV_RET error;
62
63 error = RV_OK;
64
65 switch(((T_RV_HDR *)message_p)->msg_id)
66 {
67 case SPP_OPEN_PORT_CFM_EVT :
68 {
69 rvf_send_trace("ATP/SPP : Received a SPP_OPEN_PORT_CFM from SPP ",50,
70 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
71
72 error=atp_spp_open_port_rsp((void *) message_p,ATP_SPP_IS_CFM);
73 /* RV_OK or MEMORY ERROR or RV_NOT_SUPPORTED*/
74
75 break;
76 };
77
78
79 case SPP_OPEN_PORT_IND_EVT :
80 {
81 rvf_send_trace("ATP/SPP : Received a SPP_OPEN_PORT_IND from SPP ",50,
82 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
83
84 error=atp_spp_open_port_rsp((void *) message_p,ATP_SPP_IS_IND);
85 /* RV_OK or RV_MEMORY_ERR or RV_NOT_SUPPORTED*/
86
87 break;
88 };
89
90
91 case SPP_CLOSE_PORT_IND_EVT :
92 {
93
94 rvf_send_trace("ATP/SPP : Received a SPP_CLOSE_PORT_IND from SPP ",50,
95 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
96
97 error=atp_close_port(atp_spp_sw_id,(T_ATP_PORT_NB) (((T_SPP_CLOSE_PORT_IND *) message_p)->handle));
98 /* RV_OK or MEMORY ERROR or NOT_SUPPORTED*/
99
100 /* Close server in case the port has been open is server mode */
101 if ( ( ((T_SPP_CLOSE_PORT_IND *) message_p)->handle & SPP_HANDLE_TYPE) == SPP_SERVER_HANDLE_FLAG)
102 {
103 T_SPP_CLOSE_SERV * close_server_p;
104
105 if (rvf_get_buf (spp_if_mb,sizeof(T_SPP_CLOSE_SERV),(void **) &close_server_p)==RVF_RED)
106 {
107 error = RV_MEMORY_ERR;
108 }
109 close_server_p->handle = ((T_ATP_CMD_RDY *) message_p)->port_nb;
110 close_server_p->os_hdr.msg_id = SPP_CLOSE_SERV_EVT;
111
112 rvf_send_trace("ATP/SPP : Send a SPP_CLOSE_SERV to SPP ",40,
113 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
114
115 rvf_send_msg (spp_addr_id,close_server_p);
116 }
117
118 break;
119 };
120
121 case SPP_CLOSE_PORT_CFM_EVT : /* Acknowledge the port has been actually closed */
122 {
123
124 rvf_send_trace("ATP/SPP : Received a SPP_CLOSE_PORT_CFM from SPP ",50,
125 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
126
127 /* Close server in case the port has been open is server mode */
128 if ( ( ((T_ATP_PORT_CLOSED *) message_p)->port_nb & SPP_HANDLE_TYPE) == SPP_SERVER_HANDLE_FLAG)
129 {
130
131 T_SPP_CLOSE_SERV * close_server_p;
132
133 if (rvf_get_buf (spp_if_mb,sizeof(T_SPP_CLOSE_SERV),(void **) &close_server_p)==RVF_RED)
134 {
135 error = RV_MEMORY_ERR;
136 }
137 close_server_p->handle = ((T_SPP_CLOSE_PORT_CFM *) message_p)->handle;
138 close_server_p->os_hdr.msg_id = SPP_CLOSE_SERV_EVT;
139
140 rvf_send_trace("ATP/SPP : Send a SPP_CLOSE_SERV to SPP ",40,
141 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
142
143 rvf_send_msg (spp_addr_id,close_server_p);
144 }
145
146 break;
147 };
148
149
150
151 case SPP_RECV_DATA_EVT :
152 {
153 rvf_send_trace("ATP/SPP : Received a SPP_RECV_DATA_EVT from SPP ",50,
154 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
155 error=atp_no_copy_send_data(atp_spp_sw_id,
156 (T_ATP_PORT_NB) ((T_SPP_RECV_DATA_NC *) message_p)->handle,
157 (T_ATP_BUFFER)(((T_SPP_RECV_DATA_NC *) message_p)->l2cap_acl_data),
158 ((UINT32) ((T_SPP_RECV_DATA_NC *) message_p)->l2cap_acl_data->len));
159 /* RV_OK or MEMORY ERROR */
160 break;
161 };
162
163 case SPP_RETURN_MAX_PAYLOAD_EVT:
164 {
165 UINT16 * max_payload_p;
166
167 rvf_send_trace("ATP/SPP : Received a SPP_RETURN_MAX_PAYLOAD_EVT from SPP ",57,
168 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
169 rvf_send_trace("ATP/SPP : Send custom command ATP_FROM_SPP_MAX_PAYLOAD_IND_CMD to ATP ",70,
170 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
171
172 if (rvf_get_buf (spp_if_mb,sizeof(UINT32),(void **) &max_payload_p)==RVF_RED)
173 {
174 error=RV_MEMORY_ERR;
175 }
176 else
177 {
178 *max_payload_p = ((T_SPP_RETURN_MAX_PAYLOAD *) message_p)->max_payload_length;
179 error=atp_send_cmd(atp_spp_sw_id,
180 (T_ATP_PORT_NB) ((T_SPP_RETURN_MAX_PAYLOAD *) message_p)->handle,
181 CUSTOM_CMD,ATP_FROM_SPP_MAX_PAYLOAD_IND_CMD,max_payload_p);
182 }
183 break;
184 }
185
186
187 case SPP_RETURN_ERROR_EVT:
188 {
189 rvf_send_trace("ATP/SPP : Received a SPP_RETURN_ERROR_EVT from SPP ",51,
190 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
191 rvf_send_trace("ATP/SPP : This event is not taken into account yet by ATP ",60,
192 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
193 break;
194 }
195
196
197 case SPP_RETURN_MODEM_PARAM_EVT:
198 {
199 rvf_send_trace("ATP/SPP : Received a SPP_RETURN_MODEM_PARAM_EVT from SPP ",57,
200 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
201 rvf_send_trace("ATP/SPP : This event is not taken into account yet by ATP ",60,
202 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
203 break;
204 }
205
206 case SPP_RETURN_LINE_STS_EVT:
207 {
208 rvf_send_trace("ATP/SPP : Received a SPP_RETURN_LINE_STS_EVT from SPP ",54,
209 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
210 error=atp_spp_set_atp_signals(( T_SPP_LINE_STS *) message_p);
211 break;
212 }
213
214
215 default:
216 {
217 rvf_send_trace("ATP/SPP : A message received from ATP by ATP_SPP has been ignored ",66,
218 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_HIGH, ATP_USE_ID);
219 break;
220 };
221 }
222
223 /* Release SPP message buffer */
224 rvf_free_buf(message_p);
225
226 if (error != RV_OK)
227 {
228 rvf_send_trace("ATP/SPP : An error has been encountered when processing a message from SPP ",75,
229 NULL_PARAM,RV_TRACE_LEVEL_WARNING, ATP_USE_ID);
230 }
231
232 }
233
234
235
236
237 /******************************************************************************
238 * Function name: atp_spp_to_spp_if_ft
239 *
240 * Description : Main function used to split the events coming from ATP
241 * and forwarded to SPP
242 *
243 *
244 * Parameters : * message
245 *
246 * Return : Standard error
247 * RV_OK if OK
248 *
249 * History : 0.1 (17-Marsh-2000)
250 *
251 ******************************************************************************/
252 void atp_spp_to_spp_if_ft( void * message_p)
253 {
254
255 T_RV_RET error;
256
257 error = RV_OK;
258
259
260 switch(((T_ATP_MESSAGE *) message_p)->msg_id)
261 {
262 case ATP_OPEN_PORT_IND :
263 {
264 rvf_send_trace("ATP/SPP : Received a ATP_OPEN_PORT_IND from ATP ",50,
265 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
266
267
268 error=atp_spp_open_port_rqst((T_ATP_OPEN_PORT_IND *) message_p);
269 /* RV_OK or MEMORY ERROR */
270
271 break;
272 };
273
274
275 case ATP_PORT_CLOSED :
276 {
277 rvf_send_trace("ATP/SPP : Received a ATP_PORT_CLOSED from ATP ",50,
278 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
279
280 error=atp_spp_port_closed_from_atp((T_ATP_PORT_CLOSED *) message_p);
281
282 break;
283 };
284
285 case ATP_CMD_RDY :
286 {
287
288 rvf_send_trace("ATP/SPP : Received a ATP_CMD_RDY from ATP ",50,
289 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
290
291 rvf_send_trace("ATP/SPP : Command has been ignored ",35,
292 NULL_PARAM,RV_TRACE_LEVEL_WARNING, ATP_USE_ID);
293 break;
294 };
295
296 case ATP_SIGNAL_CHANGED :
297 {
298 error = atp_spp_set_spp_signals ((T_ATP_SIGNAL_CHANGED *) message_p);
299 break;
300 };
301
302
303
304 case ATP_ERROR :
305 {
306 rvf_send_trace("ATP/SPP : Received a ATP_ERROR from ATP ",41,
307 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
308 rvf_send_trace("ATP/SPP : This event is not taken into account yet by ATP ",60,
309 NULL_PARAM,RV_TRACE_LEVEL_WARNING, ATP_USE_ID);
310 break;
311 };
312
313 case ATP_NO_COPY_DATA_RDY :
314 {
315 rvf_send_trace("ATP/SPP : Received a ATP_NO_COPY_DATA_RDY from ATP",50,
316 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
317
318 error=atp_spp_send_to_spp_buffer_nc((T_ATP_NO_COPY_DATA_RDY *) message_p);
319
320 /* RV_OK or MEMORY ERROR */
321
322 break;
323 };
324
325 default:
326 {
327 rvf_send_trace("ATP/SPP : A message received from ATP by ATP_SPP has been ignored ",66,
328 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_HIGH, ATP_USE_ID);
329 break;
330 };
331 }
332
333 /* Release ATP message buffer */
334 atp_free_message(message_p);
335
336 if (error != RV_OK)
337 {
338 rvf_send_trace("ATP/SPP : An error has been encountered when processing a message from ATP ",75,
339 NULL_PARAM,RV_TRACE_LEVEL_WARNING, ATP_USE_ID);
340 }
341
342 }
343
344
345
346
347
348 /*********************************************************************************
349 *
350 * Function name: atp_spp_reg
351 *
352 * Description: Used to register spp to ATP
353 *
354 * Parameters: None
355 *
356 * Return:
357 *
358 * History: 0.1 (11-Aug-2000)
359 *
360 *********************************************************************************/
361 T_RV_RET atp_spp_reg(void)
362 {
363 T_ATP_ENTITY_MODE mode;
364 T_ATP_SW_ENTITY_NAME name;
365 T_ATP_CALLBACK return_path;
366
367 /* Register SPP to ATP */
368 strcpy((char *) name,ATP_SPP_NAME);
369 return_path.callback_func = atp_spp_to_spp_if_ft;
370 mode.cmd_mode=INTERPRETED_MODE; /* Do not care : DCE EMU is ON */
371 mode.cp_mode=COPY_OFF;
372 mode.cmd_support_mode=CMD_SUPPORT_OFF; // SPP does not support command....only data
373
374 if(atp_reg(name,return_path,mode,&atp_spp_sw_id)!=RV_OK)
375 {
376 rvf_send_trace("ATP_SPP: SPP entity registration failed ",39, NULL_PARAM ,
377 RV_TRACE_LEVEL_WARNING,ATP_USE_ID);
378 return RV_INTERNAL_ERR;
379 }
380 return RV_OK;
381 }
382
383
384 /******************************************************************************
385 * Function name: atp_spp_init
386 *
387 * Description : This function is called to initialise SPP with ATP
388 *
389 *
390 * Parameters : None
391 *
392 * Return : Standard error
393 * RV_OK if OK
394 *
395 * History : 0.1 (17-Marsh-2000)
396 *
397 ******************************************************************************/
398 T_RV_RET atp_spp_init(T_RVF_ADDR_ID addr_id, T_RVF_MB_ID mb_id)
399 {
400 UINT8 i;
401
402 /* Initialisation */
403 spp_addr_id=addr_id; /* Mail box and task number to send primitive to SPP */
404 spp_if_mb=mb_id; /* Use SPP PRIM MB as working mb */
405
406 for(i=0;i<ATP_SPP_MAX_PENDING_PORT;i++)
407 {
408 pending_port_info[i].port_nb=0;
409 pending_port_info[i].initiator_id=ATP_INVALID_SWE_ID; /* Indicates that the field is free */
410 pending_port_info[i].handle=0;
411 }
412
413 return RV_OK;
414 }
415
416
417
418 /******************************************************************************
419 * Function name: atp_spp_start
420 *
421 * Description : This function is called to register SPP to ATP
422 *
423 *
424 * Parameters : None
425 *
426 * Return : Standard error
427 * RV_OK if OK
428 *
429 * History : 0.1 (29-Oct-2001)
430 *
431 ******************************************************************************/
432 T_RV_RET atp_spp_start(void)
433 {
434 if (atp_spp_reg() != RV_OK)
435 {
436 ATP_SEND_TRACE("ATP: Normal warning if ATP should not be started along with SPP",
437 RV_TRACE_LEVEL_WARNING);
438 }
439 return RV_OK;
440 }
441
442
443
444
445 /******************************************************************************
446 * Function name: atp_spp_open_port_rqst
447 *
448 * Description : Translate ATP_OPEN_PORT_IND into SPP_OPEN_PORT_RQST
449 *
450 *
451 * Parameters : Message pointer
452 *
453 * Return : Standard error
454 * RV_OK if OK
455 *
456 * History : 0.1 (20-Marsh-2000)
457 *
458 ******************************************************************************/
459 T_RV_RET atp_spp_open_port_rqst(T_ATP_OPEN_PORT_IND * open_port_ind_p)
460 {
461
462 T_SPP_OPEN_PORT_RQST * spp_open_port_rqst_p;
463 T_ATP_CUSTOM_TO_SPP_INFO * spp_custom_info_p;
464 UINT8 i,j;
465
466 if (open_port_ind_p->custom_info_p == NULL)
467 {
468 rvf_send_trace("ATP_SPP: Received an open port request from ATP without SPP information ",72, NULL_PARAM ,
469 RV_TRACE_LEVEL_WARNING,ATP_USE_ID);
470 rvf_send_trace("ATP_SPP: => the ATP open port request has been ignored ",56, NULL_PARAM ,
471 RV_TRACE_LEVEL_WARNING,ATP_USE_ID);
472 return RV_NOT_SUPPORTED;
473 }
474
475 if (rvf_get_buf (spp_if_mb,sizeof(T_SPP_OPEN_PORT_RQST),(void **) &spp_open_port_rqst_p)!=RVF_RED)
476 {
477
478 /* Find an empty field in the pending_port_info array
479 and store intermediate value before getting a CFM or IND */
480 i=0;
481 while((pending_port_info[i].initiator_id!=ATP_INVALID_SWE_ID) &&
482 (i<ATP_SPP_MAX_PENDING_PORT))
483 {
484 i++;
485 }
486 if (i==ATP_SPP_MAX_PENDING_PORT)
487 {
488 rvf_send_trace("ATP/SPP : Cannot open a new port : max authorized reached",57,
489 NULL_PARAM,RV_TRACE_LEVEL_WARNING, ATP_USE_ID);
490 // SHOULD SEND A IGNORE MESSAGE TO ATP
491 rvf_free_buf(spp_open_port_rqst_p);
492 return RV_NOT_SUPPORTED;
493
494 }
495 pending_port_info[i].port_nb=open_port_ind_p->initiator_port_nb;
496 pending_port_info[i].initiator_id=open_port_ind_p->initiator_id;
497 /* pending_port_info[i].handle address is provided later on to SPP for update */
498
499 spp_custom_info_p = (T_ATP_CUSTOM_TO_SPP_INFO *) open_port_ind_p->custom_info_p;
500
501 /* Update field for SPP event */
502 spp_open_port_rqst_p->appli_rx_mb = spp_custom_info_p->rx_mb;
503 if (spp_custom_info_p->max_payload_length_reneg_en == ATP_PAYLOAD_LENGTH_RENEG_ON)
504 {
505 spp_open_port_rqst_p->max_payload_reneg= SPP_ENABLE_MAX_PAYLOAD_RENEG;
506 }
507 else
508 {
509 spp_open_port_rqst_p->max_payload_reneg= SPP_DISABLE_MAX_PAYLOAD_RENEG;
510 }
511 spp_open_port_rqst_p->max_payload_length = spp_custom_info_p->max_payload_length;
512 if (spp_custom_info_p->is_server==ATP_IS_SERVER)
513 {
514 spp_open_port_rqst_p->server_mode=SPP_SERVER;
515 }
516 else
517 {
518 spp_open_port_rqst_p->server_mode=SPP_CLIENT;
519 }
520
521 if (spp_custom_info_p->flow_ctrl_mode==ATP_AUTOMATIC_FLOW_CTRL_OFF)
522 {
523 spp_open_port_rqst_p->rx_flow_ctrl=SPP_MANUAL_FLOW_CTRL;
524 }
525 else
526 {
527 spp_open_port_rqst_p->rx_flow_ctrl=SPP_AUTOMATIC_FLOW_CTRL;
528 }
529 spp_open_port_rqst_p->serv_channel = (T_SERVER_CHANNEL) spp_custom_info_p->server_channel;
530 spp_open_port_rqst_p->os_hdr.callback_func = atp_spp_from_spp_if_ft;
531 spp_open_port_rqst_p->os_hdr.dest_addr_id = RVF_INVALID_ADDR_ID;
532 for (j=0 ; j<sizeof(T_BD_ADDR) ; j++)
533 {spp_open_port_rqst_p->bd_addr[j] = spp_custom_info_p->bd_addr[j]; }
534
535 spp_open_port_rqst_p->modem_accept = AUTO_ACCEPT;
536
537 spp_open_port_rqst_p->handle=&(pending_port_info[i].handle);
538 spp_open_port_rqst_p->os_hdr.msg_id = SPP_OPEN_PORT_RQST_EVT;
539
540 /* Free the custom info buffer */
541 rvf_free_buf(spp_custom_info_p);
542
543 rvf_send_msg (spp_addr_id,spp_open_port_rqst_p);
544 return (RV_OK);
545 }
546 else
547 {
548 return(RV_MEMORY_ERR);
549 }
550 }
551
552
553
554
555 /******************************************************************************
556 * Function name: atp_spp_open_port_rsp
557 *
558 * Description : Translate SPP_OPEN_PORT_CFM and IND to atp_open_port_rsp
559 *
560 *
561 * Parameters : Message pointer
562 *
563 * Return : Standard error
564 * RV_OK if OK
565 *
566 * History : 0.1 (20-Marsh-2000)
567 *
568 ******************************************************************************/
569 T_RV_RET atp_spp_open_port_rsp(void * spp_open_port_rsp_p,T_ATP_SPP_IS_IND_OR_CFM cfm_or_ind)
570 {
571 T_ATP_OPEN_PORT_RESULT result;
572 T_ATP_PORT_INFO port_info;
573 T_ATP_NO_COPY_INFO no_copy_info;
574 UINT8 i;
575 T_RV_RET return_status;
576 T_SPP_HANDLE handle;
577 T_ATP_CUSTOM_FROM_SPP_INFO * custom_info_p;
578
579
580
581 if (rvf_get_buf (spp_if_mb,sizeof(T_ATP_CUSTOM_FROM_SPP_INFO),(void **) &custom_info_p)==RVF_RED)
582 {
583 return RV_MEMORY_ERR;
584 }
585
586 if (cfm_or_ind==ATP_SPP_IS_CFM)
587 {
588 /* Result translation */
589 if (((T_SPP_OPEN_PORT_CFM *) spp_open_port_rsp_p)->result!=SPP_OPEN_PORT_SUCCESS)
590 {
591 result=OPEN_PORT_NOK;
592 }
593 else
594 {
595 result=OPEN_PORT_OK;
596 }
597 handle=((T_SPP_OPEN_PORT_CFM *) spp_open_port_rsp_p)->handle;
598 custom_info_p->max_payload_length = ((T_SPP_OPEN_PORT_CFM *) spp_open_port_rsp_p)->max_payload_length;
599 memcpy(custom_info_p->bd_addr,"000000",BD_ADDR_LEN);
600 }
601 else
602 {
603 result=OPEN_PORT_OK;
604 handle=((T_SPP_OPEN_PORT_IND *) spp_open_port_rsp_p)->handle;
605 custom_info_p->max_payload_length = ((T_SPP_OPEN_PORT_IND *) spp_open_port_rsp_p)->max_payload_length;
606 memcpy(custom_info_p->bd_addr,((T_SPP_OPEN_PORT_IND *) spp_open_port_rsp_p)->bd_addr,BD_ADDR_LEN);
607
608 /* Create custom info field and update values */
609 }
610
611 custom_info_p->custom_type=ATP_FROM_SPP_INFO;
612
613 /* Get field from pending_port_info */
614 i=0;
615 while( ((pending_port_info[i].handle!=handle) ||
616 (pending_port_info[i].initiator_id==ATP_INVALID_SWE_ID)) &&
617 (i<ATP_SPP_MAX_PENDING_PORT))
618 {
619 i++;
620 }
621 if (i==ATP_SPP_MAX_PENDING_PORT)
622 {
623 rvf_send_trace("ATP/SPP : Port handle from SPP not found ",57,
624 NULL_PARAM,RV_TRACE_LEVEL_WARNING, ATP_USE_ID);
625 if (cfm_or_ind==ATP_SPP_IS_IND)
626 {
627 rvf_send_trace("ATP/SPP : SPP may have send a PORT_IND whereas no port has been created first as a server ",90,
628 NULL_PARAM,RV_TRACE_LEVEL_WARNING, ATP_USE_ID);
629 }
630 rvf_free_buf(custom_info_p);
631 return RV_NOT_SUPPORTED; /* Ignore command */
632 }
633
634 /* Port info */
635 port_info.port_config = NOT_DEFINED_CONFIG;
636 port_info.dce_mask[0]=0x0000; /* Command to interpret by ATP are not fixed on SPP side */
637 port_info.ring_type=ATP_NO_RING_TYPE;
638 port_info.signal_mask=ATP_ALL_THE_SIGNAL_UNMASK; /* Get all the signals */
639
640 /* No copy info */
641 no_copy_info.packet_mode=SEGMENTED_PACKET;
642 no_copy_info.tx_head_mode=TX_HEADER_ON;/* Do not care */
643 no_copy_info.tx_head_size=0;/* Do not care because SEGMENTED*/
644 no_copy_info.tx_trail_size=0; /* Do not care */
645 no_copy_info.rx_head_mode=RX_HEADER_ON; /* RX = DATA received by SPP from ATP */
646 no_copy_info.rx_head_size=SPP_RX_HEAD_SIZE;
647 no_copy_info.rx_trail_size=SPP_RX_TRAIL_SIZE;
648 no_copy_info.rx_mb=RVF_INVALID_MB_ID; /* Not set by SPP */
649 no_copy_info.tx_mb=RVF_INVALID_MB_ID; /* Not set by SPP */
650
651 return_status=atp_open_port_rsp(pending_port_info[i].initiator_id, pending_port_info[i].port_nb,atp_spp_sw_id,
652 (T_ATP_PORT_NB) handle,port_info,no_copy_info, (T_ATP_CUSTOM_INFO*) custom_info_p,result);
653
654 pending_port_info[i].initiator_id = ATP_INVALID_SWE_ID;
655
656 return return_status;
657 }
658
659
660
661
662 /******************************************************************************
663 * Function name: atp_spp_port_closed_from_atp
664 *
665 * Description : Translate ATP_PORT_CLOSED into SPP_CLOSE_PORT
666 *
667 *
668 * Parameters : Message pointer
669 *
670 * Return : Standard error
671 * RV_OK if OK
672 *
673 * History : 0.1 (20-Marsh-2000)
674 *
675 ******************************************************************************/
676 T_RV_RET atp_spp_port_closed_from_atp(T_ATP_PORT_CLOSED * close_port_p)
677 {
678
679 T_SPP_CLOSE_PORT * spp_close_port_p;
680 T_ATP_PORT_NB handle;
681 UINT8 i;
682
683 handle = close_port_p->port_nb;
684
685 /* Check that this port was not in opening mode */
686 /* If it was in opening mode, then find it in the pending port array */
687 i=0;
688 while( ((pending_port_info[i].port_nb!=close_port_p->closer_port_nb) ||
689 (pending_port_info[i].initiator_id!=close_port_p->closer_sw_id)) &&
690 (i<ATP_SPP_MAX_PENDING_PORT))
691 {
692 i++;
693 }
694
695 if (i!=ATP_SPP_MAX_PENDING_PORT)
696 {
697 /* In this case, the port handle was in the pending port array */
698 /* That means that the port has not been completely open (only RQST sent) */
699 /* RV_OK or MEMORY ERROR */
700
701 handle = pending_port_info[i].handle;
702 pending_port_info[i].initiator_id = ATP_INVALID_SWE_ID; // Refresh value
703
704 if ( (handle & SPP_HANDLE_TYPE) == SPP_SERVER_HANDLE_FLAG)
705 {
706 // Port was open in server mode
707 // So close server
708 T_SPP_CLOSE_SERV * close_server_p;
709 if (rvf_get_buf (spp_if_mb,sizeof(T_SPP_CLOSE_SERV),(void **) &close_server_p)==RVF_RED)
710 {
711 return RV_MEMORY_ERR;
712 }
713 close_server_p->handle = handle;
714 close_server_p->os_hdr.msg_id = SPP_CLOSE_SERV_EVT;
715 rvf_send_trace("ATP/SPP : Send a SPP_CLOSE_SERV to SPP ",40,
716 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
717 rvf_send_msg (spp_addr_id,close_server_p);
718 return RV_OK;
719 }
720 }
721
722
723 if (rvf_get_buf (spp_if_mb,sizeof(T_SPP_CLOSE_PORT),(void **) &spp_close_port_p)!=RVF_RED)
724 {
725 spp_close_port_p->handle=handle;
726 spp_close_port_p->os_hdr.msg_id=SPP_CLOSE_PORT_EVT;
727 rvf_send_msg (spp_addr_id,spp_close_port_p);
728 return (RV_OK);
729 }
730 else
731 {
732 return(RV_MEMORY_ERR);
733 }
734 }
735
736
737
738
739
740
741
742
743 /******************************************************************************
744 * Function name: atp_spp_send_to_spp_buffer_nc
745 *
746 * Description : Translate ATP_NO_COPY_DATA_RDY into SPP_SEND_BUFFER_NC_EVT
747 *
748 *
749 * Parameters : Message pointer
750 *
751 * Return : Standard error
752 * RV_OK if OK
753 *
754 * History : 0.1 (20-Marsh-2000)
755 *
756 ******************************************************************************/
757 T_RV_RET atp_spp_send_to_spp_buffer_nc(T_ATP_NO_COPY_DATA_RDY * atp_no_copy_p)
758 {
759
760 T_SPP_SEND_BUFFER_NC * spp_no_copy_p;
761
762 if (rvf_get_buf (spp_if_mb,sizeof(T_SPP_SEND_BUFFER_NC),(void **) &spp_no_copy_p)!=RVF_RED)
763 {
764
765 spp_no_copy_p->handle=(T_SPP_HANDLE) atp_no_copy_p->port_nb;
766 spp_no_copy_p->buffer=atp_no_copy_p->atp_buffer_p;
767 spp_no_copy_p->length=(UINT16) atp_no_copy_p->buffer_size;
768
769
770 spp_no_copy_p->os_hdr.msg_id=SPP_SEND_BUFFER_NC_EVT;
771
772 rvf_send_msg (spp_addr_id,spp_no_copy_p);
773
774 return (RV_OK);
775 }
776 else
777 {
778 return(RV_MEMORY_ERR);
779 }
780 }
781
782
783 /******************************************************************************
784 * Function name: atp_spp_set_spp_signals
785 *
786 * Description : Based on a ATP_SIGNAL_CHANGED signal, set SPP signals
787 *
788 *
789 * Parameters : Message pointer
790 *
791 * Return : Standard error
792 * RV_OK if OK
793 *
794 * History : 0.1 (20-Marsh-2000)
795 *
796 ******************************************************************************/
797 T_RV_RET atp_spp_set_spp_signals(T_ATP_SIGNAL_CHANGED * message_p)
798 {
799 T_SPP_LINE_STS * line_sts_p;
800
801 /* Get Signals of the port on ATP side */
802
803
804 ATP_SEND_TRACE("ATP/SPP : Received a ATP_SIGNAL_CHANGED from ATP ",
805 RV_TRACE_LEVEL_DEBUG_LOW);
806
807 rvf_send_trace("ATP/SPP : Signal value = ",26,
808 (UINT32) message_p->signal,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
809
810 if (rvf_get_buf (spp_if_mb,sizeof(T_SPP_LINE_STS),(void **) &line_sts_p)==RVF_RED)
811 {
812 return RV_MEMORY_ERR;
813 }
814
815 line_sts_p->handle =((T_ATP_SIGNAL_CHANGED *) message_p)->port_nb;
816 line_sts_p->mask =OTHER_SIGNALS;
817 line_sts_p->os_hdr.msg_id =SPP_SET_LINE_STS_EVT;
818 line_sts_p->fc_flow =FC_FLOW_ON; // Should be do not care
819
820 /* DCD */
821 if ( (message_p->signal & ATP_DCD_UNMASK) == ATP_DCD_0)
822 {
823 line_sts_p->dv = DCD_0;
824 }
825 else
826 {
827 line_sts_p->dv = DCD_1;
828 }
829
830 /* RI */
831 if ( (message_p->signal & ATP_RI_UNMASK) == ATP_RI_0)
832 {
833 line_sts_p->ic = RI_0;
834 }
835 else
836 {
837 line_sts_p->ic = RI_1;
838 }
839
840
841 /* DTR/DSR */
842 if ( (message_p->signal & ATP_DTR_DSR_UNMASK) == ATP_DTR_DSR_0)
843 {
844 line_sts_p->rtc = DTRDSR_0;
845 }
846 else
847 {
848 line_sts_p->rtc = DTRDSR_1;
849 }
850
851 /* RTS CTS */
852 if ( (message_p->signal & ATP_RTS_CTS_UNMASK) == ATP_RTS_CTS_0)
853 {
854 line_sts_p->rtr = RTSCTS_0;
855 }
856 else
857 {
858 line_sts_p->rtr = RTSCTS_1;
859 }
860
861 rvf_send_trace("ATP/SPP : Send a SPP_SET_LINE_STS to SPP ",42,
862 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
863
864 return rvf_send_msg (spp_addr_id,line_sts_p);
865 }
866
867
868
869 /******************************************************************************
870 * Function name: atp_spp_set_atp_signals
871 *
872 * Description : Based on a SPP_LINE_STS
873 *
874 *
875 * Parameters : Message pointer
876 *
877 * Return : Standard error
878 * RV_OK if OK
879 *
880 * History : 0.1 (20-Marsh-2000)
881 *
882 ******************************************************************************/
883 T_RV_RET atp_spp_set_atp_signals(T_SPP_LINE_STS * message_p)
884 {
885 T_ATP_PORT_SIGNAL signal,old_signal;
886 T_ATP_SIGNAL_CHANGE_MASK mask = 0;
887
888 rvf_send_trace("ATP/SPP : Received a LINE_STS event from SPP ",45,
889 NULL_PARAM,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
890
891 atp_get_signal(atp_spp_sw_id,(T_ATP_PORT_NB) ((T_SPP_LINE_STS *) message_p)->handle,
892 &old_signal);
893
894 signal=old_signal;
895
896 /* DCD */
897 if ( (message_p->dv == DCD_0) && ( (old_signal & ATP_DCD_UNMASK) == ATP_DCD_1))
898 {
899 /* DCD changed to 0 */
900 mask |= ATP_DCD_UNMASK;
901 signal &= (~ ATP_DCD_UNMASK); // clear DCD
902 ATP_SEND_TRACE("ATP : DCD has been set to 0",RV_TRACE_LEVEL_DEBUG_LOW);
903 }
904 else
905 {
906 if ( (message_p->dv == DCD_1) && ( (old_signal & ATP_DCD_UNMASK) == ATP_DCD_0))
907 {
908 /* DCD changed to 1 */
909 mask |= ATP_DCD_UNMASK;
910 signal |= ATP_DCD_1;
911 ATP_SEND_TRACE("ATP : DCD has been set to 1",RV_TRACE_LEVEL_DEBUG_LOW);
912 }
913 }
914
915 /* RI */
916 if ( (message_p->ic == RI_0) && ( (old_signal & ATP_RI_UNMASK) == ATP_RI_1))
917 {
918 /* RI changed to 0 */
919 mask |= ATP_RI_UNMASK;
920 signal &= (~ ATP_RI_UNMASK); // clear RI
921 ATP_SEND_TRACE("ATP : RI has been set to 0",RV_TRACE_LEVEL_DEBUG_LOW);
922 }
923 else
924 {
925 if ( (message_p->ic == RI_1) && ( (old_signal & ATP_RI_UNMASK) == ATP_RI_0))
926 {
927 /* RIchanged to 1 */
928 mask |= ATP_RI_UNMASK;
929 signal |= ATP_RI_1;
930 ATP_SEND_TRACE("ATP : RI has been set to 1",RV_TRACE_LEVEL_DEBUG_LOW);
931 }
932 }
933
934
935 /* DTR/DSR */
936 if ( (message_p->rtc == DTRDSR_0) && ( (old_signal & ATP_DTR_DSR_UNMASK) == ATP_DTR_DSR_1))
937 {
938 /* DTR/DSR changed to 0 */
939 mask |= ATP_DTR_DSR_UNMASK;
940 signal &= (~ ATP_DTR_DSR_UNMASK); // clear DTR/DSR
941 ATP_SEND_TRACE("ATP : DTR/DSR has been set to 0",RV_TRACE_LEVEL_DEBUG_LOW);
942 }
943 else
944 {
945 if ( (message_p->rtc == DTRDSR_1) && ( (old_signal & ATP_DTR_DSR_UNMASK) == ATP_DTR_DSR_0))
946 {
947 /* DCD changed to 0 */
948 mask |= ATP_DTR_DSR_UNMASK;
949 signal |= ATP_DTR_DSR_1;
950 ATP_SEND_TRACE("ATP : DTR/DSR has been set to 1",RV_TRACE_LEVEL_DEBUG_LOW);
951 }
952 }
953
954
955 /* RTS CTS */
956 if ( (message_p->rtr == RTSCTS_0) && ( (old_signal & ATP_RTS_CTS_UNMASK) == ATP_RTS_CTS_1))
957 {
958 /* DTR/DSR changed to 0 */
959 mask |= ATP_RTS_CTS_UNMASK;
960 signal &= (~ ATP_RTS_CTS_UNMASK); // clear DTR/DSR
961 ATP_SEND_TRACE("ATP : RTS/CTS has been set to 0",RV_TRACE_LEVEL_DEBUG_LOW);
962 }
963 else
964 {
965 if ( (message_p->rtr == RTSCTS_1) && ( (old_signal & ATP_RTS_CTS_UNMASK) == ATP_RTS_CTS_0))
966 {
967 /* DCD changed to 0 */
968 mask |= ATP_RTS_CTS_UNMASK;
969 signal |= ATP_RTS_CTS_1;
970 ATP_SEND_TRACE("ATP : RTS/CTS has been set to 1",RV_TRACE_LEVEL_DEBUG_LOW);
971 }
972 }
973
974
975 rvf_send_trace("ATP/SPP : Signal Value = ",25,
976 (UINT32) signal ,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
977 rvf_send_trace("ATP/SPP : Mask Value = ",24,
978 (UINT32) mask ,RV_TRACE_LEVEL_DEBUG_LOW, ATP_USE_ID);
979
980 return atp_set_signal(atp_spp_sw_id, (T_ATP_PORT_NB) ((T_SPP_LINE_STS *) message_p)->handle,
981 signal,mask);
982 }
983
984
985