1 /******************************************************************************
2 *
3 * Copyright (C) 2010-2014 Broadcom Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
19
20 /******************************************************************************
21 *
22 * This file contains function of the NCI unit to format and send NCI
23 * commands (for DH).
24 *
25 ******************************************************************************/
26 #include <string.h>
27 #include "nfc_target.h"
28
29 #if NFC_INCLUDED == TRUE
30 #include "nci_defs.h"
31 #include "nci_hmsgs.h"
32 #include "nfc_api.h"
33 #include "nfc_int.h"
34
35 /*******************************************************************************
36 **
37 ** Function nci_snd_core_reset
38 **
39 ** Description compose and send CORE RESET command to command queue
40 **
41 ** Returns status
42 **
43 *******************************************************************************/
nci_snd_core_reset(UINT8 reset_type)44 UINT8 nci_snd_core_reset (UINT8 reset_type)
45 {
46 BT_HDR *p;
47 UINT8 *pp;
48
49 if ((p = NCI_GET_CMD_BUF (NCI_CORE_PARAM_SIZE_RESET)) == NULL)
50 return (NCI_STATUS_FAILED);
51
52 p->event = BT_EVT_TO_NFC_NCI;
53 p->len = NCI_MSG_HDR_SIZE + NCI_CORE_PARAM_SIZE_RESET;
54 p->offset = NCI_MSG_OFFSET_SIZE;
55 p->layer_specific = 0;
56 pp = (UINT8 *) (p + 1) + p->offset;
57
58 NCI_MSG_BLD_HDR0 (pp, NCI_MT_CMD, NCI_GID_CORE);
59 NCI_MSG_BLD_HDR1 (pp, NCI_MSG_CORE_RESET);
60 UINT8_TO_STREAM (pp, NCI_CORE_PARAM_SIZE_RESET);
61 UINT8_TO_STREAM (pp, reset_type);
62
63 nfc_ncif_send_cmd (p);
64 return (NCI_STATUS_OK);
65 }
66
67 /*******************************************************************************
68 **
69 ** Function nci_snd_core_init
70 **
71 ** Description compose and send CORE INIT command to command queue
72 **
73 ** Returns status
74 **
75 *******************************************************************************/
nci_snd_core_init(void)76 UINT8 nci_snd_core_init (void)
77 {
78 BT_HDR *p;
79 UINT8 *pp;
80
81 if ((p = NCI_GET_CMD_BUF (NCI_CORE_PARAM_SIZE_INIT)) == NULL)
82 return (NCI_STATUS_FAILED);
83
84 p->event = BT_EVT_TO_NFC_NCI;
85 p->len = NCI_MSG_HDR_SIZE + NCI_CORE_PARAM_SIZE_INIT;
86 p->offset = NCI_MSG_OFFSET_SIZE;
87 p->layer_specific = 0;
88 pp = (UINT8 *) (p + 1) + p->offset;
89
90 NCI_MSG_BLD_HDR0 (pp, NCI_MT_CMD, NCI_GID_CORE);
91 NCI_MSG_BLD_HDR1 (pp, NCI_MSG_CORE_INIT);
92 UINT8_TO_STREAM (pp, NCI_CORE_PARAM_SIZE_INIT);
93
94 nfc_ncif_send_cmd (p);
95 return (NCI_STATUS_OK);
96 }
97
98 /*******************************************************************************
99 **
100 ** Function nci_snd_core_get_config
101 **
102 ** Description compose and send CORE GET_CONFIG command to command queue
103 **
104 ** Returns status
105 **
106 *******************************************************************************/
nci_snd_core_get_config(UINT8 * param_ids,UINT8 num_ids)107 UINT8 nci_snd_core_get_config (UINT8 *param_ids, UINT8 num_ids)
108 {
109 BT_HDR *p;
110 UINT8 *pp;
111
112 if ((p = NCI_GET_CMD_BUF (num_ids)) == NULL)
113 return (NCI_STATUS_FAILED);
114
115 p->event = BT_EVT_TO_NFC_NCI;
116 p->len = NCI_MSG_HDR_SIZE + num_ids + 1;
117 p->offset = NCI_MSG_OFFSET_SIZE;
118 p->layer_specific = 0;
119 pp = (UINT8 *) (p + 1) + p->offset;
120
121 NCI_MSG_BLD_HDR0 (pp, NCI_MT_CMD, NCI_GID_CORE);
122 NCI_MSG_BLD_HDR1 (pp, NCI_MSG_CORE_GET_CONFIG);
123 UINT8_TO_STREAM (pp, (UINT8) (num_ids + 1));
124 UINT8_TO_STREAM (pp, num_ids);
125 ARRAY_TO_STREAM (pp, param_ids, num_ids);
126
127 nfc_ncif_send_cmd (p);
128 return (NCI_STATUS_OK);
129 }
130
131 /*******************************************************************************
132 **
133 ** Function nci_snd_core_set_config
134 **
135 ** Description compose and send CORE SET_CONFIG command to command queue
136 **
137 ** Returns status
138 **
139 *******************************************************************************/
nci_snd_core_set_config(UINT8 * p_param_tlvs,UINT8 tlv_size)140 UINT8 nci_snd_core_set_config (UINT8 *p_param_tlvs, UINT8 tlv_size)
141 {
142 BT_HDR *p;
143 UINT8 *pp;
144 UINT8 num = 0, ulen, len, *pt;
145
146 if ((p = NCI_GET_CMD_BUF (tlv_size + 1)) == NULL)
147 return (NCI_STATUS_FAILED);
148
149 p->event = BT_EVT_TO_NFC_NCI;
150 p->len = NCI_MSG_HDR_SIZE + tlv_size + 1;
151 p->offset = NCI_MSG_OFFSET_SIZE;
152 pp = (UINT8 *) (p + 1) + p->offset;
153
154 NCI_MSG_BLD_HDR0 (pp, NCI_MT_CMD, NCI_GID_CORE);
155 NCI_MSG_BLD_HDR1 (pp, NCI_MSG_CORE_SET_CONFIG);
156 UINT8_TO_STREAM (pp, (UINT8) (tlv_size + 1));
157 len = tlv_size;
158 pt = p_param_tlvs;
159 while (len > 1)
160 {
161 len -= 2;
162 pt++;
163 num++;
164 ulen = *pt++;
165 pt += ulen;
166 if (len >= ulen)
167 {
168 len -= ulen;
169 }
170 else
171 {
172 GKI_freebuf (p);
173 return NCI_STATUS_FAILED;
174 }
175 }
176
177 UINT8_TO_STREAM (pp, num);
178 ARRAY_TO_STREAM (pp, p_param_tlvs, tlv_size);
179 nfc_ncif_send_cmd (p);
180
181 return (NCI_STATUS_OK);
182 }
183
184 /*******************************************************************************
185 **
186 ** Function nci_snd_core_conn_create
187 **
188 ** Description compose and send CORE CONN_CREATE command to command queue
189 **
190 ** Returns status
191 **
192 *******************************************************************************/
nci_snd_core_conn_create(UINT8 dest_type,UINT8 num_tlv,UINT8 tlv_size,UINT8 * p_param_tlvs)193 UINT8 nci_snd_core_conn_create (UINT8 dest_type, UINT8 num_tlv, UINT8 tlv_size, UINT8 *p_param_tlvs)
194 {
195 BT_HDR *p;
196 UINT8 *pp;
197 UINT8 size = NCI_CORE_PARAM_SIZE_CON_CREATE+tlv_size;
198
199 if ((p = NCI_GET_CMD_BUF (size)) == NULL)
200 return (NCI_STATUS_FAILED);
201
202 p->event = BT_EVT_TO_NFC_NCI;
203 p->len = NCI_MSG_HDR_SIZE + NCI_CORE_PARAM_SIZE_CON_CREATE;
204 p->offset = NCI_MSG_OFFSET_SIZE;
205 p->layer_specific = 0;
206 pp = (UINT8 *) (p + 1) + p->offset;
207
208 NCI_MSG_BLD_HDR0 (pp, NCI_MT_CMD, NCI_GID_CORE);
209 NCI_MSG_BLD_HDR1 (pp, NCI_MSG_CORE_CONN_CREATE);
210 UINT8_TO_STREAM (pp, size);
211 UINT8_TO_STREAM (pp, dest_type);
212 UINT8_TO_STREAM (pp, num_tlv);
213 if (tlv_size)
214 {
215 ARRAY_TO_STREAM (pp, p_param_tlvs, tlv_size);
216 p->len += tlv_size;
217 }
218
219 nfc_ncif_send_cmd (p);
220 return (NCI_STATUS_OK);
221 }
222
223 /*******************************************************************************
224 **
225 ** Function nci_snd_core_conn_close
226 **
227 ** Description compose and send CORE CONN_CLOSE command to command queue
228 **
229 ** Returns status
230 **
231 *******************************************************************************/
nci_snd_core_conn_close(UINT8 conn_id)232 UINT8 nci_snd_core_conn_close (UINT8 conn_id)
233 {
234 BT_HDR *p;
235 UINT8 *pp;
236
237 if ((p = NCI_GET_CMD_BUF (NCI_CORE_PARAM_SIZE_CON_CLOSE)) == NULL)
238 return (NCI_STATUS_FAILED);
239
240 p->event = BT_EVT_TO_NFC_NCI;
241 p->len = NCI_MSG_HDR_SIZE + NCI_CORE_PARAM_SIZE_CON_CLOSE;
242 p->offset = NCI_MSG_OFFSET_SIZE;
243 p->layer_specific = 0;
244 pp = (UINT8 *) (p + 1) + p->offset;
245
246 NCI_MSG_BLD_HDR0 (pp, NCI_MT_CMD, NCI_GID_CORE);
247 NCI_MSG_BLD_HDR1 (pp, NCI_MSG_CORE_CONN_CLOSE);
248 UINT8_TO_STREAM (pp, NCI_CORE_PARAM_SIZE_CON_CLOSE);
249 UINT8_TO_STREAM (pp, conn_id);
250
251 nfc_ncif_send_cmd (p);
252 return (NCI_STATUS_OK);
253 }
254
255
256 #if (NFC_NFCEE_INCLUDED == TRUE)
257 #if (NFC_RW_ONLY == FALSE)
258 /*******************************************************************************
259 **
260 ** Function nci_snd_nfcee_discover
261 **
262 ** Description compose and send NFCEE Management NFCEE_DISCOVER command
263 ** to command queue
264 **
265 ** Returns status
266 **
267 *******************************************************************************/
nci_snd_nfcee_discover(UINT8 discover_action)268 UINT8 nci_snd_nfcee_discover (UINT8 discover_action)
269 {
270 BT_HDR *p;
271 UINT8 *pp;
272
273 if ((p = NCI_GET_CMD_BUF (NCI_PARAM_SIZE_DISCOVER_NFCEE)) == NULL)
274 return (NCI_STATUS_FAILED);
275
276 p->event = BT_EVT_TO_NFC_NCI;
277 p->len = NCI_MSG_HDR_SIZE + NCI_PARAM_SIZE_DISCOVER_NFCEE;
278 p->offset = NCI_MSG_OFFSET_SIZE;
279 p->layer_specific = 0;
280 pp = (UINT8 *) (p + 1) + p->offset;
281
282 NCI_MSG_BLD_HDR0 (pp, NCI_MT_CMD, NCI_GID_EE_MANAGE);
283 NCI_MSG_BLD_HDR1 (pp, NCI_MSG_NFCEE_DISCOVER);
284 UINT8_TO_STREAM (pp, NCI_PARAM_SIZE_DISCOVER_NFCEE);
285 UINT8_TO_STREAM (pp, discover_action);
286
287 nfc_ncif_send_cmd (p);
288 return (NCI_STATUS_OK);
289 }
290
291 /*******************************************************************************
292 **
293 ** Function nci_snd_nfcee_mode_set
294 **
295 ** Description compose and send NFCEE Management NFCEE MODE SET command
296 ** to command queue
297 **
298 ** Returns status
299 **
300 *******************************************************************************/
nci_snd_nfcee_mode_set(UINT8 nfcee_id,UINT8 nfcee_mode)301 UINT8 nci_snd_nfcee_mode_set (UINT8 nfcee_id, UINT8 nfcee_mode)
302 {
303 BT_HDR *p;
304 UINT8 *pp;
305
306 if ((p = NCI_GET_CMD_BUF (NCI_CORE_PARAM_SIZE_NFCEE_MODE_SET)) == NULL)
307 return (NCI_STATUS_FAILED);
308
309 p->event = BT_EVT_TO_NFC_NCI;
310 p->len = NCI_MSG_HDR_SIZE + NCI_CORE_PARAM_SIZE_NFCEE_MODE_SET;
311 p->offset = NCI_MSG_OFFSET_SIZE;
312 p->layer_specific = 0;
313 pp = (UINT8 *) (p + 1) + p->offset;
314
315 NCI_MSG_BLD_HDR0 (pp, NCI_MT_CMD, NCI_GID_EE_MANAGE);
316 NCI_MSG_BLD_HDR1 (pp, NCI_MSG_NFCEE_MODE_SET);
317 UINT8_TO_STREAM (pp, NCI_CORE_PARAM_SIZE_NFCEE_MODE_SET);
318 UINT8_TO_STREAM (pp, nfcee_id);
319 UINT8_TO_STREAM (pp, nfcee_mode);
320
321 nfc_ncif_send_cmd (p);
322 return (NCI_STATUS_OK);
323 }
324 #endif
325 #endif
326
327 /*******************************************************************************
328 **
329 ** Function nci_snd_discover_cmd
330 **
331 ** Description compose and send RF Management DISCOVER command to command queue
332 **
333 ** Returns status
334 **
335 *******************************************************************************/
nci_snd_discover_cmd(UINT8 num,tNCI_DISCOVER_PARAMS * p_param)336 UINT8 nci_snd_discover_cmd (UINT8 num, tNCI_DISCOVER_PARAMS *p_param)
337 {
338 BT_HDR *p;
339 UINT8 *pp, *p_size, *p_start;
340 int xx;
341 int size;
342
343 size = num * sizeof (tNCI_DISCOVER_PARAMS) + 1;
344 if ((p = NCI_GET_CMD_BUF (size)) == NULL)
345 return (NCI_STATUS_FAILED);
346
347 p->event = BT_EVT_TO_NFC_NCI;
348 p->offset = NCI_MSG_OFFSET_SIZE;
349 p->layer_specific = 0;
350 pp = (UINT8 *) (p + 1) + p->offset;
351
352 NCI_MSG_BLD_HDR0 (pp, NCI_MT_CMD, NCI_GID_RF_MANAGE);
353 NCI_MSG_BLD_HDR1 (pp, NCI_MSG_RF_DISCOVER);
354 p_size = pp;
355 pp++;
356 p_start = pp;
357 UINT8_TO_STREAM (pp, num);
358 for (xx=0; xx<num; xx++)
359 {
360 UINT8_TO_STREAM (pp, p_param[xx].type);
361 UINT8_TO_STREAM (pp, p_param[xx].frequency);
362 }
363 *p_size = (UINT8) (pp - p_start);
364 p->len = NCI_MSG_HDR_SIZE + *p_size;
365
366 nfc_ncif_send_cmd (p);
367 return (NCI_STATUS_OK);
368 }
369
370 /*******************************************************************************
371 **
372 ** Function nci_snd_discover_select_cmd
373 **
374 ** Description compose and send RF Management DISCOVER SELECT command
375 ** to command queue
376 **
377 ** Returns status
378 **
379 *******************************************************************************/
nci_snd_discover_select_cmd(UINT8 rf_disc_id,UINT8 protocol,UINT8 rf_interface)380 UINT8 nci_snd_discover_select_cmd (UINT8 rf_disc_id, UINT8 protocol, UINT8 rf_interface)
381 {
382 BT_HDR *p;
383 UINT8 *pp;
384
385 if ((p = NCI_GET_CMD_BUF (NCI_DISCOVER_PARAM_SIZE_SELECT)) == NULL)
386 return (NCI_STATUS_FAILED);
387
388 p->event = BT_EVT_TO_NFC_NCI;
389 p->len = NCI_MSG_HDR_SIZE + NCI_DISCOVER_PARAM_SIZE_SELECT;
390 p->offset = NCI_MSG_OFFSET_SIZE;
391 p->layer_specific = 0;
392 pp = (UINT8 *) (p + 1) + p->offset;
393
394 NCI_MSG_BLD_HDR0 (pp, NCI_MT_CMD, NCI_GID_RF_MANAGE);
395 NCI_MSG_BLD_HDR1 (pp, NCI_MSG_RF_DISCOVER_SELECT);
396 UINT8_TO_STREAM (pp, NCI_DISCOVER_PARAM_SIZE_SELECT);
397 UINT8_TO_STREAM (pp, rf_disc_id);
398 UINT8_TO_STREAM (pp, protocol);
399 UINT8_TO_STREAM (pp, rf_interface);
400
401 nfc_ncif_send_cmd (p);
402 return (NCI_STATUS_OK);
403 }
404
405 /*******************************************************************************
406 **
407 ** Function nci_snd_deactivate_cmd
408 **
409 ** Description compose and send RF Management DEACTIVATE command
410 ** to command queue
411 **
412 ** Returns status
413 **
414 *******************************************************************************/
nci_snd_deactivate_cmd(UINT8 de_act_type)415 UINT8 nci_snd_deactivate_cmd (UINT8 de_act_type )
416 {
417 BT_HDR *p;
418 UINT8 *pp;
419
420 nfc_cb.reassembly = TRUE;
421
422 if ((p = NCI_GET_CMD_BUF (NCI_DISCOVER_PARAM_SIZE_DEACT)) == NULL)
423 return (NCI_STATUS_FAILED);
424
425 p->event = BT_EVT_TO_NFC_NCI;
426 p->len = NCI_MSG_HDR_SIZE + NCI_DISCOVER_PARAM_SIZE_DEACT;
427 p->offset = NCI_MSG_OFFSET_SIZE;
428 p->layer_specific = 0;
429 pp = (UINT8 *) (p + 1) + p->offset;
430
431 NCI_MSG_BLD_HDR0 (pp, NCI_MT_CMD, NCI_GID_RF_MANAGE);
432 NCI_MSG_BLD_HDR1 (pp, NCI_MSG_RF_DEACTIVATE);
433 UINT8_TO_STREAM (pp, NCI_DISCOVER_PARAM_SIZE_DEACT);
434 UINT8_TO_STREAM (pp, de_act_type);
435
436 nfc_ncif_send_cmd (p);
437 return (NCI_STATUS_OK);
438 }
439
440 /*******************************************************************************
441 **
442 ** Function nci_snd_discover_map_cmd
443 **
444 ** Description compose and send RF Management DISCOVER MAP command
445 ** to command queue
446 **
447 ** Returns status
448 **
449 *******************************************************************************/
nci_snd_discover_map_cmd(UINT8 num,tNCI_DISCOVER_MAPS * p_maps)450 UINT8 nci_snd_discover_map_cmd (UINT8 num, tNCI_DISCOVER_MAPS *p_maps)
451 {
452 BT_HDR *p;
453 UINT8 *pp, *p_size, *p_start;
454 int xx;
455 int size;
456
457 size = num * sizeof (tNCI_DISCOVER_MAPS) + 1;
458
459 if ((p = NCI_GET_CMD_BUF (size)) == NULL)
460 return (NCI_STATUS_FAILED);
461
462 p->event = BT_EVT_TO_NFC_NCI;
463 p->offset = NCI_MSG_OFFSET_SIZE;
464 p->layer_specific = 0;
465 pp = (UINT8 *) (p + 1) + p->offset;
466
467 NCI_MSG_BLD_HDR0 (pp, NCI_MT_CMD, NCI_GID_RF_MANAGE);
468 NCI_MSG_BLD_HDR1 (pp, NCI_MSG_RF_DISCOVER_MAP);
469 p_size = pp;
470 pp++;
471 p_start = pp;
472 UINT8_TO_STREAM (pp, num);
473 for (xx = 0; xx < num; xx++)
474 {
475 UINT8_TO_STREAM (pp, p_maps[xx].protocol);
476 UINT8_TO_STREAM (pp, p_maps[xx].mode);
477 UINT8_TO_STREAM (pp, p_maps[xx].intf_type);
478 }
479 *p_size = (UINT8) (pp - p_start);
480 p->len = NCI_MSG_HDR_SIZE + *p_size;
481 nfc_ncif_send_cmd (p);
482 return (NCI_STATUS_OK);
483 }
484 /*******************************************************************************
485 **
486 ** Function nci_snd_t3t_polling
487 **
488 ** Description compose and send RF Management T3T POLLING command
489 ** to command queue
490 **
491 ** Returns status
492 **
493 *******************************************************************************/
nci_snd_t3t_polling(UINT16 system_code,UINT8 rc,UINT8 tsn)494 UINT8 nci_snd_t3t_polling (UINT16 system_code, UINT8 rc, UINT8 tsn)
495 {
496 BT_HDR *p;
497 UINT8 *pp;
498
499 if ((p = NCI_GET_CMD_BUF (NCI_RF_PARAM_SIZE_T3T_POLLING)) == NULL)
500 return (NCI_STATUS_FAILED);
501
502 p->event = BT_EVT_TO_NFC_NCI;
503 p->len = NCI_MSG_HDR_SIZE + NCI_RF_PARAM_SIZE_T3T_POLLING;
504 p->offset = NCI_MSG_OFFSET_SIZE;
505 p->layer_specific = 0;
506 pp = (UINT8 *) (p + 1) + p->offset;
507
508 NCI_MSG_BLD_HDR0 (pp, NCI_MT_CMD, NCI_GID_RF_MANAGE);
509 NCI_MSG_BLD_HDR1 (pp, NCI_MSG_RF_T3T_POLLING);
510 UINT8_TO_STREAM (pp, NCI_RF_PARAM_SIZE_T3T_POLLING);
511 UINT16_TO_BE_STREAM (pp, system_code);
512 UINT8_TO_STREAM (pp, rc);
513 UINT8_TO_STREAM (pp, tsn);
514
515 nfc_ncif_send_cmd (p);
516 return (NCI_STATUS_OK);
517 }
518
519 /*******************************************************************************
520 **
521 ** Function nci_snd_parameter_update_cmd
522 **
523 ** Description compose and send RF Management RF Communication Parameter
524 ** Update commandto command queue
525 **
526 ** Returns status
527 **
528 *******************************************************************************/
nci_snd_parameter_update_cmd(UINT8 * p_param_tlvs,UINT8 tlv_size)529 UINT8 nci_snd_parameter_update_cmd (UINT8 *p_param_tlvs, UINT8 tlv_size)
530 {
531 BT_HDR *p;
532 UINT8 *pp;
533 UINT8 num = 0, ulen, len, *pt;
534
535 if ((p = NCI_GET_CMD_BUF (tlv_size + 1)) == NULL)
536 return (NCI_STATUS_FAILED);
537
538 p->event = BT_EVT_TO_NFC_NCI;
539 p->len = NCI_MSG_HDR_SIZE + tlv_size + 1;
540 p->offset = NCI_MSG_OFFSET_SIZE;
541 pp = (UINT8 *) (p + 1) + p->offset;
542
543 NCI_MSG_BLD_HDR0 (pp, NCI_MT_CMD, NCI_GID_RF_MANAGE);
544 NCI_MSG_BLD_HDR1 (pp, NCI_MSG_RF_PARAMETER_UPDATE);
545 UINT8_TO_STREAM (pp, (UINT8) (tlv_size + 1));
546 len = tlv_size;
547 pt = p_param_tlvs;
548 while (len > 1)
549 {
550 len -= 2;
551 pt++;
552 num++;
553 ulen = *pt++;
554 pt += ulen;
555 if (len >= ulen)
556 {
557 len -= ulen;
558 }
559 else
560 {
561 GKI_freebuf (p);
562 return NCI_STATUS_FAILED;
563 }
564 }
565
566 UINT8_TO_STREAM (pp, num);
567 ARRAY_TO_STREAM (pp, p_param_tlvs, tlv_size);
568 nfc_ncif_send_cmd (p);
569
570 return (NCI_STATUS_OK);
571 }
572
573 #if (NFC_NFCEE_INCLUDED == TRUE)
574 #if (NFC_RW_ONLY == FALSE)
575 /*******************************************************************************
576 **
577 ** Function nci_snd_set_routing_cmd
578 **
579 ** Description compose and send RF Management SET_LISTEN_MODE_ROUTING command
580 ** to command queue
581 **
582 ** Returns status
583 **
584 *******************************************************************************/
nci_snd_set_routing_cmd(BOOLEAN more,UINT8 num_tlv,UINT8 tlv_size,UINT8 * p_param_tlvs)585 UINT8 nci_snd_set_routing_cmd (BOOLEAN more, UINT8 num_tlv, UINT8 tlv_size, UINT8 *p_param_tlvs)
586 {
587 BT_HDR *p;
588 UINT8 *pp;
589 UINT8 size = tlv_size + 2;
590
591 if (tlv_size == 0)
592 {
593 /* just to terminate routing table
594 * 2 bytes (more=FALSE and num routing entries=0) */
595 size = 2;
596 }
597
598 if ((p = NCI_GET_CMD_BUF(size)) == NULL)
599 return (NCI_STATUS_FAILED);
600
601 p->event = BT_EVT_TO_NFC_NCI;
602 p->offset = NCI_MSG_OFFSET_SIZE;
603 p->len = NCI_MSG_HDR_SIZE + size;
604 p->layer_specific = 0;
605 pp = (UINT8 *) (p + 1) + p->offset;
606
607 NCI_MSG_BLD_HDR0 (pp, NCI_MT_CMD, NCI_GID_RF_MANAGE);
608 NCI_MSG_BLD_HDR1 (pp, NCI_MSG_RF_SET_ROUTING);
609 UINT8_TO_STREAM (pp, size);
610 UINT8_TO_STREAM (pp, more);
611 if (size == 2)
612 {
613 UINT8_TO_STREAM (pp, 0);
614 }
615 else
616 {
617 UINT8_TO_STREAM (pp, num_tlv);
618 ARRAY_TO_STREAM (pp, p_param_tlvs, tlv_size);
619 }
620 nfc_ncif_send_cmd (p);
621
622 return (NCI_STATUS_OK);
623 }
624
625 /*******************************************************************************
626 **
627 ** Function nci_snd_get_routing_cmd
628 **
629 ** Description compose and send RF Management GET_LISTEN_MODE_ROUTING command
630 ** to command queue
631 **
632 ** Returns status
633 **
634 *******************************************************************************/
nci_snd_get_routing_cmd(void)635 UINT8 nci_snd_get_routing_cmd (void)
636 {
637 BT_HDR *p;
638 UINT8 *pp;
639 UINT8 param_size = 0;
640
641 if ((p = NCI_GET_CMD_BUF (param_size)) == NULL)
642 return (NCI_STATUS_FAILED);
643
644 p->event = BT_EVT_TO_NFC_NCI;
645 p->len = NCI_MSG_HDR_SIZE + param_size;
646 p->offset = NCI_MSG_OFFSET_SIZE;
647 p->layer_specific = 0;
648 pp = (UINT8 *) (p + 1) + p->offset;
649
650 NCI_MSG_BLD_HDR0 (pp, NCI_MT_CMD, NCI_GID_RF_MANAGE);
651 NCI_MSG_BLD_HDR1 (pp, NCI_MSG_RF_GET_ROUTING);
652 UINT8_TO_STREAM (pp, param_size);
653
654 nfc_ncif_send_cmd (p);
655 return (NCI_STATUS_OK);
656 }
657 #endif
658 #endif
659
660
661 #endif /* NFC_INCLUDED == TRUE*/
662