1 /******************************************************************************
2 *
3 * Copyright (C) 2010-2014 Broadcom Corporation
4 * Copyright 2018-2020 NXP
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 ******************************************************************************/
19
20 /******************************************************************************
21 *
22 * UWA interface for device management
23 *
24 ******************************************************************************/
25 #include <string.h>
26
27 #include "uci_log.h"
28 #include "uwa_api.h"
29 #include "uwa_dm_int.h"
30 #include "uwa_sys.h"
31 #include "uwa_sys_int.h"
32 #include "uwb_osal_common.h"
33
34 tHAL_UWB_CONTEXT hal_Initcntxt;
35
36 /*****************************************************************************
37 ** APIs
38 *****************************************************************************/
39 /*******************************************************************************
40 **
41 ** Function UWA_Init
42 **
43 ** Description This function initializes control blocks for UWA
44 **
45 ** p_hal_entry_tbl points to a table of HAL entry points
46 **
47 ** NOTE: the buffer that p_hal_entry_tbl points must be
48 ** persistent until UWA is disabled.
49 **
50 ** Returns none
51 **
52 *******************************************************************************/
UWA_Init(tHAL_UWB_ENTRY * p_hal_entry_tbl)53 void UWA_Init(tHAL_UWB_ENTRY* p_hal_entry_tbl) {
54 UCI_TRACE_I(__func__);
55 hal_Initcntxt.hal_entry_func = p_hal_entry_tbl;
56 uwa_sys_init();
57 uwa_dm_init();
58 UWB_Init(&hal_Initcntxt);
59 }
60
61 /*******************************************************************************
62 **
63 ** Function UWA_Enable
64 **
65 ** Description This function enables UWBS. Prior to calling UWA_Enable,
66 ** the UWBC must be powered up, and ready to receive commands.
67 ** This function enables the tasks needed by UWB, opens the UCI
68 ** transport, resets the UWB Subsystem, downloads patches to
69 ** the UWBS (if necessary), and initializes the UWB subsystems.
70 **
71 ** Returns UWA_STATUS_OK if successfully initiated
72 ** UWA_STATUS_FAILED otherwise
73 **
74 *******************************************************************************/
UWA_Enable(tUWA_DM_CBACK * p_dm_cback,tUWA_DM_TEST_CBACK * p_dm_test_cback)75 tUWA_STATUS UWA_Enable(tUWA_DM_CBACK* p_dm_cback,
76 tUWA_DM_TEST_CBACK* p_dm_test_cback) {
77 tUWA_DM_API_ENABLE* p_msg;
78
79 UCI_TRACE_I(__func__);
80
81 /* Validate parameters */
82 if (!p_dm_cback) {
83 UCI_TRACE_E("error null callback");
84 return (UWA_STATUS_FAILED);
85 }
86
87 if ((p_msg = (tUWA_DM_API_ENABLE*)phUwb_GKI_getbuf(
88 sizeof(tUWA_DM_API_ENABLE))) != NULL) {
89 p_msg->hdr.event = UWA_DM_API_ENABLE_EVT;
90 p_msg->p_dm_cback = p_dm_cback;
91 p_msg->p_dm_test_cback = p_dm_test_cback;
92 uwa_sys_sendmsg(p_msg);
93
94 return (UWA_STATUS_OK);
95 }
96
97 return (UWA_STATUS_FAILED);
98 }
99
100 /*******************************************************************************
101 **
102 ** Function UWA_Disable
103 **
104 ** Description This function is called to shutdown UWBS. The tasks for UWB
105 ** are terminated, and clean up routines are performed. This
106 ** function is typically called during platform shut-down, or
107 ** when UWB is disabled from a settings UI. When the UWBS
108 ** shutdown procedure is completed, an UWA_DM_DISABLE_EVT is
109 ** returned to the application using the tUWA_DM_CBACK.
110 **
111 ** Returns UWA_STATUS_OK if successfully initiated
112 ** UWA_STATUS_FAILED otherwise
113 **
114 *******************************************************************************/
UWA_Disable(bool graceful)115 tUWA_STATUS UWA_Disable(bool graceful) {
116 tUWA_DM_API_DISABLE* p_msg;
117
118 UCI_TRACE_I("UWA_Disable (graceful=%i)", graceful);
119
120 if ((p_msg = (tUWA_DM_API_DISABLE*)phUwb_GKI_getbuf(
121 sizeof(tUWA_DM_API_DISABLE))) != NULL) {
122 p_msg->hdr.event = UWA_DM_API_DISABLE_EVT;
123 p_msg->graceful = graceful;
124
125 uwa_sys_sendmsg(p_msg);
126
127 return (UWA_STATUS_OK);
128 }
129
130 return (UWA_STATUS_FAILED);
131 }
132
133 /*******************************************************************************
134 **
135 ** Function: UWA_GetDeviceInfo
136 **
137 ** Description: This function gets the UWB Subsystem Information
138 **
139 ** Returns: UCI version and manufacturer specific information
140 **
141 *******************************************************************************/
UWA_GetDeviceInfo()142 tUWA_STATUS UWA_GetDeviceInfo() {
143 tUWA_DM_API_GET_DEVICE_INFO* p_msg;
144
145 UCI_TRACE_I("UWA_GetDeviceInfo ()");
146
147 p_msg = (tUWA_DM_API_GET_DEVICE_INFO*)phUwb_GKI_getbuf(
148 sizeof(tUWA_DM_API_GET_DEVICE_INFO));
149 if (p_msg != NULL) {
150 p_msg->hdr.event = UWA_DM_API_GET_DEVICE_INFO_EVT;
151 uwa_sys_sendmsg(p_msg);
152 return (UWA_STATUS_OK);
153 }
154 return (UWA_STATUS_FAILED);
155 }
156
157 /*******************************************************************************
158 **
159 ** Function UWA_SetCoreConfig
160 **
161 ** Description Set the configuration parameters to UWBS. The result is
162 ** reported with an UWA_DM_CORE_SET_CONFIG_RSP_EVT in the
163 ** tUWA_DM_CBACK callback.
164 **
165 ** Returns UWA_STATUS_OK if command is sent successfully
166 ** UWA_STATUS_FAILED otherwise
167 **
168 *******************************************************************************/
UWA_SetCoreConfig(tUWA_PMID param_id,uint8_t length,uint8_t * p_data)169 tUWA_STATUS UWA_SetCoreConfig(tUWA_PMID param_id, uint8_t length,
170 uint8_t* p_data) {
171 tUWA_DM_API_CORE_SET_CONFIG* p_msg;
172
173 UCI_TRACE_I("param_id:0x%X", param_id);
174
175 if ((p_msg = (tUWA_DM_API_CORE_SET_CONFIG*)phUwb_GKI_getbuf(
176 (uint16_t)(sizeof(tUWA_DM_API_CORE_SET_CONFIG) + length))) != NULL) {
177 p_msg->hdr.event = UWA_DM_API_SET_CORE_CONFIG_EVT;
178
179 p_msg->param_id = param_id;
180 p_msg->length = length;
181 p_msg->p_data = (uint8_t*)(p_msg + 1);
182
183 /* Copy parameter data */
184 memcpy(p_msg->p_data, p_data, length);
185
186 uwa_sys_sendmsg(p_msg);
187
188 return (UWA_STATUS_OK);
189 }
190
191 return (UWA_STATUS_FAILED);
192 }
193
194 /*******************************************************************************
195 **
196 ** Function UWA_GetCoreConfig
197 **
198 ** Description Get the configuration parameters from UWBS. The result is
199 ** reported with an UWA_DM_CORE_GET_CONFIG_RSP_EVT in the
200 ** tUWA_DM_CBACK callback.
201 **
202 ** Returns UWA_STATUS_OK if command is sent successfully
203 ** UWA_STATUS_FAILED otherwise
204 **
205 *******************************************************************************/
UWA_GetCoreConfig(uint8_t num_ids,tUWA_PMID * p_param_ids)206 tUWA_STATUS UWA_GetCoreConfig(uint8_t num_ids, tUWA_PMID* p_param_ids) {
207 tUWA_DM_API_CORE_GET_CONFIG* p_msg;
208
209 UCI_TRACE_I("UWA_GetCoreConfig (): num_ids: %i", num_ids);
210 if ((p_msg = (tUWA_DM_API_CORE_GET_CONFIG*)phUwb_GKI_getbuf((uint16_t)(
211 sizeof(tUWA_DM_API_CORE_GET_CONFIG) + num_ids))) != NULL) {
212 p_msg->hdr.event = UWA_DM_API_GET_CORE_CONFIG_EVT;
213 p_msg->num_ids = num_ids;
214 p_msg->p_pmids = (tUWA_PMID*)(p_msg + 1);
215 /* Copy the param IDs */
216 memcpy(p_msg->p_pmids, p_param_ids, num_ids);
217 uwa_sys_sendmsg(p_msg);
218 return (UWA_STATUS_OK);
219 }
220 return (UWA_STATUS_FAILED);
221 }
222
223 /*******************************************************************************
224 **
225 ** Function UWA_SendDeviceReset
226 **
227 ** Description Send Device Reset Command to UWBS. The result is
228 ** reported with an UWA_DM_DEVICE_RESET_RSP_EVT in the
229 ** tUWA_DM_CBACK callback.
230 **
231 ** Returns UWA_STATUS_OK if command is sent successfully
232 ** UWA_STATUS_FAILED otherwise
233 **
234 *******************************************************************************/
UWA_SendDeviceReset(uint8_t resetConfig)235 tUWA_STATUS UWA_SendDeviceReset(uint8_t resetConfig) {
236 tUWA_DM_API_DEVICE_RESET* p_msg;
237
238 UCI_TRACE_I("UWA_SendDeviceReset(): resetConfig:0x%X", resetConfig);
239
240 if ((p_msg = (tUWA_DM_API_DEVICE_RESET*)phUwb_GKI_getbuf(
241 (uint16_t)(sizeof(tUWA_DM_API_DEVICE_RESET)))) != NULL) {
242 p_msg->hdr.event = UWA_DM_API_DEVICE_RESET_EVT;
243 p_msg->resetConfig = resetConfig;
244
245 uwa_sys_sendmsg(p_msg);
246
247 return (UWA_STATUS_OK);
248 }
249
250 return (UWA_STATUS_FAILED);
251 }
252
253 /*******************************************************************************
254 **
255 ** Function UWA_SendSessionInit
256 **
257 ** Description This function is called to send session init command.
258 ** The result is reported with an UWA_DM_SESSION_INIT_RSP_EVT
259 ** in the tUWA_DM_CBACK callback
260 **
261 ** session id - value of particular session ID
262 ** session type - type of session to start ex: ranging,app etc
263 **
264 ** Returns UWA_STATUS_OK if successfully initiated
265 ** UWA_STATUS_FAILED otherwise
266 **
267 *******************************************************************************/
UWA_SendSessionInit(uint32_t session_id,uint8_t sessionType)268 extern tUWA_STATUS UWA_SendSessionInit(uint32_t session_id,
269 uint8_t sessionType) {
270 tUWA_DM_API_SESSION_INIT* p_msg;
271 p_msg = (tUWA_DM_API_SESSION_INIT*)phUwb_GKI_getbuf(
272 sizeof(tUWA_DM_API_SESSION_INIT));
273
274 if (p_msg != NULL) {
275 p_msg->hdr.event = UWA_DM_API_SESSION_INIT_EVT;
276 p_msg->session_id = session_id;
277 p_msg->sessionType = sessionType;
278 uwa_sys_sendmsg(p_msg);
279
280 return UWA_STATUS_OK;
281 }
282
283 return UWA_STATUS_FAILED;
284 }
285
286 /*******************************************************************************
287 **
288 ** Function UWA_SendSessionDeInit
289 **
290 ** Description This function is called to send session deinit command.
291 ** The result is reported with an UWA_DM_SESSION_DEINIT_RSP_EVT
292 ** in the tUWA_DM_CBACK callback
293 **
294 ** session id - value of particular session ID
295 **
296 ** Returns UWA_STATUS_OK if successfully initiated
297 ** UWA_STATUS_FAILED otherwise
298 **
299 *******************************************************************************/
UWA_SendSessionDeInit(uint32_t session_id)300 extern tUWA_STATUS UWA_SendSessionDeInit(uint32_t session_id) {
301 tUWA_DM_API_SESSION_DEINIT* p_msg;
302 p_msg = (tUWA_DM_API_SESSION_DEINIT*)phUwb_GKI_getbuf(
303 sizeof(tUWA_DM_API_SESSION_DEINIT));
304
305 if (p_msg != NULL) {
306 p_msg->hdr.event = UWA_DM_API_SESSION_DEINIT_EVT;
307 p_msg->session_id = session_id;
308 uwa_sys_sendmsg(p_msg);
309
310 return UWA_STATUS_OK;
311 }
312
313 return UWA_STATUS_FAILED;
314 }
315
316 /*******************************************************************************
317 **
318 ** Function UWA_GetSessionCount
319 **
320 ** Description This function is called to send get session count command
321 ** The result is reported with an
322 ** UWA_DM_SESSION_GET_COUNT_RSP_EVT
323 ** in the tUWA_DM_CBACK callback.
324 **
325 ** Returns UWA_STATUS_OK if command is successfully sent
326 ** UWA_STATUS_FAILED otherwise
327 **
328 *******************************************************************************/
UWA_GetSessionCount()329 tUWA_STATUS UWA_GetSessionCount() {
330 tUWA_DM_API_GET_SESSION_COUNT* p_msg;
331
332 UCI_TRACE_I("UWA_GetSessionCount ()");
333
334 p_msg = (tUWA_DM_API_GET_SESSION_COUNT*)phUwb_GKI_getbuf(
335 sizeof(tUWA_DM_API_GET_SESSION_COUNT));
336 if (p_msg != NULL) {
337 p_msg->hdr.event = UWA_DM_API_SESSION_GET_COUNT_EVT;
338 uwa_sys_sendmsg(p_msg);
339 return (UWA_STATUS_OK);
340 }
341 return (UWA_STATUS_FAILED);
342 }
343
344 /*******************************************************************************
345 **
346 ** Function UWA_SetAppConfig
347 **
348 ** Description Set the configuration parameters to UWBS. The result is
349 ** reported with an UWA_DM_SESSION_SET_CONFIG_RSP_EVT in the
350 ** tUWA_DM_CBACK callback.
351 **
352 ** Returns UWA_STATUS_OK if command is sent successfully
353 ** UWA_STATUS_FAILED otherwise
354 **
355 *******************************************************************************/
UWA_SetAppConfig(uint32_t session_id,uint8_t noOfParams,uint8_t paramLen,uint8_t appConfigParams[])356 tUWA_STATUS UWA_SetAppConfig(uint32_t session_id, uint8_t noOfParams,
357 uint8_t paramLen, uint8_t appConfigParams[]) {
358 tUWA_DM_API_SET_APP_CONFIG* p_msg;
359
360 if ((p_msg = (tUWA_DM_API_SET_APP_CONFIG*)phUwb_GKI_getbuf((uint16_t)(
361 sizeof(tUWA_DM_API_SET_APP_CONFIG) + paramLen))) != NULL) {
362 p_msg->hdr.event = UWA_DM_API_SET_APP_CONFIG_EVT;
363
364 p_msg->session_id = session_id;
365 p_msg->num_ids = noOfParams;
366 p_msg->length = paramLen;
367 p_msg->p_data = (uint8_t*)(p_msg + 1);
368
369 /* Copy parameter data */
370 memcpy(p_msg->p_data, appConfigParams, paramLen);
371
372 uwa_sys_sendmsg(p_msg);
373
374 return (UWA_STATUS_OK);
375 }
376
377 return (UWA_STATUS_FAILED);
378 }
379
380 /*******************************************************************************
381 **
382 ** Function UWA_GetAppConfig
383 **
384 ** Description Get the configuration parameters from UWBS. The result is
385 ** reported with an UWA_DM_SESSION_GET_CONFIG_RSP_EVT in the
386 ** tUWA_DM_CBACK callback.
387 **
388 ** Returns UWA_STATUS_OK if command is sent successfully
389 ** UWA_STATUS_FAILED otherwise
390 **
391 *******************************************************************************/
UWA_GetAppConfig(uint32_t session_id,uint8_t noOfParams,uint8_t paramLen,tUWA_PMID * p_param_ids)392 tUWA_STATUS UWA_GetAppConfig(uint32_t session_id, uint8_t noOfParams,
393 uint8_t paramLen, tUWA_PMID* p_param_ids) {
394 tUWA_DM_API_GET_APP_CONFIG* p_msg;
395
396 UCI_TRACE_I("UWA_GetAppConfig (): num_ids: %i", noOfParams);
397 if ((p_msg = (tUWA_DM_API_GET_APP_CONFIG*)phUwb_GKI_getbuf((uint16_t)(
398 sizeof(tUWA_DM_API_GET_APP_CONFIG) + paramLen))) != NULL) {
399 p_msg->hdr.event = UWA_DM_API_GET_APP_CONFIG_EVT;
400 p_msg->session_id = session_id;
401 p_msg->num_ids = noOfParams;
402 p_msg->length = paramLen;
403 p_msg->p_pmids = (tUWA_PMID*)(p_msg + 1);
404
405 /* Copy the param IDs */
406 memcpy(p_msg->p_pmids, p_param_ids, paramLen);
407
408 uwa_sys_sendmsg(p_msg);
409
410 return (UWA_STATUS_OK);
411 }
412
413 return (UWA_STATUS_FAILED);
414 }
415
416 /*******************************************************************************
417 **
418 ** Function UWA_StartRangingSession
419 **
420 ** Description start the ranging session.
421 ** The result is reported with an UWA_DM_RANGE_START_RSP_EVT in
422 ** the tUWA_DM_CBACK callback
423 **
424 ** Returns UWA_STATUS_OK if ranging started successfully
425 ** UWA_STATUS_FAILED otherwise
426 **
427 *******************************************************************************/
UWA_StartRangingSession(uint32_t session_id)428 tUWA_STATUS UWA_StartRangingSession(uint32_t session_id) {
429 tUWA_DM_API_RANGING_START* p_msg;
430
431 UCI_TRACE_I("UWA_StartRangingSession ():");
432
433 p_msg = (tUWA_DM_API_RANGING_START*)phUwb_GKI_getbuf(
434 sizeof(tUWA_DM_API_RANGING_START));
435 if (p_msg != NULL) {
436 p_msg->hdr.event = UWA_DM_API_START_RANGE_EVT;
437 p_msg->session_id = session_id;
438 uwa_sys_sendmsg(p_msg);
439 return (UWA_STATUS_OK);
440 }
441
442 return (UWA_STATUS_FAILED);
443 }
444
445 /*******************************************************************************
446 **
447 ** Function UWA_StopRangingSession
448 **
449 ** Description stop the ranging session.
450 ** The result is reported with an UWA_DM_RANGE_STOP_RSP_EVT
451 ** in the tUWA_DM_CBACK callback.
452 **
453 ** Returns UWA_STATUS_OK if ranging is stopped successfully
454 ** UWA_STATUS_FAILED otherwise
455 **
456 *******************************************************************************/
UWA_StopRangingSession(uint32_t session_id)457 tUWA_STATUS UWA_StopRangingSession(uint32_t session_id) {
458 tUWA_DM_API_RANGING_STOP* p_msg;
459
460 UCI_TRACE_I("UWA_StopRangingSession ()");
461
462 p_msg = (tUWA_DM_API_RANGING_STOP*)phUwb_GKI_getbuf(
463 sizeof(tUWA_DM_API_RANGING_STOP));
464 if (p_msg != NULL) {
465 p_msg->hdr.event = UWA_DM_API_STOP_RANGE_EVT;
466 p_msg->session_id = session_id;
467 uwa_sys_sendmsg(p_msg);
468 return (UWA_STATUS_OK);
469 }
470 return (UWA_STATUS_FAILED);
471 }
472
473 /*******************************************************************************
474 **
475 ** Function UWA_GetRangingCount
476 **
477 ** Description Get ranging count.
478 ** The result is reported with an
479 ** UWA_DM_GET_RANGE_COUNT_RSP_EVT
480 ** in the tUWA_DM_CBACK callback.
481 **
482 ** Returns ranging count if successful
483 ** 0 otherwise
484 **
485 *******************************************************************************/
UWA_GetRangingCount(uint32_t session_id)486 tUWA_STATUS UWA_GetRangingCount(uint32_t session_id) {
487 tUWA_DM_API_GET_RANGING_COUNT* p_msg;
488
489 UCI_TRACE_I("UWA_GetRangeCount ()");
490
491 p_msg = (tUWA_DM_API_GET_RANGING_COUNT*)phUwb_GKI_getbuf(
492 sizeof(tUWA_DM_API_GET_RANGING_COUNT));
493 if (p_msg != NULL) {
494 p_msg->hdr.event = UWA_DM_API_GET_RANGE_COUNT_EVT;
495 p_msg->session_id = session_id;
496 uwa_sys_sendmsg(p_msg);
497 return (UWA_STATUS_OK);
498 }
499 return (UWA_STATUS_FAILED);
500 }
501
502 /*******************************************************************************
503 **
504 ** Function UWA_GetSessionStatus
505 **
506 ** Description Get session status.
507 ** The result is reported with an
508 ** UWA_DM_SESSION_GET_STATE_RSP_EVT
509 ** in the tUWA_DM_CBACK callback.
510 **
511 ** Returns session status if successful
512 ** UWA_STATUS_FAILED otherwise
513 **
514 *******************************************************************************/
UWA_GetSessionStatus(uint32_t session_id)515 tUWA_STATUS UWA_GetSessionStatus(uint32_t session_id) {
516 tUWA_DM_API_GET_SESSION_STATUS* p_msg;
517
518 UCI_TRACE_I("UWA_GetSessionStatus ()");
519
520 p_msg = (tUWA_DM_API_GET_SESSION_STATUS*)phUwb_GKI_getbuf(
521 sizeof(tUWA_DM_API_GET_SESSION_STATUS));
522 if (p_msg != NULL) {
523 p_msg->hdr.event = UWA_DM_API_GET_SESSION_STATUS_EVT;
524 p_msg->session_id = session_id;
525 uwa_sys_sendmsg(p_msg);
526 return (UWA_STATUS_OK);
527 }
528 return (UWA_STATUS_FAILED);
529 }
530
531 /*******************************************************************************
532 **
533 ** Function UWA_GetCoreGetDeviceCapability
534 **
535 ** Description Get core device capability info command.
536 ** The result is reported with an
537 ** UWA_DM_GET_CORE_DEVICE_CAP_RSP_EVT
538 ** in the tUWA_DM_CBACK callback.
539 **
540 ** Returns UWA_STATUS_OK if successfully sent
541 ** UWA_STATUS_FAILED otherwise
542 **
543 *******************************************************************************/
UWA_GetCoreGetDeviceCapability()544 tUWA_STATUS UWA_GetCoreGetDeviceCapability() {
545 tUWA_DM_API_CORE_GET_DEVICE_CAPABILITY* p_msg;
546
547 UCI_TRACE_I("UWA_GetCoreGetDeviceCapability()");
548
549 p_msg = (tUWA_DM_API_CORE_GET_DEVICE_CAPABILITY*)phUwb_GKI_getbuf(
550 sizeof(tUWA_DM_API_CORE_GET_DEVICE_CAPABILITY));
551 if (p_msg != NULL) {
552 p_msg->hdr.event = UWA_DM_API_CORE_GET_DEVICE_CAPABILITY_EVT;
553 uwa_sys_sendmsg(p_msg);
554 return (UWA_STATUS_OK);
555 }
556 return (UWA_STATUS_FAILED);
557 }
558
559 /*******************************************************************************
560 **
561 ** Function UWA_ControllerMulticastListUpdate
562 **
563 ** Description This function is called to send Controller Multicast List
564 ** Update.
565 ** The result is reported with an
566 ** UWA_DM_SESSION_MC_LIST_UPDATE_RSP_EVT
567 ** in the tUWA_DM_CBACK callback.
568 **
569 ** Returns UWA_STATUS_OK if command is successfully initiated
570 ** UWA_STATUS_FAILED otherwise
571 **
572 *******************************************************************************/
UWA_ControllerMulticastListUpdate(uint32_t session_id,uint8_t action,uint8_t noOfControlees,uint16_t * shortAddressList,uint32_t * subSessionIdList)573 extern tUWA_STATUS UWA_ControllerMulticastListUpdate(
574 uint32_t session_id, uint8_t action, uint8_t noOfControlees,
575 uint16_t* shortAddressList, uint32_t* subSessionIdList) {
576 tUWA_DM_API_SESSION_UPDATE_MULTICAST_LIST* p_msg;
577 p_msg = (tUWA_DM_API_SESSION_UPDATE_MULTICAST_LIST*)phUwb_GKI_getbuf(
578 sizeof(tUWA_DM_API_SESSION_UPDATE_MULTICAST_LIST));
579
580 if (p_msg != NULL) {
581 p_msg->hdr.event = UWA_DM_API_SESSION_UPDATE_MULTICAST_LIST_EVT;
582 p_msg->session_id = session_id;
583 p_msg->action = action;
584 p_msg->no_of_controlee = noOfControlees;
585 if ((noOfControlees > 0) && (shortAddressList != NULL)) {
586 memcpy(p_msg->short_address_list, shortAddressList,
587 (noOfControlees * SHORT_ADDRESS_LEN));
588 }
589 if ((noOfControlees > 0) && (subSessionIdList != NULL)) {
590 memcpy(p_msg->subsession_id_list, subSessionIdList,
591 (noOfControlees * SESSION_ID_LEN));
592 }
593 uwa_sys_sendmsg(p_msg);
594
595 return UWA_STATUS_OK;
596 }
597 return UWA_STATUS_FAILED;
598 }
599
600 /*******************************************************************************
601 **
602 ** Function UWA_ControllerSetCountryCode
603 **
604 ** Description This function is called to set country code.
605 ** The result is reported with an
606 ** UWA_DM_SET_COUNTRY_CODE_RSP_EVT
607 ** in the tUWA_DM_CBACK callback.
608 **
609 ** Returns UWA_STATUS_OK if command is successfully initiated
610 ** UWA_STATUS_FAILED otherwise
611 **
612 *******************************************************************************/
UWA_ControllerSetCountryCode(uint8_t * countryCodeArray)613 extern tUWA_STATUS UWA_ControllerSetCountryCode(uint8_t* countryCodeArray) {
614 tUWA_DM_API_SET_COUNTRY_CODE * p_msg;
615 p_msg = (tUWA_DM_API_SET_COUNTRY_CODE *)phUwb_GKI_getbuf(
616 sizeof(tUWA_DM_API_SET_COUNTRY_CODE));
617
618 if (p_msg != NULL) {
619 p_msg->hdr.event = UWA_DM_API_SET_COUNTRY_CODE_EVT;
620 if (countryCodeArray != NULL) {
621 memcpy(p_msg->country_code, countryCodeArray, COUNTRY_CODE_ARRAY_LEN);
622 }
623 uwa_sys_sendmsg(p_msg);
624 return UWA_STATUS_OK;
625 }
626 return UWA_STATUS_FAILED;
627 }
628
629 /*******************************************************************************
630 **
631 ** Function UWA_SendBlinkData
632 **
633 ** Description This function is called to send Blink Data Tx.
634 ** The result is reported with an
635 ** UWA_DM_SEND_BLINK_DATA_RSP_EVT
636 ** in the tUWA_DM_CBACK callback.
637 **
638 ** Returns UWA_STATUS_OK if successfully initiated
639 ** UWA_STATUS_FAILED otherwise
640 **
641 *******************************************************************************/
UWA_SendBlinkData(uint32_t session_id,uint8_t repetition_count,uint8_t app_data_len,uint8_t * app_data)642 extern tUWA_STATUS UWA_SendBlinkData(uint32_t session_id,
643 uint8_t repetition_count,
644 uint8_t app_data_len, uint8_t* app_data) {
645 tUWA_DM_API_SEND_BLINK_DATA* p_msg;
646 p_msg = (tUWA_DM_API_SEND_BLINK_DATA*)phUwb_GKI_getbuf(
647 sizeof(tUWA_DM_API_SEND_BLINK_DATA));
648
649 if (p_msg != NULL) {
650 p_msg->hdr.event = UWA_DM_API_SEND_BLINK_DATA_EVT;
651 p_msg->session_id = session_id;
652 p_msg->repetition_count = repetition_count;
653 p_msg->app_data_len = app_data_len;
654 if ((app_data_len > 0) && (app_data != NULL)) {
655 memcpy(p_msg->app_data, app_data, app_data_len);
656 }
657
658 uwa_sys_sendmsg(p_msg);
659
660 return UWA_STATUS_OK;
661 }
662 return UWA_STATUS_FAILED;
663 }
664
665 /* UWA APIs for RF Test functionality */
666
667 /*******************************************************************************
668 **
669 ** Function UWA_TestSetConfig
670 **
671 ** Description Set the configuration parameters to UWBS.
672 ** The result is reported with an
673 ** UWA_DM_TEST_SET_CONFIG_RSP_EVT
674 ** in the tUWA_DM_TEST_CBACK callback.
675 **
676 ** Returns UWA_STATUS_OK if command is sent successfully
677 ** UWA_STATUS_FAILED otherwise
678 **
679 *******************************************************************************/
UWA_TestSetConfig(uint32_t session_id,uint8_t noOfParams,uint8_t paramLen,uint8_t testConfigParams[])680 tUWA_STATUS UWA_TestSetConfig(uint32_t session_id, uint8_t noOfParams,
681 uint8_t paramLen, uint8_t testConfigParams[]) {
682 tUWA_DM_API_TEST_SET_CONFIG* p_msg;
683
684 if ((p_msg = (tUWA_DM_API_TEST_SET_CONFIG*)phUwb_GKI_getbuf((uint16_t)(
685 sizeof(tUWA_DM_API_TEST_SET_CONFIG) + paramLen))) != NULL) {
686 p_msg->hdr.event = UWA_DM_API_TEST_SET_CONFIG_EVT;
687
688 p_msg->session_id = session_id;
689 p_msg->num_ids = noOfParams;
690 p_msg->length = paramLen;
691 p_msg->p_data = (uint8_t*)(p_msg + 1);
692
693 /* Copy parameter data */
694 memcpy(p_msg->p_data, testConfigParams, paramLen);
695
696 uwa_sys_sendmsg(p_msg);
697
698 return (UWA_STATUS_OK);
699 }
700
701 return (UWA_STATUS_FAILED);
702 }
703
704 /*******************************************************************************
705 **
706 ** Function UWA_TestGetConfig
707 **
708 ** Description Get the configuration parameters from UWBS.
709 ** The result is reported with an
710 ** UWA_DM_TEST_GET_CONFIG_RSP_EVT
711 ** in the tUWA_DM_TEST_CBACK callback.
712 **
713 ** Returns UWA_STATUS_OK if command is sent successfully
714 ** UWA_STATUS_FAILED otherwise
715 **
716 *******************************************************************************/
UWA_TestGetConfig(uint32_t session_id,uint8_t noOfParams,uint8_t paramLen,tUWA_PMID * p_param_ids)717 tUWA_STATUS UWA_TestGetConfig(uint32_t session_id, uint8_t noOfParams,
718 uint8_t paramLen, tUWA_PMID* p_param_ids) {
719 tUWA_DM_API_TEST_GET_CONFIG* p_msg;
720
721 UCI_TRACE_I("UWA_TestGetConfig (): num_ids: %i", noOfParams);
722 if ((p_msg = (tUWA_DM_API_TEST_GET_CONFIG*)phUwb_GKI_getbuf((uint16_t)(
723 sizeof(tUWA_DM_API_TEST_GET_CONFIG) + paramLen))) != NULL) {
724 p_msg->hdr.event = UWA_DM_API_TEST_GET_CONFIG_EVT;
725 p_msg->session_id = session_id;
726 p_msg->num_ids = noOfParams;
727 p_msg->length = paramLen;
728 p_msg->p_pmids = (tUWA_PMID*)(p_msg + 1);
729
730 /* Copy the param IDs */
731 memcpy(p_msg->p_pmids, p_param_ids, paramLen);
732
733 uwa_sys_sendmsg(p_msg);
734
735 return (UWA_STATUS_OK);
736 }
737
738 return (UWA_STATUS_FAILED);
739 }
740
741 /*******************************************************************************
742 **
743 ** Function UWA_PeriodicTxTest
744 **
745 ** Description This function is called to trigger the periodic Tx Test.
746 ** The result is reported with an
747 ** UWA_DM_TEST_PERIODIC_TX_RSP_EVT
748 ** in the tUWA_DM_TEST_CBACK callback.
749 **
750 ** Returns UWA_STATUS_OK if command is sent successfully
751 ** UWA_STATUS_FAILED otherwise
752 **
753 *******************************************************************************/
UWA_PeriodicTxTest(uint16_t psduLen,uint8_t psduData[])754 tUWA_STATUS UWA_PeriodicTxTest(uint16_t psduLen, uint8_t psduData[]) {
755 tUWA_DM_API_TEST_PERIODIC_TX* p_msg;
756
757 if ((p_msg = (tUWA_DM_API_TEST_PERIODIC_TX*)phUwb_GKI_getbuf((uint16_t)(
758 sizeof(tUWA_DM_API_TEST_PERIODIC_TX) + psduLen))) != NULL) {
759 p_msg->hdr.event = UWA_DM_API_TEST_PERIODIC_TX_EVT;
760 p_msg->length = psduLen;
761 p_msg->p_data = (uint8_t*)(p_msg + 1);
762 if ((psduLen > 0) && (psduData != NULL)) {
763 memcpy(p_msg->p_data, psduData, psduLen);
764 }
765
766 uwa_sys_sendmsg(p_msg);
767
768 return (UWA_STATUS_OK);
769 }
770
771 return (UWA_STATUS_FAILED);
772 }
773
774 /*******************************************************************************
775 **
776 ** Function UWA_PerRxTest
777 **
778 ** Description This function is called to trigger the PER Rx Tx Test
779 ** The result is reported with an UWA_DM_TEST_PER_RX_RSP_EVT
780 ** in the tUWA_DM_TEST_CBACK callback.
781 **
782 ** Returns UWA_STATUS_OK if command is sent successfully
783 ** UWA_STATUS_FAILED otherwise
784 **
785 *******************************************************************************/
UWA_PerRxTest(uint16_t psduLen,uint8_t psduData[])786 tUWA_STATUS UWA_PerRxTest(uint16_t psduLen, uint8_t psduData[]) {
787 tUWA_DM_API_TEST_PER_RX* p_msg;
788
789 if ((p_msg = (tUWA_DM_API_TEST_PER_RX*)phUwb_GKI_getbuf(
790 (uint16_t)(sizeof(tUWA_DM_API_TEST_PER_RX) + psduLen))) != NULL) {
791 p_msg->hdr.event = UWA_DM_API_TEST_PER_RX_EVT;
792 p_msg->length = psduLen;
793 p_msg->p_data = (uint8_t*)(p_msg + 1);
794 if ((psduLen > 0) && (psduData != NULL)) {
795 memcpy(p_msg->p_data, psduData, psduLen);
796 }
797
798 uwa_sys_sendmsg(p_msg);
799
800 return (UWA_STATUS_OK);
801 }
802
803 return (UWA_STATUS_FAILED);
804 }
805
806 /*******************************************************************************
807 **
808 ** Function UWA_UwbLoopBackTest
809 **
810 ** Description This function is called to trigger the loop back Test.
811 ** The result is reported with an UWA_DM_TEST_LOOPBACK_RSP_EVT
812 ** in the tUWA_DM_TEST_CBACK callback.
813 **
814 ** Returns UWA_STATUS_OK if command is sent successfully
815 ** UWA_STATUS_FAILED otherwise
816 **
817 *******************************************************************************/
UWA_UwbLoopBackTest(uint16_t psduLen,uint8_t psduData[])818 tUWA_STATUS UWA_UwbLoopBackTest(uint16_t psduLen, uint8_t psduData[]) {
819 tUWA_DM_API_TEST_UWB_LOOPBACK* p_msg;
820
821 if ((p_msg = (tUWA_DM_API_TEST_UWB_LOOPBACK*)phUwb_GKI_getbuf((uint16_t)(
822 sizeof(tUWA_DM_API_TEST_UWB_LOOPBACK) + psduLen))) != NULL) {
823 p_msg->hdr.event = UWA_DM_API_TEST_UWB_LOOPBACK_EVT;
824 p_msg->length = psduLen;
825 p_msg->p_data = (uint8_t*)(p_msg + 1);
826 if ((psduLen > 0) && (psduData != NULL)) {
827 memcpy(p_msg->p_data, psduData, psduLen);
828 }
829
830 uwa_sys_sendmsg(p_msg);
831
832 return (UWA_STATUS_OK);
833 }
834
835 return (UWA_STATUS_FAILED);
836 }
837
838 /*******************************************************************************
839 **
840 ** Function UWA_RxTest
841 **
842 ** Description This function is called to trigger the Rx Test.
843 ** The result is reported with an UWA_DM_TEST_RX_RSP_EVT in the
844 ** tUWA_DM_TEST_CBACK callback.
845 **
846 ** Returns UWA_STATUS_OK if Per Session stopped successfully
847 ** UWA_STATUS_FAILED otherwise
848 **
849 *******************************************************************************/
UWA_RxTest()850 tUWA_STATUS UWA_RxTest() {
851 tUWA_DM_API_TEST_RX* p_msg;
852
853 UCI_TRACE_I("UWA_RxTest()");
854
855 p_msg = (tUWA_DM_API_TEST_RX*)phUwb_GKI_getbuf(
856 sizeof(tUWA_DM_API_TEST_STOP_SESSION));
857 if (p_msg != NULL) {
858 p_msg->hdr.event = UWA_DM_API_TEST_RX_EVT;
859 uwa_sys_sendmsg(p_msg);
860 return (UWA_STATUS_OK);
861 }
862 return (UWA_STATUS_FAILED);
863 }
864
865 /*******************************************************************************
866 **
867 ** Function UWA_TestStopSession
868 **
869 ** Description This function is called to stop the ongoing test session.
870 ** The result is reported with an
871 ** UWA_DM_TEST_STOP_SESSION_RSP_EVT in the
872 ** tUWA_DM_TEST_CBACK callback.
873 **
874 ** Returns UWA_STATUS_OK if Per Session stopped successfully
875 ** UWA_STATUS_FAILED otherwise
876 **
877 *******************************************************************************/
UWA_TestStopSession()878 tUWA_STATUS UWA_TestStopSession() {
879 tUWA_DM_API_TEST_STOP_SESSION* p_msg;
880
881 UCI_TRACE_I("UWA_TestStopSession()");
882
883 p_msg = (tUWA_DM_API_TEST_STOP_SESSION*)phUwb_GKI_getbuf(
884 sizeof(tUWA_DM_API_TEST_STOP_SESSION));
885 if (p_msg != NULL) {
886 p_msg->hdr.event = UWA_DM_API_TEST_STOP_SESSION_EVT;
887 uwa_sys_sendmsg(p_msg);
888 return (UWA_STATUS_OK);
889 }
890 return (UWA_STATUS_FAILED);
891 }
892
893 /*******************************************************************************
894 **
895 ** Function UWA_SendRawVsCommand
896 **
897 ** Description This function is called to send raw Vendor Specific
898 ** command to UWBS.
899 **
900 ** cmd_params_len - The command parameter len
901 ** p_cmd_params - The command parameter
902 ** p_cback - The callback function to receive the
903 ** command
904 **
905 ** Returns UWA_STATUS_OK if successfully initiated
906 ** UWA_STATUS_FAILED otherwise
907 **
908 *******************************************************************************/
UWA_SendRawCommand(uint16_t cmd_params_len,uint8_t * p_cmd_params,tUWA_RAW_CMD_CBACK * p_cback)909 tUWA_STATUS UWA_SendRawCommand(uint16_t cmd_params_len, uint8_t* p_cmd_params,
910 tUWA_RAW_CMD_CBACK* p_cback) {
911 if (cmd_params_len == 0x00 || p_cmd_params == NULL || p_cback == NULL) {
912 return UWA_STATUS_INVALID_PARAM;
913 }
914 uint16_t size = (uint16_t)(sizeof(tUWA_DM_API_SEND_RAW) + cmd_params_len);
915 tUWA_DM_API_SEND_RAW* p_msg = (tUWA_DM_API_SEND_RAW*)phUwb_GKI_getbuf(size);
916
917 if (p_msg != NULL) {
918 p_msg->hdr.event = UWA_DM_API_SEND_RAW_EVT;
919 p_msg->p_cback = p_cback;
920 if (cmd_params_len && p_cmd_params) {
921 p_msg->cmd_params_len = cmd_params_len;
922 p_msg->p_cmd_params = (uint8_t*)(p_msg + 1);
923 memcpy(p_msg->p_cmd_params, p_cmd_params, cmd_params_len);
924 }
925 uwa_sys_sendmsg(p_msg);
926
927 return UWA_STATUS_OK;
928 }
929
930 return UWA_STATUS_FAILED;
931 }