35 #include "btrCore_logger.h"
39 #include "btrCore_service.h"
41 #include "btrCore_avMedia.h"
42 #include "btrCore_le.h"
44 #include "btrCore_bt_ifce.h"
47 #ifdef RDK_LOGGER_ENABLED
48 int b_rdk_logger_enabled = 0;
53 typedef enum _enBTRCoreTaskOp {
57 enBTRCoreTaskOpProcess,
59 enBTRCoreTaskOpUnknown
62 typedef enum _enBTRCoreTaskProcessType {
63 enBTRCoreTaskPTcBAdapterStatus,
64 enBTRCoreTaskPTcBDeviceDisc,
65 enBTRCoreTaskPTcBDeviceRemoved,
66 enBTRCoreTaskPTcBDeviceLost,
67 enBTRCoreTaskPTcBDeviceStatus,
68 enBTRCoreTaskPTcBMediaStatus,
69 enBTRCoreTaskPTcBDevOpInfoStatus,
70 enBTRCoreTaskPTcBConnIntim,
71 enBTRCoreTaskPTcBConnAuth,
72 enBTRCoreTaskPTUnknown
73 } enBTRCoreTaskProcessType;
77 enBTRCoreTaskOp enBTRCoreTskOp;
78 enBTRCoreTaskProcessType enBTRCoreTskPT;
79 void* pvBTRCoreTskInData;
84 tBTRCoreDevId bTRCoreDevId;
85 enBTRCoreDeviceType enBTRCoreDevType;
91 enBTRCoreDeviceState eDevicePrevState;
92 enBTRCoreDeviceState eDeviceCurrState;
98 tBTRCoreAVMediaHdl avMediaHdl;
104 unsigned int numOfAdapters;
105 char* adapterPath[BTRCORE_MAX_NUM_BT_ADAPTERS];
106 char* adapterAddr[BTRCORE_MAX_NUM_BT_ADAPTERS];
108 char* curAdapterPath;
109 char* curAdapterAddr;
111 unsigned int numOfScannedDevices;
115 unsigned int numOfPairedDevices;
125 fPtr_BTRCore_DeviceDiscCb fpcBBTRCoreDeviceDisc;
126 fPtr_BTRCore_StatusCb fpcBBTRCoreStatus;
127 fPtr_BTRCore_MediaStatusCb fpcBBTRCoreMediaStatus;
128 fPtr_BTRCore_ConnIntimCb fpcBBTRCoreConnIntim;
129 fPtr_BTRCore_ConnAuthCb fpcBBTRCoreConnAuth;
131 void* pvcBDevDiscUserData;
132 void* pvcBStatusUserData;
133 void* pvcBMediaStatusUserData;
134 void* pvcBConnIntimUserData;
135 void* pvcBConnAuthUserData;
138 GThread* pThreadRunTask;
139 GAsyncQueue* pGAQueueRunTask;
141 GThread* pThreadOutTask;
142 GAsyncQueue* pGAQueueOutTask;
143 enBTRCoreDeviceType aenDeviceDiscoveryType;
149 static void btrCore_InitDataSt (
stBTRCoreHdl* apsthBTRCore);
150 static tBTRCoreDevId btrCore_GenerateUniqueDeviceID (
const char* apcDeviceMac);
151 static enBTRCoreDeviceClass btrCore_MapClassIDtoAVDevClass(
unsigned int aui32ClassId);
152 static enBTRCoreDeviceClass btrCore_MapServiceClasstoDevType(
unsigned int aui32ClassId);
153 static enBTRCoreDeviceClass btrCore_MapClassIDtoDevClass(
unsigned int aui32ClassId);
154 static enBTRCoreDeviceType btrCore_MapClassIDToDevType(
unsigned int aui32ClassId,
enBTDeviceType aeBtDeviceType);
155 static enBTRCoreDeviceType btrCore_MapDevClassToDevType(enBTRCoreDeviceClass aenBTRCoreDevCl);
156 static void btrCore_ClearScannedDevicesList (
stBTRCoreHdl* apsthBTRCore);
158 static enBTRCoreRet btrCore_RemoveDeviceFromScannedDevicesArr (
stBTRCoreHdl* apsthBTRCore, tBTRCoreDevId aBTRCoreDevId,
stBTRCoreBTDevice* astRemovedDevice);
160 static enBTRCoreRet btrCore_RemoveDeviceFromKnownDevicesArr (
stBTRCoreHdl* apstlhBTRCore, tBTRCoreDevId aBTRCoreDevId);
161 static enBTRCoreRet btrCore_PopulateListOfPairedDevices(
stBTRCoreHdl* apsthBTRCore,
const char* pAdapterPath);
163 static const char* btrCore_GetScannedDeviceAddress (
stBTRCoreHdl* apsthBTRCore, tBTRCoreDevId aBTRCoreDevId);
164 static const char* btrCore_GetKnownDeviceMac (
stBTRCoreHdl* apsthBTRCore, tBTRCoreDevId aBTRCoreDevId);
165 static enBTRCoreRet btrCore_GetDeviceInfo (
stBTRCoreHdl* apsthBTRCore, tBTRCoreDevId aBTRCoreDevId, enBTRCoreDeviceType aenBTRCoreDevType,
167 stBTRCoreDevStateInfo** appstBTRCoreDevStateInfo,
const char** appcBTRCoreBTDevicePath,
const char** appcBTRCoreBTDeviceName);
168 static enBTRCoreRet btrCore_GetDeviceInfoKnown (
stBTRCoreHdl* apsthBTRCore, tBTRCoreDevId aBTRCoreDevId, enBTRCoreDeviceType aenBTRCoreDevType,
171 static void btrCore_ShowSignalStrength (
short strength);
172 static unsigned int btrCore_BTParseUUIDValue (
const char *pUUIDString,
char* pServiceNameOut);
173 static enBTRCoreDeviceState btrCore_BTParseDeviceState (
const char* pcStateValue);
174 static eBTRCoreMedElementType btrCore_GetMediaElementType (eBTRCoreAVMElementType aeMediaElementType);
176 static enBTRCoreRet btrCore_RunTaskAddOp (GAsyncQueue* apRunTaskGAq, enBTRCoreTaskOp aenRunTaskOp, enBTRCoreTaskProcessType aenRunTaskPT,
void* apvRunTaskInData);
177 static enBTRCoreRet btrCore_OutTaskAddOp (GAsyncQueue* apOutTaskGAq, enBTRCoreTaskOp aenOutTaskOp, enBTRCoreTaskProcessType aenOutTaskPT,
void* apvOutTaskInData);
182 static gpointer btrCore_RunTask (gpointer apsthBTRCore);
183 static gpointer btrCore_OutTask (gpointer apsthBTRCore);
188 static int btrCore_BTDeviceConnectionIntimationCb (
enBTDeviceType aeBtDeviceType,
stBTDeviceInfo* apstBTDeviceInfo,
unsigned int aui32devPassKey,
unsigned char ucIsReqConfirmation,
void* apUserData);
191 static enBTRCoreRet btrCore_BTMediaStatusUpdateCb (
stBTRCoreAVMediaStatusUpdate* apMediaStreamStatus,
const char* apBtdevAddr,
void* apUserData);
192 static enBTRCoreRet btrCore_BTLeStatusUpdateCb (
stBTRCoreLeGattInfo* apstBtrLeInfo,
const char* apcBtdevAddr,
void* apvUserData);
203 apsthBTRCore->avMediaHdl = NULL;
204 apsthBTRCore->leHdl = NULL;
205 apsthBTRCore->agentPath = NULL;
209 apsthBTRCore->curAdapterPath = NULL;
212 apsthBTRCore->curAdapterAddr = NULL;
213 apsthBTRCore->curAdapterAddr = (
char*)g_malloc0(
sizeof(
char) * (BD_NAME_LEN + 1));
214 memset(apsthBTRCore->curAdapterAddr,
'\0',
sizeof(
char) * (BD_NAME_LEN + 1));
217 for (i = 0; i < BTRCORE_MAX_NUM_BT_ADAPTERS; i++) {
218 apsthBTRCore->adapterPath[i] = NULL;
219 apsthBTRCore->adapterPath[i] = (
char*)g_malloc0(
sizeof(
char) * (BD_NAME_LEN + 1));
220 memset(apsthBTRCore->adapterPath[i],
'\0',
sizeof(
char) * (BD_NAME_LEN + 1));
222 apsthBTRCore->adapterAddr[i] = NULL;
223 apsthBTRCore->adapterAddr[i] = (
char*)g_malloc0(
sizeof(
char) * (BD_NAME_LEN + 1));
224 memset(apsthBTRCore->adapterAddr[i],
'\0',
sizeof(
char) * (BD_NAME_LEN + 1));
228 for (i = 0; i < BTRCORE_MAX_NUM_BT_DEVICES; i++) {
229 apsthBTRCore->stScannedDevicesArr[i].tDeviceId = 0;
230 apsthBTRCore->stScannedDevicesArr[i].enDeviceType = enBTRCore_DC_Unknown;
231 apsthBTRCore->stScannedDevicesArr[i].bFound = FALSE;
232 apsthBTRCore->stScannedDevicesArr[i].bDeviceConnected = FALSE;
233 apsthBTRCore->stScannedDevicesArr[i].i32RSSI = INT_MIN;
235 memset (apsthBTRCore->stScannedDevicesArr[i].pcDeviceName,
'\0',
sizeof(
char) * (BD_NAME_LEN + 1));
236 memset (apsthBTRCore->stScannedDevicesArr[i].pcDeviceAddress,
'\0',
sizeof(
char) * (BD_NAME_LEN + 1));
237 memset (apsthBTRCore->stScannedDevicesArr[i].pcDevicePath,
'\0',
sizeof(
char) * (BD_NAME_LEN + 1));
239 memset (apsthBTRCore->stScannedDevicesArr[i].stAdServiceData, 0, (BTRCORE_MAX_DEVICE_PROFILE *
sizeof(
stBTRCoreAdServiceData)));
241 apsthBTRCore->stScannedDevStInfoArr[i].eDevicePrevState = enBTRCoreDevStInitialized;
242 apsthBTRCore->stScannedDevStInfoArr[i].eDeviceCurrState = enBTRCoreDevStInitialized;
245 apsthBTRCore->numOfScannedDevices = 0;
246 apsthBTRCore->numOfPairedDevices = 0;
250 for (i = 0; i < BTRCORE_MAX_NUM_BT_DEVICES; i++) {
251 apsthBTRCore->stKnownDevicesArr[i].tDeviceId = 0;
252 apsthBTRCore->stKnownDevicesArr[i].enDeviceType = enBTRCore_DC_Unknown;
253 apsthBTRCore->stKnownDevicesArr[i].bFound = FALSE;
254 apsthBTRCore->stKnownDevicesArr[i].bDeviceConnected = FALSE;
255 apsthBTRCore->stKnownDevicesArr[i].i32RSSI = INT_MIN;
257 memset (apsthBTRCore->stKnownDevicesArr[i].pcDeviceName,
'\0',
sizeof(
char) * (BD_NAME_LEN + 1));
258 memset (apsthBTRCore->stKnownDevicesArr[i].pcDeviceAddress,
'\0',
sizeof(
char) * (BD_NAME_LEN + 1));
259 memset (apsthBTRCore->stKnownDevicesArr[i].pcDevicePath,
'\0',
sizeof(
char) * (BD_NAME_LEN + 1));
261 memset (apsthBTRCore->stKnownDevicesArr[i].stAdServiceData, 0, (BTRCORE_MAX_DEVICE_PROFILE *
sizeof(
stBTRCoreAdServiceData)));
263 apsthBTRCore->stKnownDevStInfoArr[i].eDevicePrevState = enBTRCoreDevStInitialized;
264 apsthBTRCore->stKnownDevStInfoArr[i].eDeviceCurrState = enBTRCoreDevStInitialized;
268 apsthBTRCore->stDevStatusCbInfo.eDevicePrevState = enBTRCoreDevStInitialized;
269 apsthBTRCore->stDevStatusCbInfo.eDeviceCurrState = enBTRCoreDevStInitialized;
274 apsthBTRCore->fpcBBTRCoreDeviceDisc = NULL;
275 apsthBTRCore->fpcBBTRCoreStatus = NULL;
276 apsthBTRCore->fpcBBTRCoreMediaStatus = NULL;
277 apsthBTRCore->fpcBBTRCoreConnIntim = NULL;
278 apsthBTRCore->fpcBBTRCoreConnAuth = NULL;
280 apsthBTRCore->pvcBDevDiscUserData = NULL;
281 apsthBTRCore->pvcBStatusUserData = NULL;
282 apsthBTRCore->pvcBMediaStatusUserData = NULL;
283 apsthBTRCore->pvcBConnIntimUserData = NULL;
284 apsthBTRCore->pvcBConnAuthUserData = NULL;
286 apsthBTRCore->pThreadRunTask = NULL;
287 apsthBTRCore->pGAQueueRunTask = NULL;
289 apsthBTRCore->pThreadOutTask = NULL;
290 apsthBTRCore->pGAQueueOutTask = NULL;
297 btrCore_GenerateUniqueDeviceID (
298 const char* apcDeviceMac
300 tBTRCoreDevId lBTRCoreDevId = 0;
301 char lcDevHdlArr[13] = {
'\0'};
305 if (apcDeviceMac && (strlen(apcDeviceMac) >= 17)) {
306 lcDevHdlArr[0] = apcDeviceMac[0];
307 lcDevHdlArr[1] = apcDeviceMac[1];
308 lcDevHdlArr[2] = apcDeviceMac[3];
309 lcDevHdlArr[3] = apcDeviceMac[4];
310 lcDevHdlArr[4] = apcDeviceMac[6];
311 lcDevHdlArr[5] = apcDeviceMac[7];
312 lcDevHdlArr[6] = apcDeviceMac[9];
313 lcDevHdlArr[7] = apcDeviceMac[10];
314 lcDevHdlArr[8] = apcDeviceMac[12];
315 lcDevHdlArr[9] = apcDeviceMac[13];
316 lcDevHdlArr[10] = apcDeviceMac[15];
317 lcDevHdlArr[11] = apcDeviceMac[16];
319 lBTRCoreDevId = (tBTRCoreDevId) strtoll(lcDevHdlArr, NULL, 16);
322 return lBTRCoreDevId;
325 static enBTRCoreDeviceClass
326 btrCore_MapClassIDtoAVDevClass (
327 unsigned int aui32ClassId
329 enBTRCoreDeviceClass rc = enBTRCore_DC_Unknown;
331 if (((aui32ClassId & 0x400u) == 0x400u) || ((aui32ClassId & 0x200u) == 0x200u) || ((aui32ClassId & 0x100u) == 0x100u)) {
332 unsigned int ui32DevClassID = aui32ClassId & 0xFFFu;
333 BTRCORELOG_TRACE (
"ui32DevClassID = 0x%x\n", ui32DevClassID);
335 if (ui32DevClassID == enBTRCore_DC_Tablet) {
336 BTRCORELOG_INFO (
"Its a enBTRCore_DC_Tablet\n");
337 rc = enBTRCore_DC_Tablet;
339 else if (ui32DevClassID == enBTRCore_DC_SmartPhone) {
340 BTRCORELOG_INFO (
"enBTRCore_DC_SmartPhone\n");
341 rc = enBTRCore_DC_SmartPhone;
343 else if (ui32DevClassID == enBTRCore_DC_WearableHeadset) {
344 BTRCORELOG_INFO (
"enBTRCore_DC_WearableHeadset\n");
345 rc = enBTRCore_DC_WearableHeadset;
347 else if (ui32DevClassID == enBTRCore_DC_Handsfree) {
348 BTRCORELOG_INFO (
"enBTRCore_DC_Handsfree\n");
349 rc = enBTRCore_DC_Handsfree;
351 else if (ui32DevClassID == enBTRCore_DC_Reserved) {
352 BTRCORELOG_INFO (
"enBTRCore_DC_Reserved\n");
353 rc = enBTRCore_DC_Reserved;
355 else if (ui32DevClassID == enBTRCore_DC_Microphone) {
356 BTRCORELOG_INFO (
"enBTRCore_DC_Microphone\n");
357 rc = enBTRCore_DC_Microphone;
359 else if (ui32DevClassID == enBTRCore_DC_Loudspeaker) {
360 BTRCORELOG_INFO (
"enBTRCore_DC_Loudspeaker\n");
361 rc = enBTRCore_DC_Loudspeaker;
363 else if (ui32DevClassID == enBTRCore_DC_Headphones) {
364 BTRCORELOG_INFO (
"enBTRCore_DC_Headphones\n");
365 rc = enBTRCore_DC_Headphones;
367 else if (ui32DevClassID == enBTRCore_DC_HID_AudioRemote) {
368 BTRCORELOG_INFO (
"enBTRCore_DC_HID_AudioRemote\n");
369 rc = enBTRCore_DC_HID_AudioRemote;
371 else if (ui32DevClassID == enBTRCore_DC_PortableAudio) {
372 BTRCORELOG_INFO (
"enBTRCore_DC_PortableAudio\n");
373 rc = enBTRCore_DC_PortableAudio;
375 else if (ui32DevClassID == enBTRCore_DC_CarAudio) {
376 BTRCORELOG_INFO (
"enBTRCore_DC_CarAudio\n");
377 rc = enBTRCore_DC_CarAudio;
379 else if (ui32DevClassID == enBTRCore_DC_STB) {
380 BTRCORELOG_INFO (
"enBTRCore_DC_STB\n");
381 rc = enBTRCore_DC_STB;
383 else if (ui32DevClassID == enBTRCore_DC_HIFIAudioDevice) {
384 BTRCORELOG_INFO (
"enBTRCore_DC_HIFIAudioDevice\n");
385 rc = enBTRCore_DC_HIFIAudioDevice;
387 else if (ui32DevClassID == enBTRCore_DC_VCR) {
388 BTRCORELOG_INFO (
"enBTRCore_DC_VCR\n");
389 rc = enBTRCore_DC_VCR;
391 else if (ui32DevClassID == enBTRCore_DC_VideoCamera) {
392 BTRCORELOG_INFO (
"enBTRCore_DC_VideoCamera\n");
393 rc = enBTRCore_DC_VideoCamera;
395 else if (ui32DevClassID == enBTRCore_DC_Camcoder) {
396 BTRCORELOG_INFO (
"enBTRCore_DC_Camcoder\n");
397 rc = enBTRCore_DC_Camcoder;
399 else if (ui32DevClassID == enBTRCore_DC_VideoMonitor) {
400 BTRCORELOG_INFO (
"enBTRCore_DC_VideoMonitor\n");
401 rc = enBTRCore_DC_VideoMonitor;
403 else if (ui32DevClassID == enBTRCore_DC_TV) {
404 BTRCORELOG_INFO (
"enBTRCore_DC_TV\n");
405 rc = enBTRCore_DC_TV;
407 else if (ui32DevClassID == enBTRCore_DC_VideoConference) {
408 BTRCORELOG_INFO (
"enBTRCore_DC_VideoConference\n");
409 rc = enBTRCore_DC_TV;
416 static enBTRCoreDeviceClass
417 btrCore_MapServiceClasstoDevType (
418 unsigned int aui32ClassId
420 enBTRCoreDeviceClass rc = enBTRCore_DC_Unknown;
429 if (0x40000u & aui32ClassId) {
430 BTRCORELOG_TRACE (
"Its a Rendering Class of Service.\n");
431 if ((rc = btrCore_MapClassIDtoAVDevClass(aui32ClassId)) == enBTRCore_DC_Unknown) {
432 BTRCORELOG_TRACE (
"Its a Rendering Class of Service. But no Audio Device Class defined\n");
435 else if (0x80000u & aui32ClassId) {
436 BTRCORELOG_TRACE (
"Its a Capturing Service.\n");
437 if ((rc = btrCore_MapClassIDtoAVDevClass(aui32ClassId)) == enBTRCore_DC_Unknown) {
438 BTRCORELOG_TRACE (
"Its a Capturing Service. But no Audio Device Class defined\n");
441 else if (0x200000u & aui32ClassId) {
442 BTRCORELOG_TRACE (
"Its a Audio Class of Service.\n");
443 if ((rc = btrCore_MapClassIDtoAVDevClass(aui32ClassId)) == enBTRCore_DC_Unknown) {
444 BTRCORELOG_TRACE (
"Its a Audio Class of Service. But no Audio Device Class defined; Lets assume its Loud Speaker\n");
445 rc = enBTRCore_DC_Loudspeaker;
448 else if (0x400000u & aui32ClassId) {
449 BTRCORELOG_TRACE (
"Its a Telephony Class of Service. So, enBTDevAudioSink\n");
450 if ((rc = btrCore_MapClassIDtoAVDevClass(aui32ClassId)) == enBTRCore_DC_Unknown) {
451 BTRCORELOG_TRACE (
"Its a Telephony Class of Service. But no Audio Device Class defined;\n");
458 static enBTRCoreDeviceClass
459 btrCore_MapClassIDtoDevClass (
460 unsigned int aui32ClassId
462 enBTRCoreDeviceClass rc = enBTRCore_DC_Unknown;
463 BTRCORELOG_TRACE (
"classID = 0x%x\n", aui32ClassId);
465 if (aui32ClassId == enBTRCore_DC_Tile) {
466 BTRCORELOG_INFO (
"enBTRCore_DC_Tile\n");
467 rc = enBTRCore_DC_Tile;
470 if (rc == enBTRCore_DC_Unknown)
471 rc = btrCore_MapServiceClasstoDevType(aui32ClassId);
474 if (rc == enBTRCore_DC_Unknown) {
475 if ((aui32ClassId & 0x500u) == 0x500u) {
476 unsigned int ui32DevClassID = aui32ClassId & 0xFFFu;
477 BTRCORELOG_TRACE (
"ui32DevClassID = 0x%x\n", ui32DevClassID);
479 if (ui32DevClassID == enBTRCore_DC_HID_Keyboard) {
480 BTRCORELOG_INFO (
"Its a enBTRCore_DC_HID_Keyboard\n");
481 rc = enBTRCore_DC_HID_Keyboard;
483 else if (ui32DevClassID == enBTRCore_DC_HID_Mouse) {
484 BTRCORELOG_INFO (
"Its a enBTRCore_DC_HID_Mouse\n");
485 rc = enBTRCore_DC_HID_Mouse;
487 else if (ui32DevClassID == enBTRCore_DC_HID_MouseKeyBoard) {
488 BTRCORELOG_INFO (
"Its a enBTRCore_DC_HID_MouseKeyBoard\n");
489 rc = enBTRCore_DC_HID_MouseKeyBoard;
491 else if (ui32DevClassID == enBTRCore_DC_HID_AudioRemote) {
492 BTRCORELOG_INFO (
"Its a enBTRCore_DC_HID_AudioRemote\n");
493 rc = enBTRCore_DC_HID_AudioRemote;
495 else if (ui32DevClassID == enBTRCore_DC_HID_Joystick) {
496 BTRCORELOG_INFO (
"Its a enBTRCore_DC_HID_Joystick\n");
497 rc = enBTRCore_DC_HID_Joystick;
499 else if (ui32DevClassID == enBTRCore_DC_HID_GamePad) {
500 BTRCORELOG_INFO (
"Its a enBTRCore_DC_HID_GamePad\n");
501 rc = enBTRCore_DC_HID_GamePad;
506 rc = btrCore_MapClassIDtoAVDevClass(aui32ClassId);
513 static enBTRCoreDeviceType
514 btrCore_MapClassIDToDevType (
515 unsigned int aui32ClassId,
518 enBTRCoreDeviceType lenBTRCoreDevType = enBTRCoreUnknown;
519 enBTRCoreDeviceClass lenBTRCoreDevCl = enBTRCore_DC_Unknown;
521 switch (aeBtDeviceType) {
522 case enBTDevAudioSink:
523 lenBTRCoreDevCl = btrCore_MapClassIDtoDevClass(aui32ClassId);
524 if (lenBTRCoreDevCl == enBTRCore_DC_WearableHeadset) {
525 lenBTRCoreDevType = enBTRCoreHeadSet;
527 else if (lenBTRCoreDevCl == enBTRCore_DC_Headphones) {
528 lenBTRCoreDevType = enBTRCoreHeadSet;
530 else if (lenBTRCoreDevCl == enBTRCore_DC_Loudspeaker) {
531 lenBTRCoreDevType = enBTRCoreSpeakers;
533 else if (lenBTRCoreDevCl == enBTRCore_DC_HIFIAudioDevice) {
534 lenBTRCoreDevType = enBTRCoreSpeakers;
537 lenBTRCoreDevType = enBTRCoreSpeakers;
540 case enBTDevAudioSource:
541 lenBTRCoreDevCl = btrCore_MapClassIDtoDevClass(aui32ClassId);
542 if (lenBTRCoreDevCl == enBTRCore_DC_SmartPhone) {
543 lenBTRCoreDevType = enBTRCoreMobileAudioIn;
545 else if (lenBTRCoreDevCl == enBTRCore_DC_Tablet) {
546 lenBTRCoreDevType = enBTRCorePCAudioIn;
549 lenBTRCoreDevType = enBTRCoreMobileAudioIn;
552 case enBTDevHFPHeadset:
553 lenBTRCoreDevType = enBTRCoreHeadSet;
555 case enBTDevHFPAudioGateway:
556 lenBTRCoreDevType = enBTRCoreHeadSet;
559 lenBTRCoreDevType = enBTRCoreLE;
562 lenBTRCoreDevType = enBTRCoreHID;
566 lenBTRCoreDevType = enBTRCoreUnknown;
570 return lenBTRCoreDevType;
574 static enBTRCoreDeviceType
575 btrCore_MapDevClassToDevType (
576 enBTRCoreDeviceClass aenBTRCoreDevCl
578 enBTRCoreDeviceType lenBTRCoreDevType = enBTRCoreUnknown;
580 if (aenBTRCoreDevCl == enBTRCore_DC_WearableHeadset) {
581 lenBTRCoreDevType = enBTRCoreHeadSet;
583 else if (aenBTRCoreDevCl == enBTRCore_DC_Headphones) {
584 lenBTRCoreDevType = enBTRCoreHeadSet;
586 else if (aenBTRCoreDevCl == enBTRCore_DC_Loudspeaker) {
587 lenBTRCoreDevType = enBTRCoreSpeakers;
589 else if (aenBTRCoreDevCl == enBTRCore_DC_HIFIAudioDevice) {
590 lenBTRCoreDevType = enBTRCoreSpeakers;
592 else if (aenBTRCoreDevCl == enBTRCore_DC_PortableAudio) {
593 lenBTRCoreDevType = enBTRCoreSpeakers;
595 else if (aenBTRCoreDevCl == enBTRCore_DC_CarAudio) {
596 lenBTRCoreDevType = enBTRCoreSpeakers;
598 else if (aenBTRCoreDevCl == enBTRCore_DC_SmartPhone) {
599 lenBTRCoreDevType = enBTRCoreMobileAudioIn;
601 else if (aenBTRCoreDevCl == enBTRCore_DC_Tablet) {
602 lenBTRCoreDevType = enBTRCorePCAudioIn;
604 else if (aenBTRCoreDevCl == enBTRCore_DC_HID_Keyboard) {
605 lenBTRCoreDevType = enBTRCoreHID;
607 else if (aenBTRCoreDevCl == enBTRCore_DC_HID_Mouse) {
608 lenBTRCoreDevType = enBTRCoreHID;
610 else if (aenBTRCoreDevCl == enBTRCore_DC_HID_MouseKeyBoard) {
611 lenBTRCoreDevType = enBTRCoreHID;
613 else if (aenBTRCoreDevCl == enBTRCore_DC_HID_AudioRemote) {
614 lenBTRCoreDevType = enBTRCoreHID;
616 else if (aenBTRCoreDevCl == enBTRCore_DC_HID_Joystick) {
617 lenBTRCoreDevType = enBTRCoreHID;
619 else if (aenBTRCoreDevCl == enBTRCore_DC_HID_GamePad) {
620 lenBTRCoreDevType = enBTRCoreHID;
622 else if (aenBTRCoreDevCl == enBTRCore_DC_Tile) {
623 lenBTRCoreDevType = enBTRCoreLE;
628 lenBTRCoreDevType = enBTRCoreUnknown;
631 return lenBTRCoreDevType;
634 static eBTRCoreMedElementType
635 btrCore_GetMediaElementType (
636 eBTRCoreAVMElementType aeMediaElementType
638 eBTRCoreMedElementType lenMedElementType;
640 switch (aeMediaElementType) {
641 case eBTRCoreAVMETypeAlbum:
642 lenMedElementType = enBTRCoreMedETypeAlbum;
644 case eBTRCoreAVMETypeArtist:
645 lenMedElementType = enBTRCoreMedETypeArtist;
647 case eBTRCoreAVMETypeGenre:
648 lenMedElementType = enBTRCoreMedETypeGenre;
650 case eBTRCoreAVMETypeCompilation:
651 lenMedElementType = enBTRCoreMedETypeCompilation;
653 case eBTRCoreAVMETypePlayList:
654 lenMedElementType = enBTRCoreMedETypePlayList;
656 case eBTRCoreAVMETypeTrackList:
657 lenMedElementType = enBTRCoreMedETypeTrackList;
659 case eBTRCoreAVMETypeTrack:
660 lenMedElementType = enBTRCoreMedETypeTrack;
663 lenMedElementType = enBTRCoreMedETypeTrackList;
666 return lenMedElementType;
670 btrCore_ClearScannedDevicesList (
675 for (i = 0; i < BTRCORE_MAX_NUM_BT_DEVICES; i++) {
676 apsthBTRCore->stScannedDevicesArr[i].tDeviceId = 0;
677 apsthBTRCore->stScannedDevicesArr[i].i32RSSI = INT_MIN;
678 apsthBTRCore->stScannedDevicesArr[i].bFound = FALSE;
679 apsthBTRCore->stScannedDevicesArr[i].bDeviceConnected = FALSE;
680 apsthBTRCore->stScannedDevicesArr[i].enDeviceType = enBTRCore_DC_Unknown;
682 memset (apsthBTRCore->stScannedDevicesArr[i].pcDeviceName,
'\0',
sizeof(apsthBTRCore->stScannedDevicesArr[i].pcDeviceName));
683 memset (apsthBTRCore->stScannedDevicesArr[i].pcDeviceAddress,
'\0',
sizeof(apsthBTRCore->stScannedDevicesArr[i].pcDeviceAddress));
684 memset (apsthBTRCore->stScannedDevicesArr[i].pcDevicePath,
'\0',
sizeof(apsthBTRCore->stScannedDevicesArr[i].pcDevicePath));
686 apsthBTRCore->stScannedDevStInfoArr[i].eDevicePrevState = enBTRCoreDevStInitialized;
687 apsthBTRCore->stScannedDevStInfoArr[i].eDeviceCurrState = enBTRCoreDevStInitialized;
690 apsthBTRCore->numOfScannedDevices = 0;
695 btrCore_AddDeviceToScannedDevicesArr (
707 lstFoundDevice.bFound = FALSE;
708 lstFoundDevice.i32RSSI = apstBTDeviceInfo->i32RSSI;
709 lstFoundDevice.ui32VendorId = apstBTDeviceInfo->ui16Vendor;
710 lstFoundDevice.tDeviceId = btrCore_GenerateUniqueDeviceID(apstBTDeviceInfo->pcAddress);
711 lstFoundDevice.enDeviceType = btrCore_MapClassIDtoDevClass(apstBTDeviceInfo->ui32Class);
712 lstFoundDevice.ui32DevClassBtSpec = apstBTDeviceInfo->ui32Class;
714 strncpy(lstFoundDevice.pcDeviceName, apstBTDeviceInfo->pcName, BD_NAME_LEN);
715 strncpy(lstFoundDevice.pcDeviceAddress, apstBTDeviceInfo->pcAddress, BD_NAME_LEN);
716 strncpy(lstFoundDevice.pcDevicePath, apstBTDeviceInfo->pcDevicePath, BD_NAME_LEN);
720 if (apstBTDeviceInfo->aUUIDs[i][0] ==
'\0')
723 lstFoundDevice.stDeviceProfile.profile[i].uuid_value = btrCore_BTParseUUIDValue(apstBTDeviceInfo->aUUIDs[i],
724 lstFoundDevice.stDeviceProfile.profile[i].profile_name);
726 lstFoundDevice.stDeviceProfile.numberOfService = i;
728 if (lstFoundDevice.enDeviceType == enBTRCore_DC_Unknown) {
729 for (i = 0; i < lstFoundDevice.stDeviceProfile.numberOfService; i++) {
730 if (lstFoundDevice.stDeviceProfile.profile[i].uuid_value == strtol(BTR_CORE_A2SNK, NULL, 16)) {
731 lstFoundDevice.enDeviceType = enBTRCore_DC_Loudspeaker;
733 else if (lstFoundDevice.stDeviceProfile.profile[i].uuid_value == strtol(BTR_CORE_A2SRC, NULL, 16)) {
734 lstFoundDevice.enDeviceType = enBTRCore_DC_SmartPhone;
736 else if ((lstFoundDevice.stDeviceProfile.profile[i].uuid_value == strtol(BTR_CORE_GATT_TILE_1, NULL, 16)) ||
737 (lstFoundDevice.stDeviceProfile.profile[i].uuid_value == strtol(BTR_CORE_GATT_TILE_2, NULL, 16)) ||
738 (lstFoundDevice.stDeviceProfile.profile[i].uuid_value == strtol(BTR_CORE_GATT_TILE_3, NULL, 16))) {
739 lstFoundDevice.enDeviceType = enBTRCore_DC_Tile;
741 else if (lstFoundDevice.stDeviceProfile.profile[i].uuid_value == strtol(BTR_CORE_HID_1, NULL, 16) ||
742 lstFoundDevice.stDeviceProfile.profile[i].uuid_value == strtol(BTR_CORE_HID_2, NULL, 16)) {
743 lstFoundDevice.enDeviceType = enBTRCore_DC_HID_Keyboard;
751 if (lstFoundDevice.enDeviceType == enBTRCore_DC_Unknown && !btrCore_IsDevNameSameAsAddress(&lstFoundDevice)) {
752 if (((apstBTDeviceInfo->ui16Appearance & 0xffc0) >> 6) == 0x0f) {
753 if ((apstBTDeviceInfo->ui16Appearance & 0x3f) == 0x03 || (apstBTDeviceInfo->ui16Appearance & 0x3f) == 0x04) {
754 lstFoundDevice.enDeviceType = enBTRCore_DC_HID_Joystick;
755 BTRCORELOG_INFO (
"Setting device type to Joystick based on GAP appearance\n");
761 for(count = 0; count < lstFoundDevice.stDeviceProfile.numberOfService; count++)
763 strncpy(lstFoundDevice.stAdServiceData[count].pcUUIDs, apstBTDeviceInfo->saServices[count].pcUUIDs, (
BT_MAX_UUID_STR_LEN - 1));
765 if(0 != apstBTDeviceInfo->saServices[count].len)
767 lstFoundDevice.stAdServiceData[count].len = apstBTDeviceInfo->saServices[count].len;
768 memcpy(lstFoundDevice.stAdServiceData[count].pcData, apstBTDeviceInfo->saServices[count].pcData, apstBTDeviceInfo->saServices[count].len);
770 BTRCORELOG_TRACE (
"ServiceData from %s\n", __FUNCTION__);
771 for (
int i =0; i < apstBTDeviceInfo->saServices[count].len; i++){
772 BTRCORELOG_TRACE (
"ServiceData[%d] = [%x]\n ", i, lstFoundDevice.stAdServiceData[count].pcData[i]);
777 if (apsthBTRCore->aenDeviceDiscoveryType == enBTRCoreHID) {
778 if ((lstFoundDevice.enDeviceType != enBTRCore_DC_HID_Keyboard) &&
779 (lstFoundDevice.enDeviceType != enBTRCore_DC_HID_Mouse) &&
780 (lstFoundDevice.enDeviceType != enBTRCore_DC_HID_AudioRemote) &&
781 (lstFoundDevice.enDeviceType != enBTRCore_DC_HID_Joystick) &&
782 (lstFoundDevice.enDeviceType != enBTRCore_DC_HID_GamePad) &&
783 (lstFoundDevice.enDeviceType != enBTRCore_DC_HID_MouseKeyBoard) ){
784 BTRCORELOG_ERROR(
"Skipped the device %s DevID = %lld as the it is not interested device\n", lstFoundDevice.pcDeviceAddress, lstFoundDevice.tDeviceId);
789 for (i = 0; i < BTRCORE_MAX_NUM_BT_DEVICES; i++) {
790 if ((lstFoundDevice.tDeviceId == apsthBTRCore->stScannedDevicesArr[i].tDeviceId) || (apsthBTRCore->stScannedDevicesArr[i].bFound == FALSE)) {
791 BTRCORELOG_DEBUG (
"Unique DevID = %lld\n", lstFoundDevice.tDeviceId);
792 BTRCORELOG_DEBUG (
"Adding %s at location %d\n", lstFoundDevice.pcDeviceAddress, i);
794 lstFoundDevice.bFound =
TRUE;
796 memcpy (&apsthBTRCore->stScannedDevicesArr[i], &lstFoundDevice,
sizeof(
stBTRCoreBTDevice));
798 apsthBTRCore->stScannedDevStInfoArr[i].eDevicePrevState = apsthBTRCore->stScannedDevStInfoArr[i].eDeviceCurrState;
799 apsthBTRCore->stScannedDevStInfoArr[i].eDeviceCurrState = enBTRCoreDevStFound;
801 apsthBTRCore->numOfScannedDevices++;
808 if ((i < BTRCORE_MAX_NUM_BT_DEVICES) || (lstFoundDevice.enDeviceType == enBTRCore_DC_Tile)) {
810 if (lstFoundDevice.enDeviceType == enBTRCore_DC_Tile) {
811 lstFoundDevice.bFound =
TRUE;
818 BTRCORELOG_DEBUG (
"Skipped %s DevID = %lld\n", lstFoundDevice.pcDeviceAddress, lstFoundDevice.tDeviceId);
823 btrCore_RemoveDeviceFromScannedDevicesArr (
825 tBTRCoreDevId aBTRCoreDevId,
828 enBTRCoreRet retResult = enBTRCoreSuccess;
831 for (i32LoopIdx = 0; i32LoopIdx < apstlhBTRCore->numOfScannedDevices; i32LoopIdx++) {
832 if (apstlhBTRCore->stScannedDevicesArr[i32LoopIdx].tDeviceId == aBTRCoreDevId) {
837 if (i32LoopIdx != apstlhBTRCore->numOfScannedDevices) {
838 BTRCORELOG_TRACE (
"i32ScannedDevIdx = %d\n", i32LoopIdx);
839 BTRCORELOG_TRACE (
"pstlhBTRCore->stScannedDevicesArr[i32LoopIdx].eDeviceCurrState = %d\n", apstlhBTRCore->stScannedDevStInfoArr[i32LoopIdx].eDeviceCurrState);
840 BTRCORELOG_TRACE (
"pstlhBTRCore->stScannedDevicesArr[i32LoopIdx].eDevicePrevState = %d\n", apstlhBTRCore->stScannedDevStInfoArr[i32LoopIdx].eDevicePrevState);
842 memcpy (astRemovedDevice, &apstlhBTRCore->stScannedDevicesArr[i32LoopIdx],
sizeof(
stBTRCoreBTDevice));
843 astRemovedDevice->bFound = FALSE;
846 if (i32LoopIdx != apstlhBTRCore->numOfScannedDevices - 1) {
847 memcpy (&apstlhBTRCore->stScannedDevicesArr[i32LoopIdx], &apstlhBTRCore->stScannedDevicesArr[apstlhBTRCore->numOfScannedDevices - 1],
sizeof(
stBTRCoreBTDevice));
848 memcpy (&apstlhBTRCore->stScannedDevStInfoArr[i32LoopIdx], &apstlhBTRCore->stScannedDevStInfoArr[apstlhBTRCore->numOfScannedDevices - 1],
sizeof(
stBTRCoreDevStateInfo));
851 memset(&apstlhBTRCore->stScannedDevicesArr[apstlhBTRCore->numOfScannedDevices - 1], 0,
sizeof(
stBTRCoreBTDevice));
852 memset(&apstlhBTRCore->stScannedDevStInfoArr[apstlhBTRCore->numOfScannedDevices - 1], 0,
sizeof(
stBTRCoreDevStateInfo));
854 apstlhBTRCore->numOfScannedDevices--;
857 BTRCORELOG_ERROR (
"Device %lld not found in Scanned List!\n", aBTRCoreDevId);
858 retResult = enBTRCoreDeviceNotFound;
865 btrCore_AddDeviceToKnownDevicesArr (
869 tBTRCoreDevId ltDeviceId;
871 int i32KnownDevIdx = -1;
872 int i32ScannedDevIdx= -1;
875 ltDeviceId = btrCore_GenerateUniqueDeviceID(apstBTDeviceInfo->pcAddress);
877 for (i32LoopIdx = 0; i32LoopIdx < apsthBTRCore->numOfPairedDevices; i32LoopIdx++) {
878 if (ltDeviceId == apsthBTRCore->stKnownDevicesArr[i32LoopIdx].tDeviceId) {
879 i32KnownDevIdx = i32LoopIdx;
884 if (i32KnownDevIdx != -1) {
885 BTRCORELOG_DEBUG (
"Already Present in stKnownDevicesArr - DevID = %lld\n", ltDeviceId);
886 return i32KnownDevIdx;
889 if (apsthBTRCore->numOfPairedDevices >= BTRCORE_MAX_NUM_BT_DEVICES) {
890 BTRCORELOG_ERROR (
"No Space in stKnownDevicesArr - DevID = %lld\n", ltDeviceId);
891 return i32KnownDevIdx;
894 for (i32LoopIdx = 0; i32LoopIdx < apsthBTRCore->numOfScannedDevices; i32LoopIdx++) {
895 if (ltDeviceId == apsthBTRCore->stScannedDevicesArr[i32LoopIdx].tDeviceId) {
896 i32ScannedDevIdx = i32LoopIdx;
901 if (i32ScannedDevIdx == -1) {
902 BTRCORELOG_DEBUG (
"Not Present in stScannedDevicesArr - DevID = %lld\n", ltDeviceId);
903 return i32ScannedDevIdx;
907 i32KnownDevIdx = apsthBTRCore->numOfPairedDevices++;
909 memcpy (&apsthBTRCore->stKnownDevicesArr[i32KnownDevIdx], &apsthBTRCore->stScannedDevicesArr[i32ScannedDevIdx],
sizeof(
stBTRCoreBTDevice));
910 apsthBTRCore->stKnownDevicesArr[i32KnownDevIdx].bDeviceConnected = apstBTDeviceInfo->bConnected;
912 BTRCORELOG_TRACE (
"Added in stKnownDevicesArr - DevID = %lld i32KnownDevIdx = %d NumOfPairedDevices = %d\n", ltDeviceId, i32KnownDevIdx, apsthBTRCore->numOfPairedDevices);
914 return i32KnownDevIdx;
919 btrCore_RemoveDeviceFromKnownDevicesArr (
921 tBTRCoreDevId aBTRCoreDevId
923 enBTRCoreRet retResult = enBTRCoreSuccess;
926 for (i32LoopIdx = 0; i32LoopIdx < apstlhBTRCore->numOfPairedDevices; i32LoopIdx++) {
927 if (apstlhBTRCore->stKnownDevicesArr[i32LoopIdx].tDeviceId == aBTRCoreDevId) {
932 if (i32LoopIdx != apstlhBTRCore->numOfPairedDevices) {
933 BTRCORELOG_TRACE (
"i32ScannedDevIdx = %d\n", i32LoopIdx);
934 BTRCORELOG_TRACE (
"pstlhBTRCore->stKnownDevicesArr[i32LoopIdx].eDeviceCurrState = %d\n", apstlhBTRCore->stKnownDevStInfoArr[i32LoopIdx].eDeviceCurrState);
935 BTRCORELOG_TRACE (
"pstlhBTRCore->stKnownDevicesArr[i32LoopIdx].eDevicePrevState = %d\n", apstlhBTRCore->stKnownDevStInfoArr[i32LoopIdx].eDevicePrevState);
938 if (i32LoopIdx != apstlhBTRCore->numOfScannedDevices - 1) {
939 memcpy (&apstlhBTRCore->stKnownDevicesArr[i32LoopIdx], &apstlhBTRCore->stKnownDevicesArr[apstlhBTRCore->numOfPairedDevices - 1],
sizeof(
stBTRCoreBTDevice));
940 memcpy (&apstlhBTRCore->stKnownDevStInfoArr[i32LoopIdx], &apstlhBTRCore->stKnownDevStInfoArr[apstlhBTRCore->numOfPairedDevices - 1],
sizeof(
stBTRCoreDevStateInfo));
943 memset(&apstlhBTRCore->stKnownDevicesArr[apstlhBTRCore->numOfPairedDevices - 1], 0,
sizeof(
stBTRCoreBTDevice));
944 memset(&apstlhBTRCore->stScannedDevStInfoArr[apstlhBTRCore->numOfPairedDevices - 1], 0,
sizeof(
stBTRCoreDevStateInfo));
946 apstlhBTRCore->numOfPairedDevices--;
949 BTRCORELOG_ERROR (
"Device %lld not found in Paired List!\n", aBTRCoreDevId);
950 retResult = enBTRCoreDeviceNotFound;
958 btrCore_MapKnownDeviceListFromPairedDeviceInfo (
962 unsigned char i_idx = 0;
963 unsigned char j_idx = 0;
965 for (i_idx = 0; i_idx < pairedDeviceInfo->numberOfDevices; i_idx++) {
966 knownDevicesArr[i_idx].ui32VendorId = pairedDeviceInfo->deviceInfo[i_idx].ui16Vendor;
967 knownDevicesArr[i_idx].bDeviceConnected = pairedDeviceInfo->deviceInfo[i_idx].bConnected;
968 knownDevicesArr[i_idx].tDeviceId = btrCore_GenerateUniqueDeviceID(pairedDeviceInfo->deviceInfo[i_idx].pcAddress);
969 knownDevicesArr[i_idx].enDeviceType = btrCore_MapClassIDtoDevClass(pairedDeviceInfo->deviceInfo[i_idx].ui32Class);
970 knownDevicesArr[i_idx].ui32DevClassBtSpec = pairedDeviceInfo->deviceInfo[i_idx].ui32Class;
972 strncpy(knownDevicesArr[i_idx].pcDeviceName, pairedDeviceInfo->deviceInfo[i_idx].pcName, BD_NAME_LEN);
973 strncpy(knownDevicesArr[i_idx].pcDeviceAddress, pairedDeviceInfo->deviceInfo[i_idx].pcAddress, BD_NAME_LEN);
974 strncpy(knownDevicesArr[i_idx].pcDevicePath, pairedDeviceInfo->devicePath[i_idx], BD_NAME_LEN);
976 BTRCORELOG_TRACE (
"Unique DevID = %lld\n", knownDevicesArr[i_idx].tDeviceId);
979 if (pairedDeviceInfo->deviceInfo[i_idx].aUUIDs[j_idx][0] ==
'\0')
982 knownDevicesArr[i_idx].stDeviceProfile.profile[j_idx].uuid_value = btrCore_BTParseUUIDValue (
983 pairedDeviceInfo->deviceInfo[i_idx].aUUIDs[j_idx],
984 knownDevicesArr[i_idx].stDeviceProfile.profile[j_idx].profile_name);
986 knownDevicesArr[i_idx].stDeviceProfile.numberOfService = j_idx;
988 if (knownDevicesArr[i_idx].enDeviceType == enBTRCore_DC_Unknown) {
989 for (j_idx = 0; j_idx < knownDevicesArr[i_idx].stDeviceProfile.numberOfService; j_idx++) {
990 if (knownDevicesArr[i_idx].stDeviceProfile.profile[j_idx].uuid_value == strtol(BTR_CORE_A2SNK, NULL, 16)) {
991 knownDevicesArr[i_idx].enDeviceType = enBTRCore_DC_Loudspeaker;
993 else if ((knownDevicesArr[i_idx].stDeviceProfile.profile[j_idx].uuid_value == strtol(BTR_CORE_HID_1, NULL, 16)) ||
994 (knownDevicesArr[i_idx].stDeviceProfile.profile[j_idx].uuid_value == strtol(BTR_CORE_HID_2, NULL, 16))) {
995 knownDevicesArr[i_idx].enDeviceType = enBTRCore_DC_HID_Keyboard;
1004 btrCore_PopulateListOfPairedDevices (
1006 const char* pAdapterPath
1008 unsigned char i_idx = 0;
1009 unsigned char j_idx = 0;
1010 enBTRCoreRet retResult = enBTRCoreSuccess;
1016 return enBTRCoreFailure;
1019 pstBTPairedDeviceInfo->numberOfDevices = 0;
1022 memset(&pstBTPairedDeviceInfo->deviceInfo[i_idx], 0,
sizeof(
stBTDeviceInfo));
1026 BTRCORELOG_ERROR (
"Failed to populate List Of Paired Devices\n");
1027 return enBTRCoreFailure;
1030 for (j_idx = 0; j_idx < BTRCORE_MAX_NUM_BT_DEVICES; j_idx++) {
1035 if (!apsthBTRCore->numOfPairedDevices) {
1036 apsthBTRCore->numOfPairedDevices = pstBTPairedDeviceInfo->numberOfDevices;
1037 btrCore_MapKnownDeviceListFromPairedDeviceInfo (knownDevicesArr, pstBTPairedDeviceInfo);
1039 for (i_idx = 0; i_idx < pstBTPairedDeviceInfo->numberOfDevices; i_idx++) {
1040 memcpy (&apsthBTRCore->stKnownDevicesArr[i_idx], &knownDevicesArr[i_idx],
sizeof(
stBTRCoreBTDevice));
1041 apsthBTRCore->stKnownDevStInfoArr[i_idx].eDevicePrevState = enBTRCoreDevStInitialized;
1042 apsthBTRCore->stKnownDevStInfoArr[i_idx].eDeviceCurrState = enBTRCoreDevStPaired;
1076 unsigned char count = 0;
1077 unsigned char k_idx = 0;
1078 unsigned char numOfDevices = 0;
1079 unsigned char knownDev_index_array[BTRCORE_MAX_NUM_BT_DEVICES];
1080 unsigned char pairedDev_index_array[BTRCORE_MAX_NUM_BT_DEVICES];
1082 memset (knownDev_index_array, 0,
sizeof(knownDev_index_array));
1083 memset (pairedDev_index_array, 0,
sizeof(pairedDev_index_array));
1085 for (j_idx = 0; j_idx < BTRCORE_MAX_NUM_BT_DEVICES; j_idx++) {
1086 memcpy (&knownDevicesArr[j_idx], &apsthBTRCore->stKnownDevicesArr[j_idx],
sizeof(
stBTRCoreBTDevice));
1091 for (i_idx = 0, j_idx = 0; i_idx < pstBTPairedDeviceInfo->numberOfDevices && j_idx < apsthBTRCore->numOfPairedDevices; j_idx++) {
1092 if (btrCore_GenerateUniqueDeviceID(pstBTPairedDeviceInfo->deviceInfo[i_idx].pcAddress) == knownDevicesArr[j_idx].tDeviceId) {
1093 knownDev_index_array[j_idx] = 1;
1094 pairedDev_index_array[i_idx]= 1;
1098 for (k_idx = i_idx + 1; k_idx < pstBTPairedDeviceInfo->numberOfDevices; k_idx++) {
1099 if (btrCore_GenerateUniqueDeviceID(pstBTPairedDeviceInfo->deviceInfo[k_idx].pcAddress) == knownDevicesArr[j_idx].tDeviceId) {
1100 knownDev_index_array[j_idx] = 1;
1101 pairedDev_index_array[k_idx]= 1;
1108 numOfDevices = apsthBTRCore->numOfPairedDevices;
1111 for (i_idx = 0; i_idx < numOfDevices; i_idx++) {
1112 if (knownDev_index_array[i_idx]) {
1113 memcpy (&apsthBTRCore->stKnownDevicesArr[i_idx - count], &knownDevicesArr[i_idx],
sizeof(
stBTRCoreBTDevice));
1114 apsthBTRCore->stKnownDevStInfoArr[i_idx - count].eDevicePrevState = apsthBTRCore->stKnownDevStInfoArr[i_idx].eDevicePrevState;
1115 apsthBTRCore->stKnownDevStInfoArr[i_idx - count].eDeviceCurrState = apsthBTRCore->stKnownDevStInfoArr[i_idx].eDeviceCurrState;
1119 apsthBTRCore->numOfPairedDevices--;
1122 btrCore_MapKnownDeviceListFromPairedDeviceInfo (knownDevicesArr, pstBTPairedDeviceInfo);
1125 for (i_idx = 0; i_idx < pstBTPairedDeviceInfo->numberOfDevices; i_idx++) {
1126 if (!pairedDev_index_array[i_idx]) {
1127 memcpy(&apsthBTRCore->stKnownDevicesArr[apsthBTRCore->numOfPairedDevices], &knownDevicesArr[i_idx],
sizeof(
stBTRCoreBTDevice));
1128 if (apsthBTRCore->stKnownDevStInfoArr[apsthBTRCore->numOfPairedDevices].eDeviceCurrState != enBTRCoreDevStConnected) {
1129 apsthBTRCore->stKnownDevStInfoArr[apsthBTRCore->numOfPairedDevices].eDevicePrevState = enBTRCoreDevStInitialized;
1130 apsthBTRCore->stKnownDevStInfoArr[apsthBTRCore->numOfPairedDevices].eDeviceCurrState = enBTRCoreDevStPaired;
1131 apsthBTRCore->stKnownDevicesArr[apsthBTRCore->numOfPairedDevices].bDeviceConnected = FALSE;
1132 apsthBTRCore->stKnownDevicesArr[apsthBTRCore->numOfPairedDevices].bFound =
TRUE;
1134 apsthBTRCore->numOfPairedDevices++;
1139 g_free(pstBTPairedDeviceInfo);
1146 btrCore_GetScannedDeviceAddress (
1148 tBTRCoreDevId aBTRCoreDevId
1152 if (apsthBTRCore->numOfScannedDevices) {
1153 for (i = 0; i < apsthBTRCore->numOfScannedDevices; i++) {
1154 if (aBTRCoreDevId == apsthBTRCore->stScannedDevicesArr[i].tDeviceId)
1155 return apsthBTRCore->stScannedDevicesArr[i].pcDevicePath;
1164 btrCore_GetKnownDeviceMac (
1166 tBTRCoreDevId aBTRCoreDevId
1168 int i32LoopIdx = -1;
1170 if (apsthBTRCore->numOfPairedDevices) {
1171 for (i32LoopIdx = 0; i32LoopIdx < apsthBTRCore->numOfPairedDevices; i32LoopIdx++) {
1172 if (aBTRCoreDevId == apsthBTRCore->stKnownDevicesArr[i32LoopIdx].tDeviceId)
1173 return apsthBTRCore->stKnownDevicesArr[i32LoopIdx].pcDeviceAddress;
1182 btrCore_GetDeviceInfo (
1184 tBTRCoreDevId aBTRCoreDevId,
1185 enBTRCoreDeviceType aenBTRCoreDevType,
1189 const char** appcBTRCoreBTDevicePath,
1190 const char** appcBTRCoreBTDeviceName
1194 unsigned int ui32NumOfDevices = 0;
1195 unsigned int ui32LoopIdx = 0;
1198 if (!apsthBTRCore->numOfPairedDevices) {
1199 BTRCORELOG_DEBUG (
"Possibly the list is not populated; like booted and connecting\n");
1200 btrCore_PopulateListOfPairedDevices(apsthBTRCore, apsthBTRCore->curAdapterPath);
1204 if (aenBTRCoreDevType != enBTRCoreLE) {
1205 ui32NumOfDevices = apsthBTRCore->numOfPairedDevices;
1206 lpstBTRCoreBTDeviceArr = apsthBTRCore->stKnownDevicesArr;
1207 lpstBTRCoreDevStInfoArr = apsthBTRCore->stKnownDevStInfoArr;
1210 ui32NumOfDevices = apsthBTRCore->numOfScannedDevices;
1211 lpstBTRCoreBTDeviceArr = apsthBTRCore->stScannedDevicesArr;
1212 lpstBTRCoreDevStInfoArr = apsthBTRCore->stScannedDevStInfoArr;
1216 if (!ui32NumOfDevices) {
1217 BTRCORELOG_ERROR (
"There is no device paried/scanned for this adapter\n");
1218 return enBTRCoreFailure;
1222 if (aBTRCoreDevId < BTRCORE_MAX_NUM_BT_DEVICES) {
1223 *appstBTRCoreBTDevice = &lpstBTRCoreBTDeviceArr[aBTRCoreDevId];
1224 *appstBTRCoreDevStateInfo = &lpstBTRCoreDevStInfoArr[aBTRCoreDevId];
1227 for (ui32LoopIdx = 0; ui32LoopIdx < ui32NumOfDevices; ui32LoopIdx++) {
1228 if (aBTRCoreDevId == lpstBTRCoreBTDeviceArr[ui32LoopIdx].tDeviceId) {
1229 *appstBTRCoreBTDevice = &lpstBTRCoreBTDeviceArr[ui32LoopIdx];
1230 *appstBTRCoreDevStateInfo = &lpstBTRCoreDevStInfoArr[ui32LoopIdx];
1236 if (*appstBTRCoreBTDevice) {
1237 *appcBTRCoreBTDevicePath = (*appstBTRCoreBTDevice)->pcDevicePath;
1238 *appcBTRCoreBTDeviceName = (*appstBTRCoreBTDevice)->pcDeviceName;
1241 if (!(*appcBTRCoreBTDevicePath) || !strlen(*appcBTRCoreBTDevicePath)) {
1242 BTRCORELOG_ERROR (
"Failed to find device in paired/scanned devices list\n");
1243 return enBTRCoreDeviceNotFound;
1247 switch (aenBTRCoreDevType) {
1248 case enBTRCoreSpeakers:
1249 case enBTRCoreHeadSet:
1250 *apenBTDeviceType = enBTDevAudioSink;
1252 case enBTRCoreMobileAudioIn:
1253 case enBTRCorePCAudioIn:
1254 *apenBTDeviceType = enBTDevAudioSource;
1257 *apenBTDeviceType = enBTDevLE;
1260 *apenBTDeviceType = enBTDevHID;
1262 case enBTRCoreUnknown:
1264 *apenBTDeviceType = enBTDevUnknown;
1268 return enBTRCoreSuccess;
1273 btrCore_GetDeviceInfoKnown (
1275 tBTRCoreDevId aBTRCoreDevId,
1276 enBTRCoreDeviceType aenBTRCoreDevType,
1280 const char** appcBTRCoreBTDevicePath
1282 unsigned int ui32NumOfDevices = 0;
1283 unsigned int ui32LoopIdx = 0;
1285 if (!apsthBTRCore->numOfPairedDevices) {
1286 BTRCORELOG_DEBUG (
"Possibly the list is not populated; like booted and connecting\n");
1287 btrCore_PopulateListOfPairedDevices(apsthBTRCore, apsthBTRCore->curAdapterPath);
1291 ui32NumOfDevices = apsthBTRCore->numOfPairedDevices;
1292 if (!ui32NumOfDevices) {
1293 BTRCORELOG_ERROR (
"There is no device paried for this adapter\n");
1294 return enBTRCoreFailure;
1298 if (aBTRCoreDevId < BTRCORE_MAX_NUM_BT_DEVICES) {
1299 *appstBTRCoreBTDevice = &apsthBTRCore->stKnownDevicesArr[aBTRCoreDevId];
1300 *appstBTRCoreDevStateInfo = &apsthBTRCore->stKnownDevStInfoArr[aBTRCoreDevId];
1303 for (ui32LoopIdx = 0; ui32LoopIdx < ui32NumOfDevices; ui32LoopIdx++) {
1304 if (aBTRCoreDevId == apsthBTRCore->stKnownDevicesArr[ui32LoopIdx].tDeviceId) {
1305 *appstBTRCoreBTDevice = &apsthBTRCore->stKnownDevicesArr[ui32LoopIdx];
1306 *appstBTRCoreDevStateInfo = &apsthBTRCore->stKnownDevStInfoArr[ui32LoopIdx];
1311 if (*appstBTRCoreBTDevice) {
1312 *appcBTRCoreBTDevicePath = (*appstBTRCoreBTDevice)->pcDevicePath;
1315 if (!(*appcBTRCoreBTDevicePath) || !strlen(*appcBTRCoreBTDevicePath)) {
1316 BTRCORELOG_ERROR (
"Failed to find device in paired devices list\n");
1317 return enBTRCoreDeviceNotFound;
1321 switch (aenBTRCoreDevType) {
1322 case enBTRCoreSpeakers:
1323 case enBTRCoreHeadSet:
1324 *apenBTDeviceType = enBTDevAudioSink;
1326 case enBTRCoreMobileAudioIn:
1327 case enBTRCorePCAudioIn:
1328 *apenBTDeviceType = enBTDevAudioSource;
1331 *apenBTDeviceType = enBTDevHID;
1333 case enBTRCoreUnknown:
1335 *apenBTDeviceType = enBTDevUnknown;
1339 return enBTRCoreSuccess;
1343 btrCore_ShowSignalStrength (
1348 pos_str = 100 + strength;
1350 BTRCORELOG_TRACE (
" Signal Strength: %d dbmv \n", strength);
1353 BTRCORELOG_TRACE (
"++++\n");
1356 if ((pos_str > 50) && (pos_str <= 70)) {
1357 BTRCORELOG_TRACE (
"+++\n");
1360 if ((pos_str > 37) && (pos_str <= 50)) {
1361 BTRCORELOG_TRACE (
"++\n");
1364 if (pos_str <= 37) {
1365 BTRCORELOG_TRACE (
"+\n");
1371 btrCore_BTParseUUIDValue (
1372 const char* pUUIDString,
1373 char* pServiceNameOut
1376 unsigned int uuid_value = 0;
1383 aUUID[2] = pUUIDString[4];
1384 aUUID[3] = pUUIDString[5];
1385 aUUID[4] = pUUIDString[6];
1386 aUUID[5] = pUUIDString[7];
1389 uuid_value = strtol(aUUID, NULL, 16);
1392 if (!strcasecmp(aUUID, BTR_CORE_SP))
1393 strcpy(pServiceNameOut, BTR_CORE_SP_TEXT);
1395 else if (!strcasecmp(aUUID, BTR_CORE_HEADSET))
1396 strcpy(pServiceNameOut, BTR_CORE_HEADSET_TEXT);
1398 else if (!strcasecmp(aUUID, BTR_CORE_A2SRC))
1399 strcpy(pServiceNameOut, BTR_CORE_A2SRC_TEXT);
1401 else if (!strcasecmp(aUUID, BTR_CORE_A2SNK))
1402 strcpy(pServiceNameOut, BTR_CORE_A2SNK_TEXT);
1404 else if (!strcasecmp(aUUID, BTR_CORE_AVRTG))
1405 strcpy(pServiceNameOut, BTR_CORE_AVRTG_TEXT);
1407 else if (!strcasecmp(aUUID, BTR_CORE_AAD))
1408 strcpy(pServiceNameOut, BTR_CORE_AAD_TEXT);
1410 else if (!strcasecmp(aUUID, BTR_CORE_AVRCT))
1411 strcpy(pServiceNameOut, BTR_CORE_AVRCT_TEXT);
1413 else if (!strcasecmp(aUUID, BTR_CORE_AVREMOTE))
1414 strcpy(pServiceNameOut, BTR_CORE_AVREMOTE_TEXT);
1416 else if (!strcasecmp(aUUID, BTR_CORE_HS_AG))
1417 strcpy(pServiceNameOut, BTR_CORE_HS_AG_TEXT);
1419 else if (!strcasecmp(aUUID, BTR_CORE_HANDSFREE))
1420 strcpy(pServiceNameOut, BTR_CORE_HANDSFREE_TEXT);
1422 else if (!strcasecmp(aUUID, BTR_CORE_HAG))
1423 strcpy(pServiceNameOut, BTR_CORE_HAG_TEXT);
1425 else if (!strcasecmp(aUUID, BTR_CORE_HEADSET2))
1426 strcpy(pServiceNameOut, BTR_CORE_HEADSET2_TEXT);
1428 else if (!strcasecmp(aUUID, BTR_CORE_GEN_AUDIO))
1429 strcpy(pServiceNameOut, BTR_CORE_GEN_AUDIO_TEXT);
1431 else if (!strcasecmp(aUUID, BTR_CORE_PNP))
1432 strcpy(pServiceNameOut, BTR_CORE_PNP_TEXT);
1434 else if (!strcasecmp(aUUID, BTR_CORE_GEN_ATRIB))
1435 strcpy(pServiceNameOut, BTR_CORE_GEN_ATRIB_TEXT);
1437 else if (!strcasecmp(aUUID, BTR_CORE_GATT_TILE_1))
1438 strcpy(pServiceNameOut, BTR_CORE_GATT_TILE_TEXT);
1440 else if (!strcasecmp(aUUID, BTR_CORE_GATT_TILE_2))
1441 strcpy(pServiceNameOut, BTR_CORE_GATT_TILE_TEXT);
1443 else if (!strcasecmp(aUUID, BTR_CORE_GATT_TILE_3))
1444 strcpy(pServiceNameOut, BTR_CORE_GATT_TILE_TEXT);
1446 else if (!strcasecmp(aUUID, BTR_CORE_GEN_ACCESS))
1447 strcpy(pServiceNameOut, BTR_CORE_GEN_ACCESS_TEXT);
1449 else if (!strcasecmp(aUUID, BTR_CORE_GEN_ATTRIBUTE))
1450 strcpy(pServiceNameOut, BTR_CORE_GEN_ATTRIBUTE_TEXT);
1452 else if (!strcasecmp(aUUID, BTR_CORE_DEVICE_INFO))
1453 strcpy(pServiceNameOut, BTR_CORE_DEVICE_INFO_TEXT);
1455 else if (!strcasecmp(aUUID, BTR_CORE_BATTERY_SERVICE))
1456 strcpy(pServiceNameOut, BTR_CORE_BATTERY_SERVICE_TEXT);
1458 else if (!strcasecmp(aUUID, BTR_CORE_HID_1))
1459 strcpy(pServiceNameOut, BTR_CORE_HID_TEXT);
1461 else if (!strcasecmp(aUUID, BTR_CORE_HID_2))
1462 strcpy(pServiceNameOut, BTR_CORE_HID_TEXT);
1465 strcpy (pServiceNameOut,
"Not Identified");
1468 strcpy (pServiceNameOut,
"Not Identified");
1474 static enBTRCoreDeviceState
1475 btrCore_BTParseDeviceState (
1476 const char* pcStateValue
1478 enBTRCoreDeviceState rc = enBTRCoreDevStInitialized;
1480 if ((pcStateValue) && (pcStateValue[0] !=
'\0')) {
1481 BTRCORELOG_DEBUG (
"Current State of this connection is @@%s@@\n", pcStateValue);
1483 if (!strcasecmp(
"unpaired", pcStateValue)) {
1484 rc = enBTRCoreDevStUnpaired;
1486 else if (!strcasecmp(
"paired", pcStateValue)) {
1487 rc = enBTRCoreDevStPaired;
1489 else if (!strcasecmp(
"disconnected", pcStateValue)) {
1490 rc = enBTRCoreDevStDisconnected;
1492 else if (!strcasecmp(
"connecting", pcStateValue)) {
1493 rc = enBTRCoreDevStConnecting;
1495 else if (!strcasecmp(
"connected", pcStateValue)) {
1496 rc = enBTRCoreDevStConnected;
1498 else if (!strcasecmp(
"playing", pcStateValue)) {
1499 rc = enBTRCoreDevStPlaying;
1508 btrCore_RunTaskAddOp (
1509 GAsyncQueue* apRunTaskGAq,
1510 enBTRCoreTaskOp aenRunTaskOp,
1511 enBTRCoreTaskProcessType aenRunTaskPT,
1512 void* apvRunTaskInData
1516 if ((apRunTaskGAq == NULL) || (aenRunTaskOp == enBTRCoreTaskOpUnknown)) {
1517 return enBTRCoreInvalidArg;
1522 return enBTRCoreFailure;
1526 lpstRunTaskGAqData->enBTRCoreTskOp = aenRunTaskOp;
1527 switch (lpstRunTaskGAqData->enBTRCoreTskOp) {
1528 case enBTRCoreTaskOpStart:
1530 case enBTRCoreTaskOpStop:
1532 case enBTRCoreTaskOpIdle:
1534 case enBTRCoreTaskOpProcess:
1536 case enBTRCoreTaskOpExit:
1538 case enBTRCoreTaskOpUnknown:
1544 lpstRunTaskGAqData->enBTRCoreTskPT = aenRunTaskPT;
1545 if (lpstRunTaskGAqData->enBTRCoreTskPT == enBTRCoreTaskPTUnknown) {
1551 BTRCORELOG_INFO (
"g_async_queue_push %d %d %p\n", lpstRunTaskGAqData->enBTRCoreTskOp, lpstRunTaskGAqData->enBTRCoreTskPT, lpstRunTaskGAqData->pvBTRCoreTskInData);
1552 g_async_queue_push(apRunTaskGAq, lpstRunTaskGAqData);
1555 return enBTRCoreSuccess;
1559 btrCore_OutTaskAddOp (
1560 GAsyncQueue* apOutTaskGAq,
1561 enBTRCoreTaskOp aenOutTaskOp,
1562 enBTRCoreTaskProcessType aenOutTaskPT,
1563 void* apvOutTaskInData
1567 if ((apOutTaskGAq == NULL) || (aenOutTaskOp == enBTRCoreTaskOpUnknown)) {
1568 return enBTRCoreInvalidArg;
1573 return enBTRCoreFailure;
1577 lpstOutTaskGAqData->enBTRCoreTskOp = aenOutTaskOp;
1578 switch (lpstOutTaskGAqData->enBTRCoreTskOp) {
1579 case enBTRCoreTaskOpStart:
1581 case enBTRCoreTaskOpStop:
1583 case enBTRCoreTaskOpIdle:
1585 case enBTRCoreTaskOpProcess:
1587 case enBTRCoreTaskOpExit:
1589 case enBTRCoreTaskOpUnknown:
1595 lpstOutTaskGAqData->enBTRCoreTskPT = aenOutTaskPT;
1596 if (lpstOutTaskGAqData->enBTRCoreTskPT == enBTRCoreTaskPTcBAdapterStatus) {
1597 if ((lpstOutTaskGAqData->pvBTRCoreTskInData = g_malloc0(
sizeof(
stBTAdapterInfo)))) {
1601 else if (lpstOutTaskGAqData->enBTRCoreTskPT == enBTRCoreTaskPTcBDeviceDisc) {
1602 if ((apvOutTaskInData) &&
1610 else if (lpstOutTaskGAqData->enBTRCoreTskPT == enBTRCoreTaskPTcBDeviceRemoved) {
1611 if ((apvOutTaskInData) &&
1619 else if (lpstOutTaskGAqData->enBTRCoreTskPT == enBTRCoreTaskPTcBDeviceLost) {
1620 if ((apvOutTaskInData) &&
1628 else if (lpstOutTaskGAqData->enBTRCoreTskPT == enBTRCoreTaskPTcBDeviceStatus) {
1629 if ((apvOutTaskInData) &&
1637 else if (lpstOutTaskGAqData->enBTRCoreTskPT == enBTRCoreTaskPTcBMediaStatus) {
1642 else if (lpstOutTaskGAqData->enBTRCoreTskPT == enBTRCoreTaskPTcBDevOpInfoStatus) {
1643 if ((apvOutTaskInData) &&
1648 else if (lpstOutTaskGAqData->enBTRCoreTskPT == enBTRCoreTaskPTcBConnIntim) {
1650 else if (lpstOutTaskGAqData->enBTRCoreTskPT == enBTRCoreTaskPTcBConnAuth) {
1652 else if (lpstOutTaskGAqData->enBTRCoreTskPT == enBTRCoreTaskPTUnknown) {
1658 BTRCORELOG_INFO (
"g_async_queue_push %d %d %p\n", lpstOutTaskGAqData->enBTRCoreTskOp, lpstOutTaskGAqData->enBTRCoreTskPT, lpstOutTaskGAqData->pvBTRCoreTskInData);
1659 g_async_queue_push(apOutTaskGAq, lpstOutTaskGAqData);
1662 return enBTRCoreSuccess;
1669 gpointer apsthBTRCore
1672 enBTRCoreRet* penExitStatusRunTask= NULL;
1673 enBTRCoreRet lenBTRCoreRet = enBTRCoreSuccess;
1675 gint64 li64usTimeout = 0;
1676 guint16 lui16msTimeout = 20;
1677 BOOLEAN lbRunTaskExit = FALSE;
1678 enBTRCoreTaskOp lenRunTskOpPrv = enBTRCoreTaskOpUnknown;
1679 enBTRCoreTaskOp lenRunTskOpCur = enBTRCoreTaskOpUnknown;
1680 enBTRCoreTaskProcessType lenRunTskPTCur = enBTRCoreTaskPTUnknown;
1681 void* lpvRunTskInData = NULL;
1687 if (!(penExitStatusRunTask = g_malloc0(
sizeof(enBTRCoreRet)))) {
1688 BTRCORELOG_ERROR (
"RunTask failure - No Memory\n");
1692 if (!pstlhBTRCore || !pstlhBTRCore->connHdl) {
1693 BTRCORELOG_ERROR (
"RunTask failure - BTRCore not initialized\n");
1694 *penExitStatusRunTask = enBTRCoreNotInitialized;
1695 return (gpointer)penExitStatusRunTask;
1699 BTRCORELOG_DEBUG (
"%s \n",
"RunTask Started");
1705 li64usTimeout = lui16msTimeout * G_TIME_SPAN_MILLISECOND;
1706 if ((lpstRunTaskGAqData = g_async_queue_timeout_pop(pstlhBTRCore->pGAQueueRunTask, li64usTimeout))) {
1707 lenRunTskOpCur = lpstRunTaskGAqData->enBTRCoreTskOp;
1708 lenRunTskPTCur = lpstRunTaskGAqData->enBTRCoreTskPT;
1709 lpvRunTskInData= lpstRunTaskGAqData->pvBTRCoreTskInData;
1710 g_free(lpstRunTaskGAqData);
1711 lpstRunTaskGAqData = NULL;
1712 BTRCORELOG_INFO (
"g_async_queue_timeout_pop %d %d %p\n", lenRunTskOpCur, lenRunTskPTCur, lpvRunTskInData);
1718 if (lenRunTskOpPrv != lenRunTskOpCur) {
1719 lenRunTskOpPrv = lenRunTskOpCur;
1721 switch (lenRunTskOpCur) {
1722 case enBTRCoreTaskOpStart: {
1723 BTRCORELOG_INFO (
"enBTRCoreTaskOpStart\n");
1724 if ((lenBTRCoreRet = btrCore_RunTaskAddOp(pstlhBTRCore->pGAQueueRunTask, enBTRCoreTaskOpProcess, enBTRCoreTaskPTUnknown, NULL)) != enBTRCoreSuccess) {
1725 BTRCORELOG_ERROR(
"Failure btrCore_RunTaskAddOp enBTRCoreTaskOpProcess enBTRCoreTaskPTUnknown = %d\n", lenBTRCoreRet);
1730 case enBTRCoreTaskOpStop: {
1731 BTRCORELOG_INFO (
"enBTRCoreTaskOpStop\n");
1735 case enBTRCoreTaskOpIdle: {
1736 BTRCORELOG_INFO (
"enBTRCoreTaskOpIdle\n");
1740 case enBTRCoreTaskOpProcess: {
1741 BTRCORELOG_INFO (
"enBTRCoreTaskOpProcess\n");
1745 case enBTRCoreTaskOpExit: {
1746 BTRCORELOG_INFO (
"enBTRCoreTaskOpExit\n");
1750 case enBTRCoreTaskOpUnknown: {
1751 BTRCORELOG_INFO (
"enBTRCoreTaskOpUnknown\n");
1756 BTRCORELOG_INFO (
"default\n");
1765 switch (lenRunTskOpCur) {
1766 case enBTRCoreTaskOpStart: {
1770 case enBTRCoreTaskOpStop: {
1775 case enBTRCoreTaskOpIdle: {
1780 case enBTRCoreTaskOpProcess: {
1782 *penExitStatusRunTask = enBTRCoreFailure;
1783 lbRunTaskExit =
TRUE;
1788 case enBTRCoreTaskOpExit: {
1789 *penExitStatusRunTask = enBTRCoreSuccess;
1790 lbRunTaskExit =
TRUE;
1794 case enBTRCoreTaskOpUnknown: {
1806 }
while (lbRunTaskExit == FALSE);
1808 BTRCORELOG_DEBUG (
"RunTask Exiting\n");
1811 return (gpointer)penExitStatusRunTask;
1817 gpointer apsthBTRCore
1820 enBTRCoreRet* penExitStatusOutTask= NULL;
1821 enBTRCoreRet lenBTRCoreRet = enBTRCoreSuccess;
1823 gint64 li64usTimeout = 0;
1824 guint16 lui16msTimeout = 50;
1825 BOOLEAN lbOutTaskExit = FALSE;
1826 enBTRCoreTaskOp lenOutTskOpPrv = enBTRCoreTaskOpUnknown;
1827 enBTRCoreTaskOp lenOutTskOpCur = enBTRCoreTaskOpUnknown;
1828 enBTRCoreTaskProcessType lenOutTskPTCur = enBTRCoreTaskPTUnknown;
1836 if (!(penExitStatusOutTask = g_malloc0(
sizeof(enBTRCoreRet)))) {
1837 BTRCORELOG_ERROR (
"OutTask failure - No Memory\n");
1841 if (!pstlhBTRCore || !pstlhBTRCore->connHdl) {
1842 BTRCORELOG_ERROR (
"OutTask failure - BTRCore not initialized\n");
1843 *penExitStatusOutTask = enBTRCoreNotInitialized;
1844 return (gpointer)penExitStatusOutTask;
1848 BTRCORELOG_DEBUG (
"OutTask Started\n");
1854 li64usTimeout = lui16msTimeout * G_TIME_SPAN_MILLISECOND;
1855 if ((lpstOutTaskGAqData = (
stBTRCoreTaskGAqData*)(g_async_queue_timeout_pop(pstlhBTRCore->pGAQueueOutTask, li64usTimeout)))) {
1856 lenOutTskOpCur = lpstOutTaskGAqData->enBTRCoreTskOp;
1857 lenOutTskPTCur = lpstOutTaskGAqData->enBTRCoreTskPT;
1858 lpstOutTskInData= lpstOutTaskGAqData->pvBTRCoreTskInData;
1859 g_free(lpstOutTaskGAqData);
1860 lpstOutTaskGAqData = NULL;
1861 BTRCORELOG_INFO (
"g_async_queue_timeout_pop %d %d %p\n", lenOutTskOpCur, lenOutTskPTCur, lpstOutTskInData);
1867 if (lenOutTskOpPrv != lenOutTskOpCur) {
1868 lenOutTskOpPrv = lenOutTskOpCur;
1870 switch (lenOutTskOpCur) {
1871 case enBTRCoreTaskOpStart: {
1872 BTRCORELOG_INFO (
"enBTRCoreTaskOpStart\n");
1873 if ((lenBTRCoreRet = btrCore_OutTaskAddOp(pstlhBTRCore->pGAQueueOutTask, enBTRCoreTaskOpIdle, enBTRCoreTaskPTUnknown, NULL)) != enBTRCoreSuccess) {
1874 BTRCORELOG_ERROR(
"Failure btrCore_OutTaskAddOp enBTRCoreTaskOpProcess enBTRCoreTaskPTUnknown = %d\n", lenBTRCoreRet);
1879 case enBTRCoreTaskOpStop: {
1880 BTRCORELOG_INFO (
"enBTRCoreTaskOpStop\n");
1884 case enBTRCoreTaskOpIdle: {
1885 BTRCORELOG_INFO (
"enBTRCoreTaskOpIdle\n");
1889 case enBTRCoreTaskOpProcess: {
1890 BTRCORELOG_INFO (
"enBTRCoreTaskOpProcess\n");
1891 if ((lenBTRCoreRet = btrCore_OutTaskAddOp(pstlhBTRCore->pGAQueueOutTask, enBTRCoreTaskOpIdle, enBTRCoreTaskPTUnknown, NULL)) != enBTRCoreSuccess) {
1892 BTRCORELOG_ERROR(
"Failure btrCore_OutTaskAddOp enBTRCoreTaskOpProcess enBTRCoreTaskPTUnknown = %d\n", lenBTRCoreRet);
1897 case enBTRCoreTaskOpExit: {
1898 BTRCORELOG_INFO (
"enBTRCoreTaskOpExit\n");
1902 case enBTRCoreTaskOpUnknown: {
1903 BTRCORELOG_INFO (
"enBTRCoreTaskOpUnknown\n");
1908 BTRCORELOG_INFO (
"default\n");
1918 switch (lenOutTskOpCur) {
1919 case enBTRCoreTaskOpStart: {
1923 case enBTRCoreTaskOpStop: {
1928 case enBTRCoreTaskOpIdle: {
1933 case enBTRCoreTaskOpProcess: {
1935 if (lenOutTskPTCur == enBTRCoreTaskPTcBDeviceDisc) {
1937 if (lpstOutTskInData && lpstOutTskInData->pstBTDevInfo) {
1940 int i32ScannedDevIdx = -1;
1942 if ((i32ScannedDevIdx = btrCore_AddDeviceToScannedDevicesArr(pstlhBTRCore, lpstBTDeviceInfo, &lstFoundDevice)) != -1) {
1943 BTRCORELOG_DEBUG (
"btrCore_AddDeviceToScannedDevicesArr - Success Index = %d\n", i32ScannedDevIdx);
1945 pstlhBTRCore->stDiscoveryCbInfo.type = enBTRCoreOpTypeDevice;
1946 memcpy(&pstlhBTRCore->stDiscoveryCbInfo.device, &lstFoundDevice,
sizeof(
stBTRCoreBTDevice));
1948 if (pstlhBTRCore->fpcBBTRCoreDeviceDisc) {
1949 if ((lenBTRCoreRet = pstlhBTRCore->fpcBBTRCoreDeviceDisc(&pstlhBTRCore->stDiscoveryCbInfo,
1950 pstlhBTRCore->pvcBDevDiscUserData)) != enBTRCoreSuccess) {
1951 BTRCORELOG_ERROR (
"Failure fpcBBTRCoreDeviceDisc Ret = %d\n", lenBTRCoreRet);
1956 g_free(lpstOutTskInData->pstBTDevInfo);
1957 lpstOutTskInData->pstBTDevInfo = NULL;
1960 if (lpstOutTskInData) {
1961 g_free(lpstOutTskInData);
1962 lpstOutTskInData = NULL;
1965 else if (lenOutTskPTCur == enBTRCoreTaskPTcBDeviceRemoved) {
1967 if (lpstOutTskInData && lpstOutTskInData->pstBTDevInfo) {
1970 tBTRCoreDevId lBTRCoreDevId = lpstOutTskInData->bTRCoreDevId;
1972 (
void)lpstBTDeviceInfo;
1975 lenBTRCoreRet = btrCore_RemoveDeviceFromScannedDevicesArr (pstlhBTRCore, lBTRCoreDevId, &lstRemovedDevice);
1977 if (lenBTRCoreRet == enBTRCoreSuccess && lstRemovedDevice.tDeviceId) {
1979 pstlhBTRCore->stDiscoveryCbInfo.type = enBTRCoreOpTypeDevice;
1980 memcpy(&pstlhBTRCore->stDiscoveryCbInfo.device, &lstRemovedDevice,
sizeof(
stBTRCoreBTDevice));
1982 if (pstlhBTRCore->fpcBBTRCoreDeviceDisc) {
1983 if ((lenBTRCoreRet = pstlhBTRCore->fpcBBTRCoreDeviceDisc(&pstlhBTRCore->stDiscoveryCbInfo,
1984 pstlhBTRCore->pvcBDevDiscUserData)) != enBTRCoreSuccess) {
1985 BTRCORELOG_ERROR (
"Failure fpcBBTRCoreDeviceDisc Ret = %d\n", lenBTRCoreRet);
1990 BTRCORELOG_ERROR (
"Failed to remove dev %lld from Scanned List | Ret = %d\n", lBTRCoreDevId, lenBTRCoreRet);
1994 if (!pstlhBTRCore->numOfScannedDevices) {
1995 BTRCORELOG_INFO (
"\nClearing Scanned Device List...\n");
1996 btrCore_ClearScannedDevicesList(pstlhBTRCore);
1998 pstlhBTRCore->stDevStatusCbInfo.deviceId = 0;
1999 pstlhBTRCore->stDevStatusCbInfo.eDevicePrevState = enBTRCoreDevStFound;
2000 pstlhBTRCore->stDevStatusCbInfo.eDeviceCurrState = enBTRCoreDevStLost;
2001 pstlhBTRCore->stDevStatusCbInfo.isPaired = 0;
2003 if (pstlhBTRCore->fpcBBTRCoreStatus) {
2010 g_free(lpstOutTskInData->pstBTDevInfo);
2011 lpstOutTskInData->pstBTDevInfo = NULL;
2014 if (lpstOutTskInData) {
2015 g_free(lpstOutTskInData);
2016 lpstOutTskInData = NULL;
2019 else if (lenOutTskPTCur == enBTRCoreTaskPTcBDeviceLost) {
2021 if (lpstOutTskInData && lpstOutTskInData->pstBTDevInfo) {
2023 tBTRCoreDevId lBTRCoreDevId = lpstOutTskInData->bTRCoreDevId;
2024 int i32LoopIdx = -1;
2025 int i32KnownDevIdx = -1;
2028 (
void)lpstBTDeviceInfo;
2030 for (i32LoopIdx = 0; i32LoopIdx < pstlhBTRCore->numOfPairedDevices; i32LoopIdx++) {
2031 if (lBTRCoreDevId == pstlhBTRCore->stKnownDevicesArr[i32LoopIdx].tDeviceId) {
2032 i32KnownDevIdx = i32LoopIdx;
2038 if (pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].tDeviceId == lBTRCoreDevId) {
2039 BTRCORELOG_INFO (
"Device %llu power state Off or OOR\n", pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].tDeviceId);
2040 BTRCORELOG_TRACE (
"i32LoopIdx = %d\n", i32KnownDevIdx);
2041 BTRCORELOG_TRACE (
"pstlhBTRCore->stKnownDevStInfoArr[i32LoopIdx].eDeviceCurrState = %d\n", pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState);
2042 BTRCORELOG_TRACE (
"pstlhBTRCore->stKnownDevStInfoArr[i32LoopIdx].eDevicePrevState = %d\n", pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState);
2044 if (((pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState == enBTRCoreDevStConnected) ||
2045 (pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState == enBTRCoreDevStPlaying)) &&
2046 (pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState == enBTRCoreDevStDisconnecting)) {
2048 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState = pstlhBTRCore->stKnownDevStInfoArr[i32LoopIdx].eDeviceCurrState;
2049 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState = enBTRCoreDevStDisconnected;
2050 pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].bDeviceConnected = FALSE;
2053 else if (pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState == enBTRCoreDevStPlaying ||
2054 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState == enBTRCoreDevStConnected ) {
2056 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState = pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState;
2057 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState = enBTRCoreDevStLost;
2058 pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].bDeviceConnected = FALSE;
2064 pstlhBTRCore->stDevStatusCbInfo.deviceId = pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].tDeviceId;
2065 pstlhBTRCore->stDevStatusCbInfo.eDeviceClass = pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].enDeviceType;
2066 pstlhBTRCore->stDevStatusCbInfo.ui32DevClassBtSpec = pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].ui32DevClassBtSpec;
2067 pstlhBTRCore->stDevStatusCbInfo.eDevicePrevState = pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState;
2068 pstlhBTRCore->stDevStatusCbInfo.eDeviceCurrState = pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState;
2069 pstlhBTRCore->stDevStatusCbInfo.eDeviceType = btrCore_MapDevClassToDevType(pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].enDeviceType);
2070 pstlhBTRCore->stDevStatusCbInfo.isPaired = 1;
2071 strncpy(pstlhBTRCore->stDevStatusCbInfo.deviceName, pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].pcDeviceName, BD_NAME_LEN);
2072 strncpy(pstlhBTRCore->stDevStatusCbInfo.deviceAddress, pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].pcDeviceAddress, BD_NAME_LEN);
2074 if (pstlhBTRCore->fpcBBTRCoreStatus) {
2075 if ((lenBTRCoreRet = pstlhBTRCore->fpcBBTRCoreStatus(&pstlhBTRCore->stDevStatusCbInfo, pstlhBTRCore->pvcBStatusUserData)) != enBTRCoreSuccess) {
2076 BTRCORELOG_ERROR (
"Failure fpcBBTRCoreStatus Ret = %d\n", lenBTRCoreRet);
2082 g_free(lpstOutTskInData->pstBTDevInfo);
2083 lpstOutTskInData->pstBTDevInfo = NULL;
2086 if (lpstOutTskInData) {
2087 g_free(lpstOutTskInData);
2088 lpstOutTskInData = NULL;
2091 else if (lenOutTskPTCur == enBTRCoreTaskPTcBDeviceStatus) {
2093 if (lpstOutTskInData && lpstOutTskInData->pstBTDevInfo) {
2096 int i32LoopIdx = -1;
2097 int i32KnownDevIdx = -1;
2098 int i32ScannedDevIdx = -1;
2100 tBTRCoreDevId lBTRCoreDevId = lpstOutTskInData->bTRCoreDevId;
2101 enBTRCoreDeviceType lenBTRCoreDevType = lpstOutTskInData->enBTRCoreDevType;
2102 enBTRCoreDeviceState leBTDevState = btrCore_BTParseDeviceState(lpstBTDeviceInfo->pcDeviceCurrState);
2105 if (pstlhBTRCore->numOfPairedDevices) {
2106 for (i32LoopIdx = 0; i32LoopIdx < pstlhBTRCore->numOfPairedDevices; i32LoopIdx++) {
2107 if (lBTRCoreDevId == pstlhBTRCore->stKnownDevicesArr[i32LoopIdx].tDeviceId) {
2108 i32KnownDevIdx = i32LoopIdx;
2114 if (pstlhBTRCore->numOfScannedDevices) {
2115 for (i32LoopIdx = 0; i32LoopIdx < pstlhBTRCore->numOfScannedDevices; i32LoopIdx++) {
2116 if (lBTRCoreDevId == pstlhBTRCore->stScannedDevicesArr[i32LoopIdx].tDeviceId) {
2117 i32ScannedDevIdx = i32LoopIdx;
2126 if (((i32ScannedDevIdx != -1) || (i32KnownDevIdx != -1)) && (leBTDevState != enBTRCoreDevStInitialized)) {
2127 BOOLEAN bTriggerDevStatusChangeCb = FALSE;
2131 if ((i32KnownDevIdx != -1) && (leBTDevState != enBTRCoreDevStPaired)) {
2133 BTRCORELOG_TRACE (
"i32KnownDevIdx = %d\n", i32KnownDevIdx);
2134 BTRCORELOG_TRACE (
"leBTDevState = %d\n", leBTDevState);
2135 BTRCORELOG_TRACE (
"lpstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState = %d\n", pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState);
2136 BTRCORELOG_TRACE (
"lpstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState = %d\n", pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState);
2138 if ((pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState != leBTDevState) &&
2139 (pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState != enBTRCoreDevStInitialized)) {
2141 if ((enBTRCoreMobileAudioIn != lenBTRCoreDevType) && (enBTRCorePCAudioIn != lenBTRCoreDevType)) {
2143 if ( !(((pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState != enBTRCoreDevStPlaying) &&
2144 (pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState == enBTRCoreDevStConnected) && (leBTDevState == enBTRCoreDevStDisconnected)) ||
2145 ((pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState == enBTRCoreDevStDisconnected) && (leBTDevState == enBTRCoreDevStConnected) &&
2146 ((pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState != enBTRCoreDevStPaired) ||
2147 (pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState != enBTRCoreDevStConnecting))))) {
2148 bTriggerDevStatusChangeCb =
TRUE;
2151 if ((enBTRCoreHID == lenBTRCoreDevType) &&
2152 (((enBTRCoreDevStConnected == pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState) && (enBTRCoreDevStDisconnected == leBTDevState)) ||
2153 ((enBTRCoreDevStDisconnected == pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState) && (enBTRCoreDevStConnected == leBTDevState)))) {
2154 bTriggerDevStatusChangeCb =
TRUE;
2156 if (strstr(pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].pcDeviceName,
"Xbox")) {
2157 if (leBTDevState == enBTRCoreDevStConnected) {
2159 BTRCORELOG_ERROR (
"Failed to Disable ERTM\n");
2162 else if (leBTDevState == enBTRCoreDevStDisconnected) {
2164 BTRCORELOG_ERROR (
"Failed to Enable ERTM\n");
2174 if ((leBTDevState == enBTRCoreDevStDisconnected) &&
2175 ((pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState == enBTRCoreDevStConnected) ||
2176 (pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState == enBTRCoreDevStDisconnecting))) {
2177 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState = enBTRCoreDevStPaired;
2179 else if ( !((leBTDevState == enBTRCoreDevStConnected) &&
2180 ((pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState == enBTRCoreDevStDisconnecting) ||
2181 (pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState == enBTRCoreDevStDisconnected) ||
2182 (pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState == enBTRCoreDevStInitialized)))) {
2183 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState = pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState;
2187 if ((leBTDevState == enBTRCoreDevStDisconnected) &&
2188 (pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState == enBTRCoreDevStPlaying)) {
2189 leBTDevState = enBTRCoreDevStLost;
2190 pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].bDeviceConnected = FALSE;
2194 if ( !((leBTDevState == enBTRCoreDevStDisconnected) &&
2195 (pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState == enBTRCoreDevStLost) &&
2196 (pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState == enBTRCoreDevStPlaying))) {
2198 if ( !((leBTDevState == enBTRCoreDevStConnected) &&
2199 (pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState == enBTRCoreDevStLost) &&
2200 (pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState != enBTRCoreDevStPlaying))) {
2201 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState = pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState;
2202 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState = leBTDevState;
2205 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState = enBTRCoreDevStConnecting;
2209 leBTDevState = enBTRCoreDevStConnected;
2210 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState = enBTRCoreDevStConnecting;
2215 bTriggerDevStatusChangeCb =
TRUE;
2217 if (enBTRCoreDevStInitialized != pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState) {
2218 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState =
2219 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState;
2222 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState = enBTRCoreDevStConnecting;
2225 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState = leBTDevState;
2228 pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].enDeviceType = btrCore_MapClassIDtoDevClass(lpstBTDeviceInfo->ui32Class);
2231 pstlhBTRCore->stDevStatusCbInfo.isPaired = 1;
2232 lpstBTRCoreBTDevice = &pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx];
2233 lpstBTRCoreDevStateInfo = &pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx];
2236 if ((pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState == enBTRCoreDevStConnected) &&
2237 (pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState == enBTRCoreDevStPaired)) {
2238 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState = enBTRCoreDevStPaired;
2239 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState = enBTRCoreDevStConnected;
2242 BTRCORELOG_TRACE (
"i32KnownDevIdx = %d\n", i32KnownDevIdx);
2243 BTRCORELOG_TRACE (
"leBTDevState = %d\n", leBTDevState);
2244 BTRCORELOG_TRACE (
"lpstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState = %d\n", pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState);
2245 BTRCORELOG_TRACE (
"lpstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState = %d\n", pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState);
2246 BTRCORELOG_TRACE (
"lpstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].enDeviceType = %x\n", pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].enDeviceType);
2248 if (pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState == enBTRCoreDevStDisconnected) {
2249 pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].bDeviceConnected = FALSE;
2251 else if (pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState == enBTRCoreDevStConnected) {
2252 pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].bDeviceConnected =
TRUE;
2257 else if (i32ScannedDevIdx != -1) {
2259 BTRCORELOG_TRACE (
"i32ScannedDevIdx = %d\n", i32ScannedDevIdx);
2260 BTRCORELOG_TRACE (
"leBTDevState = %d\n", leBTDevState);
2261 BTRCORELOG_TRACE (
"lpstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDeviceCurrState = %d\n", pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDeviceCurrState);
2262 BTRCORELOG_TRACE (
"lpstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDevicePrevState = %d\n", pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDevicePrevState);
2264 if ((pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDeviceCurrState != leBTDevState) &&
2265 (pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDeviceCurrState != enBTRCoreDevStInitialized)) {
2267 pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDevicePrevState = pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDeviceCurrState;
2268 pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDeviceCurrState = leBTDevState;
2269 pstlhBTRCore->stDevStatusCbInfo.isPaired = lpstBTDeviceInfo->bPaired;
2271 lpstBTRCoreBTDevice = &pstlhBTRCore->stScannedDevicesArr[i32ScannedDevIdx];
2272 lpstBTRCoreDevStateInfo = &pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx];
2274 if (lpstBTDeviceInfo->bPaired &&
2275 lpstBTDeviceInfo->bConnected &&
2276 (((pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDevicePrevState == enBTRCoreDevStFound) &&
2277 (pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDeviceCurrState == enBTRCoreDevStConnected)) ||
2278 ((pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDevicePrevState == enBTRCoreDevStFound) &&
2279 (pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDeviceCurrState == enBTRCoreDevStPaired)) ||
2280 ((pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDevicePrevState == enBTRCoreDevStConnected) &&
2281 (pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDeviceCurrState == enBTRCoreDevStPaired)))) {
2283 if ((i32KnownDevIdx = btrCore_AddDeviceToKnownDevicesArr(pstlhBTRCore, lpstBTDeviceInfo)) != -1) {
2285 if ((pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDevicePrevState == enBTRCoreDevStConnected) &&
2286 (pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDeviceCurrState == enBTRCoreDevStPaired)) {
2287 pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDevicePrevState = enBTRCoreDevStPaired;
2288 pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDeviceCurrState = enBTRCoreDevStConnected;
2291 if (!((pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState == enBTRCoreDevStPaired) &&
2292 (pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState == enBTRCoreDevStConnected))) {
2293 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDevicePrevState = pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDevicePrevState;
2294 pstlhBTRCore->stKnownDevStInfoArr[i32KnownDevIdx].eDeviceCurrState = pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDeviceCurrState;
2297 BTRCORELOG_DEBUG (
"btrCore_AddDeviceToKnownDevicesArr - Success Index = %d\n", i32KnownDevIdx);
2301 if (pstlhBTRCore->numOfPairedDevices) {
2302 for (i32LoopIdx = 0; i32LoopIdx < pstlhBTRCore->numOfPairedDevices; i32LoopIdx++) {
2303 if (lBTRCoreDevId == pstlhBTRCore->stKnownDevicesArr[i32LoopIdx].tDeviceId) {
2305 lpstBTRCoreBTDevice = &pstlhBTRCore->stKnownDevicesArr[i32LoopIdx];
2306 lpstBTRCoreDevStateInfo = &pstlhBTRCore->stKnownDevStInfoArr[i32LoopIdx];
2312 if (lenBTRCoreDevType == enBTRCoreLE &&
2313 (leBTDevState == enBTRCoreDevStConnected ||
2314 leBTDevState == enBTRCoreDevStDisconnected)) {
2315 lpstBTRCoreBTDevice = &pstlhBTRCore->stScannedDevicesArr[i32ScannedDevIdx];
2316 lpstBTRCoreDevStateInfo = &pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx];
2318 if (leBTDevState == enBTRCoreDevStDisconnected) {
2319 lpstBTRCoreBTDevice->bDeviceConnected = FALSE;
2322 if (pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDevicePrevState == enBTRCoreDevStInitialized) {
2323 pstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDevicePrevState = enBTRCoreDevStConnecting;
2327 bTriggerDevStatusChangeCb =
TRUE;
2331 if (bTriggerDevStatusChangeCb ==
TRUE) {
2333 if (lpstBTRCoreBTDevice->enDeviceType == enBTRCore_DC_Unknown) {
2334 for (i32LoopIdx = 0; i32LoopIdx < lpstBTRCoreBTDevice->stDeviceProfile.numberOfService; i32LoopIdx++) {
2335 if (lpstBTRCoreBTDevice->stDeviceProfile.profile[i32LoopIdx].uuid_value == strtol(BTR_CORE_A2SNK, NULL, 16)) {
2336 lpstBTRCoreBTDevice->enDeviceType = enBTRCore_DC_Loudspeaker;
2338 else if (lpstBTRCoreBTDevice->stDeviceProfile.profile[i32LoopIdx].uuid_value == strtol(BTR_CORE_A2SRC, NULL, 16)) {
2339 lpstBTRCoreBTDevice->enDeviceType = enBTRCore_DC_SmartPhone;
2341 else if ((lpstBTRCoreBTDevice->stDeviceProfile.profile[i32LoopIdx].uuid_value == strtol(BTR_CORE_GATT_TILE_1, NULL, 16)) ||
2342 (lpstBTRCoreBTDevice->stDeviceProfile.profile[i32LoopIdx].uuid_value == strtol(BTR_CORE_GATT_TILE_2, NULL, 16)) ||
2343 (lpstBTRCoreBTDevice->stDeviceProfile.profile[i32LoopIdx].uuid_value == strtol(BTR_CORE_GATT_TILE_3, NULL, 16))) {
2344 lpstBTRCoreBTDevice->enDeviceType = enBTRCore_DC_Tile;
2346 else if (lpstBTRCoreBTDevice->stDeviceProfile.profile[i32LoopIdx].uuid_value == strtol(BTR_CORE_HID_1, NULL, 16) ||
2347 lpstBTRCoreBTDevice->stDeviceProfile.profile[i32LoopIdx].uuid_value == strtol(BTR_CORE_HID_2, NULL, 16)) {
2348 lpstBTRCoreBTDevice->enDeviceType = enBTRCore_DC_HID_Keyboard;
2353 pstlhBTRCore->stDevStatusCbInfo.deviceId = lBTRCoreDevId;
2354 pstlhBTRCore->stDevStatusCbInfo.eDeviceType = btrCore_MapDevClassToDevType(lpstBTRCoreBTDevice->enDeviceType);
2355 pstlhBTRCore->stDevStatusCbInfo.eDevicePrevState = lpstBTRCoreDevStateInfo->eDevicePrevState;
2356 pstlhBTRCore->stDevStatusCbInfo.eDeviceCurrState = leBTDevState;
2357 pstlhBTRCore->stDevStatusCbInfo.eDeviceClass = lpstBTRCoreBTDevice->enDeviceType;
2358 pstlhBTRCore->stDevStatusCbInfo.ui32DevClassBtSpec = lpstBTRCoreBTDevice->ui32DevClassBtSpec;
2359 strncpy(pstlhBTRCore->stDevStatusCbInfo.deviceName, lpstBTRCoreBTDevice->pcDeviceName, BD_NAME_LEN);
2360 strncpy(pstlhBTRCore->stDevStatusCbInfo.deviceAddress, lpstBTRCoreBTDevice->pcDeviceAddress, BD_NAME_LEN);
2362 if (pstlhBTRCore->fpcBBTRCoreStatus) {
2363 if (pstlhBTRCore->fpcBBTRCoreStatus(&pstlhBTRCore->stDevStatusCbInfo, pstlhBTRCore->pvcBStatusUserData) != enBTRCoreSuccess) {
2370 g_free(lpstOutTskInData->pstBTDevInfo);
2371 lpstOutTskInData->pstBTDevInfo = NULL;
2374 if (lpstOutTskInData) {
2375 g_free(lpstOutTskInData);
2376 lpstOutTskInData = NULL;
2379 else if (lenOutTskPTCur == enBTRCoreTaskPTcBAdapterStatus) {
2380 if (lpstOutTskInData) {
2383 BTRCORELOG_TRACE (
"stDiscoveryCbInfo.adapter.bDiscovering = %d, lpstBTRCoreAdapter->bDiscovering = %d\n",
2384 pstlhBTRCore->stDiscoveryCbInfo.adapter.bDiscovering, lpstBTRCoreAdapter->bDiscovering);
2387 if (pstlhBTRCore->stDiscoveryCbInfo.adapter.bDiscovering != lpstBTRCoreAdapter->bDiscovering)
2389 pstlhBTRCore->stDiscoveryCbInfo.type = enBTRCoreOpTypeAdapter;
2390 memcpy(&pstlhBTRCore->stDiscoveryCbInfo.adapter, lpstBTRCoreAdapter,
sizeof(
stBTRCoreAdapter));
2391 if (pstlhBTRCore->fpcBBTRCoreDeviceDisc) {
2392 if ((lenBTRCoreRet = pstlhBTRCore->fpcBBTRCoreDeviceDisc(&pstlhBTRCore->stDiscoveryCbInfo,
2393 pstlhBTRCore->pvcBDevDiscUserData)) != enBTRCoreSuccess) {
2394 BTRCORELOG_ERROR (
"Failure fpcBBTRCoreDeviceDisc Ret = %d\n", lenBTRCoreRet);
2399 g_free(lpstOutTskInData);
2400 lpstOutTskInData = NULL;
2403 else if (lenOutTskPTCur == enBTRCoreTaskPTcBMediaStatus) {
2404 if (lpstOutTskInData) {
2406 tBTRCoreDevId lBTRCoreDevId = lpstMediaStatusUpdateCbInfo->deviceId;
2407 int i32LoopIdx = -1;
2408 int i32KnownDevIdx = -1;
2410 for (i32LoopIdx = 0; i32LoopIdx < pstlhBTRCore->numOfPairedDevices; i32LoopIdx++) {
2411 if (lBTRCoreDevId == pstlhBTRCore->stKnownDevicesArr[i32LoopIdx].tDeviceId) {
2412 i32KnownDevIdx = i32LoopIdx;
2417 BTRCORELOG_TRACE (
"i32KnownDevIdx = %d\n", i32KnownDevIdx);
2419 if ((i32KnownDevIdx != -1) &&
2420 ((pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].bDeviceConnected ==
TRUE) ||
2421 (lpstMediaStatusUpdateCbInfo->m_mediaStatusUpdate.bIsMediaCtrlAvailable ==
TRUE))) {
2423 pstlhBTRCore->stMediaStatusCbInfo.deviceId = pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].tDeviceId;
2424 pstlhBTRCore->stMediaStatusCbInfo.eDeviceClass = pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].enDeviceType;
2425 strncpy(pstlhBTRCore->stMediaStatusCbInfo.deviceName, pstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx].pcDeviceName, BD_NAME_LEN);
2427 if (pstlhBTRCore->fpcBBTRCoreMediaStatus) {
2428 if ((lenBTRCoreRet = pstlhBTRCore->fpcBBTRCoreMediaStatus(&pstlhBTRCore->stMediaStatusCbInfo, pstlhBTRCore->pvcBMediaStatusUserData)) != enBTRCoreSuccess) {
2429 BTRCORELOG_ERROR (
"Failure fpcBBTRCoreMediaStatus Ret = %d\n", lenBTRCoreRet);
2434 g_free(lpstOutTskInData);
2435 lpstOutTskInData = NULL;
2438 else if (lenOutTskPTCur == enBTRCoreTaskPTcBDevOpInfoStatus) {
2439 if (lpstOutTskInData) {
2443 if (pstlhBTRCore->fpcBBTRCoreStatus) {
2444 if ((lenBTRCoreRet = pstlhBTRCore->fpcBBTRCoreStatus(&pstlhBTRCore->stDevStatusCbInfo, pstlhBTRCore->pvcBStatusUserData)) != enBTRCoreSuccess) {
2445 BTRCORELOG_ERROR (
"Failure fpcBBTRCoreStatus Ret = %d\n", lenBTRCoreRet);
2449 g_free(lpstOutTskInData);
2450 lpstOutTskInData = NULL;
2453 else if (lenOutTskPTCur == enBTRCoreTaskPTcBConnIntim) {
2455 else if (lenOutTskPTCur == enBTRCoreTaskPTcBConnAuth) {
2457 else if (lenOutTskPTCur == enBTRCoreTaskPTUnknown) {
2466 case enBTRCoreTaskOpExit: {
2467 lbOutTaskExit =
TRUE;
2470 case enBTRCoreTaskOpUnknown: {
2482 }
while (lbOutTaskExit == FALSE);
2484 BTRCORELOG_DEBUG (
"OutTask Exiting\n");
2487 *penExitStatusOutTask = enBTRCoreSuccess;
2488 return (gpointer)penExitStatusOutTask;
2495 tBTRCoreHandle* phBTRCore
2500 #ifdef RDK_LOGGER_ENABLED
2501 const char* pDebugConfig = NULL;
2502 const char* BTRCORE_DEBUG_ACTUAL_PATH =
"/etc/debug.ini";
2503 const char* BTRCORE_DEBUG_OVERRIDE_PATH =
"/opt/debug.ini";
2506 if (access(BTRCORE_DEBUG_OVERRIDE_PATH, F_OK) != -1 ) {
2507 pDebugConfig = BTRCORE_DEBUG_OVERRIDE_PATH;
2510 pDebugConfig = BTRCORE_DEBUG_ACTUAL_PATH;
2514 b_rdk_logger_enabled = 1;
2518 BTRCORELOG_INFO (
"BTRCore_Init\n");
2521 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
2522 return enBTRCoreInvalidArg;
2527 if (!pstlhBTRCore) {
2528 BTRCORELOG_ERROR (
"Insufficient memory - enBTRCoreInitFailure\n");
2529 return enBTRCoreInitFailure;
2535 if (!pstlhBTRCore->connHdl) {
2536 BTRCORELOG_ERROR (
"Can't get on system bus - enBTRCoreInitFailure\n");
2538 return enBTRCoreInitFailure;
2542 btrCore_InitDataSt(pstlhBTRCore);
2545 if (!pstlhBTRCore->agentPath) {
2546 BTRCORELOG_ERROR (
"Can't get agent path - enBTRCoreInitFailure\n");
2548 return enBTRCoreInitFailure;
2552 if (!(pstlhBTRCore->pGAQueueOutTask = g_async_queue_new()) ||
2553 !(pstlhBTRCore->pThreadOutTask = g_thread_new(
"btrCore_OutTask", btrCore_OutTask, (gpointer)pstlhBTRCore))) {
2554 BTRCORELOG_ERROR (
"Failed to create btrCore_OutTask Thread - enBTRCoreInitFailure\n");
2556 return enBTRCoreInitFailure;
2559 if (!(pstlhBTRCore->pGAQueueRunTask = g_async_queue_new()) ||
2560 !(pstlhBTRCore->pThreadRunTask = g_thread_new(
"btrCore_RunTask", btrCore_RunTask, (gpointer)pstlhBTRCore))) {
2561 BTRCORELOG_ERROR (
"Failed to create btrCore_RunTask Thread - enBTRCoreInitFailure\n");
2563 return enBTRCoreInitFailure;
2566 if (btrCore_OutTaskAddOp(pstlhBTRCore->pGAQueueOutTask, enBTRCoreTaskOpStart, enBTRCoreTaskPTUnknown, NULL) != enBTRCoreSuccess) {
2567 BTRCORELOG_ERROR(
"Failure btrCore_OutTaskAddOp enBTRCoreTaskOpStart enBTRCoreTaskPTUnknown\n");
2570 if (btrCore_RunTaskAddOp(pstlhBTRCore->pGAQueueRunTask, enBTRCoreTaskOpStart, enBTRCoreTaskPTUnknown, NULL) != enBTRCoreSuccess) {
2571 BTRCORELOG_ERROR(
"Failure btrCore_RunTaskAddOp enBTRCoreTaskOpStart enBTRCoreTaskPTUnknown\n");
2579 if (!pstlhBTRCore->curAdapterPath) {
2580 BTRCORELOG_ERROR (
"Failed to get BT Adapter - enBTRCoreInitFailure\n");
2582 return enBTRCoreInitFailure;
2585 lunBtOpAdapProp.enBtAdapterProp = enBTAdPropAddress;
2587 pstlhBTRCore->curAdapterPath,
2590 pstlhBTRCore->curAdapterAddr)) {
2591 BTRCORELOG_ERROR (
"Failed to get BT Adapter Address - enBTRCoreInitFailure\n");
2593 return enBTRCoreInitFailure;
2596 BTRCORELOG_DEBUG (
"Adapter path %s - Adapter Address %s \n", pstlhBTRCore->curAdapterPath, pstlhBTRCore->curAdapterAddr);
2600 if (
BTRCore_AVMedia_Init(&pstlhBTRCore->avMediaHdl, pstlhBTRCore->connHdl, pstlhBTRCore->curAdapterPath) != enBTRCoreSuccess) {
2601 BTRCORELOG_ERROR (
"Failed to Init AV Media Subsystem - enBTRCoreInitFailure\n");
2603 return enBTRCoreInitFailure;
2607 if (
BTRCore_LE_Init(&pstlhBTRCore->leHdl, pstlhBTRCore->connHdl, pstlhBTRCore->curAdapterPath) != enBTRCoreSuccess) {
2608 BTRCORELOG_ERROR (
"Failed to Init LE Subsystem - enBTRCoreInitFailure\n");
2610 return enBTRCoreInitFailure;
2614 if(BtrCore_BTRegisterAdapterStatusUpdateCb(pstlhBTRCore->connHdl, &btrCore_BTAdapterStatusUpdateCb, pstlhBTRCore)) {
2615 BTRCORELOG_ERROR (
"Failed to Register Adapter Status CB - enBTRCoreInitFailure\n");
2619 if(BtrCore_BTRegisterDevStatusUpdateCb(pstlhBTRCore->connHdl, &btrCore_BTDeviceStatusUpdateCb, pstlhBTRCore)) {
2620 BTRCORELOG_ERROR (
"Failed to Register Device Status CB - enBTRCoreInitFailure\n");
2624 if(BtrCore_BTRegisterConnIntimationCb(pstlhBTRCore->connHdl, &btrCore_BTDeviceConnectionIntimationCb, pstlhBTRCore)) {
2625 BTRCORELOG_ERROR (
"Failed to Register Connection Intimation CB - enBTRCoreInitFailure\n");
2629 if(BtrCore_BTRegisterConnAuthCb(pstlhBTRCore->connHdl, &btrCore_BTDeviceAuthenticationCb, pstlhBTRCore)) {
2630 BTRCORELOG_ERROR (
"Failed to Register Connection Authentication CB - enBTRCoreInitFailure\n");
2635 BTRCORELOG_ERROR (
"Failed to Register Media Status CB - enBTRCoreInitFailure\n");
2639 if(BTRCore_LE_RegisterStatusUpdateCb(pstlhBTRCore->leHdl, &btrCore_BTLeStatusUpdateCb, pstlhBTRCore) != enBTRCoreSuccess) {
2640 BTRCORELOG_ERROR (
"Failed to Register LE Status CB - enBTRCoreInitFailure\n");
2644 *phBTRCore = (tBTRCoreHandle)pstlhBTRCore;
2647 btrCore_PopulateListOfPairedDevices(*phBTRCore, pstlhBTRCore->curAdapterPath);
2650 pstlhBTRCore->aenDeviceDiscoveryType = enBTRCoreUnknown;
2652 return enBTRCoreSuccess;
2658 tBTRCoreHandle hBTRCore
2660 gpointer penExitStatusRunTask = NULL;
2661 enBTRCoreRet lenExitStatusRunTask = enBTRCoreSuccess;
2663 gpointer penExitStatusOutTask = NULL;
2664 enBTRCoreRet lenExitStatusOutTask = enBTRCoreSuccess;
2666 enBTRCoreRet lenBTRCoreRet = enBTRCoreSuccess;
2672 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
2673 return enBTRCoreNotInitialized;
2678 BTRCORELOG_INFO (
"hBTRCore = %8p\n", hBTRCore);
2682 if (pstlhBTRCore->pThreadRunTask) {
2684 if (pstlhBTRCore->pGAQueueRunTask) {
2685 if (btrCore_RunTaskAddOp(pstlhBTRCore->pGAQueueRunTask, enBTRCoreTaskOpExit, enBTRCoreTaskPTUnknown, NULL) != enBTRCoreSuccess) {
2686 BTRCORELOG_ERROR(
"Failure btrCore_RunTaskAddOp enBTRCoreTaskOpExit enBTRCoreTaskPTUnknown\n");
2690 penExitStatusRunTask = g_thread_join(pstlhBTRCore->pThreadRunTask);
2691 pstlhBTRCore->pThreadRunTask = NULL;
2694 if (penExitStatusRunTask) {
2695 BTRCORELOG_INFO (
"BTRCore_DeInit - RunTask Exiting BTRCore - %d\n", *((enBTRCoreRet*)penExitStatusRunTask));
2696 lenExitStatusRunTask = *((enBTRCoreRet*)penExitStatusRunTask);
2697 g_free(penExitStatusRunTask);
2698 penExitStatusRunTask = NULL;
2701 if (pstlhBTRCore->pGAQueueRunTask) {
2702 g_async_queue_unref(pstlhBTRCore->pGAQueueRunTask);
2703 pstlhBTRCore->pGAQueueRunTask = NULL;
2707 if (pstlhBTRCore->pThreadOutTask) {
2709 if (pstlhBTRCore->pGAQueueOutTask) {
2710 if (btrCore_OutTaskAddOp(pstlhBTRCore->pGAQueueOutTask, enBTRCoreTaskOpExit, enBTRCoreTaskPTUnknown, NULL) != enBTRCoreSuccess) {
2711 BTRCORELOG_ERROR(
"Failure btrCore_OutTaskAddOp enBTRCoreTaskOpExit enBTRCoreTaskPTUnknown\n");
2715 penExitStatusOutTask = g_thread_join(pstlhBTRCore->pThreadOutTask);
2716 pstlhBTRCore->pThreadOutTask = NULL;
2719 if (penExitStatusOutTask) {
2720 BTRCORELOG_INFO (
"BTRCore_DeInit - OutTask Exiting BTRCore - %d\n", *((enBTRCoreRet*)penExitStatusOutTask));
2721 lenExitStatusOutTask = *((enBTRCoreRet*)penExitStatusOutTask);
2722 g_free(penExitStatusOutTask);
2723 penExitStatusOutTask = NULL;
2726 if (pstlhBTRCore->pGAQueueOutTask) {
2727 g_async_queue_unref(pstlhBTRCore->pGAQueueOutTask);
2728 pstlhBTRCore->pGAQueueOutTask = NULL;
2735 if (pstlhBTRCore->leHdl && (
BTRCore_LE_DeInit(pstlhBTRCore->leHdl, pstlhBTRCore->connHdl, pstlhBTRCore->curAdapterPath) != enBTRCoreSuccess)) {
2736 BTRCORELOG_ERROR (
"Failed to DeInit LE Subsystem\n");
2737 lenBTRCoreRet = enBTRCoreFailure;
2740 if (pstlhBTRCore->avMediaHdl && (
BTRCore_AVMedia_DeInit(pstlhBTRCore->avMediaHdl, pstlhBTRCore->connHdl, pstlhBTRCore->curAdapterPath) != enBTRCoreSuccess)) {
2741 BTRCORELOG_ERROR (
"Failed to DeInit AV Media Subsystem\n");
2742 lenBTRCoreRet = enBTRCoreFailure;
2745 if (pstlhBTRCore->curAdapterPath) {
2747 BTRCORELOG_ERROR (
"Failure BtrCore_BTReleaseAdapterPath\n");
2748 lenBTRCoreRet = enBTRCoreFailure;
2750 pstlhBTRCore->curAdapterPath = NULL;
2754 for (i = 0; i < BTRCORE_MAX_NUM_BT_ADAPTERS; i++) {
2755 if (pstlhBTRCore->adapterPath[i]) {
2756 g_free(pstlhBTRCore->adapterPath[i]);
2757 pstlhBTRCore->adapterPath[i] = NULL;
2760 if (pstlhBTRCore->adapterAddr[i]) {
2761 g_free(pstlhBTRCore->adapterAddr[i]);
2762 pstlhBTRCore->adapterAddr[i] = NULL;
2766 if (pstlhBTRCore->curAdapterAddr) {
2767 g_free(pstlhBTRCore->curAdapterAddr);
2768 pstlhBTRCore->curAdapterAddr = NULL;
2771 if (pstlhBTRCore->agentPath) {
2773 BTRCORELOG_ERROR (
"Failure BtrCore_BTReleaseAgentPath\n");
2774 lenBTRCoreRet = enBTRCoreFailure;
2776 pstlhBTRCore->agentPath = NULL;
2779 if (pstlhBTRCore->connHdl) {
2781 BTRCORELOG_ERROR (
"Failure BtrCore_BTDeInitReleaseConnection\n");
2782 lenBTRCoreRet = enBTRCoreFailure;
2784 pstlhBTRCore->connHdl = NULL;
2792 lenBTRCoreRet = ((lenExitStatusRunTask == enBTRCoreSuccess) &&
2793 (lenExitStatusOutTask == enBTRCoreSuccess) &&
2794 (lenBTRCoreRet == enBTRCoreSuccess)) ? enBTRCoreSuccess : enBTRCoreFailure;
2795 BTRCORELOG_DEBUG (
"Exit Status = %d\n", lenBTRCoreRet);
2798 return lenBTRCoreRet;
2804 tBTRCoreHandle hBTRCore,
2807 char capabilities[32] = {
'\0'};
2811 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
2812 return enBTRCoreNotInitialized;
2817 if (iBTRCapMode == 1) {
2818 strcpy(capabilities,
"DisplayYesNo");
2821 strcpy(capabilities,
"NoInputNoOutput");
2825 if (
BtrCore_BTRegisterAgent(pstlhBTRCore->connHdl, pstlhBTRCore->curAdapterPath, pstlhBTRCore->agentPath, capabilities) < 0) {
2826 BTRCORELOG_ERROR (
"Agent registration ERROR occurred\n");
2827 return enBTRCoreFailure;
2830 BTRCORELOG_TRACE (
"Starting Agent in mode %s\n", capabilities);
2831 return enBTRCoreSuccess;
2837 tBTRCoreHandle hBTRCore
2842 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
2843 return enBTRCoreNotInitialized;
2849 BTRCORELOG_ERROR (
"Agent unregistration ERROR occurred\n");
2850 return enBTRCoreFailure;
2853 BTRCORELOG_TRACE (
"Stopping Agent\n");
2854 return enBTRCoreSuccess;
2860 tBTRCoreHandle hBTRCore,
2864 enBTRCoreRet rc = enBTRCoreFailure;
2869 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
2870 return enBTRCoreNotInitialized;
2872 else if (!pstListAdapters) {
2873 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
2874 return enBTRCoreInvalidArg;
2880 pstListAdapters->number_of_adapters = pstlhBTRCore->numOfAdapters;
2881 for (i = 0; i < pstListAdapters->number_of_adapters; i++) {
2882 memset(&pstListAdapters->adapter_path[i][0],
'\0', BD_NAME_LEN + 1);
2883 strncpy(&pstListAdapters->adapter_path[i][0], pstlhBTRCore->adapterPath[i], BD_NAME_LEN);
2885 memset(&pstListAdapters->adapterAddr[i][0],
'\0', BD_NAME_LEN + 1);
2886 lunBtOpAdapProp.enBtAdapterProp = enBTAdPropAddress;
2887 if (!
BtrCore_BTGetProp(pstlhBTRCore->connHdl, pstlhBTRCore->adapterPath[i], enBTAdapter, lunBtOpAdapProp, pstlhBTRCore->adapterAddr[i])) {
2888 strncpy(&pstListAdapters->adapterAddr[i][0], pstlhBTRCore->adapterAddr[i], BD_NAME_LEN);
2890 rc = enBTRCoreSuccess;
2900 tBTRCoreHandle hBTRCore,
2906 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
2907 return enBTRCoreNotInitialized;
2909 else if (!pstGetAdapters) {
2910 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
2911 return enBTRCoreInvalidArg;
2917 pstGetAdapters->number_of_adapters = pstlhBTRCore->numOfAdapters;
2918 return enBTRCoreSuccess;
2921 return enBTRCoreSuccess;
2927 tBTRCoreHandle hBTRCore,
2933 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
2934 return enBTRCoreNotInitialized;
2939 if (!pstlhBTRCore->curAdapterPath) {
2941 BTRCORELOG_ERROR (
"Failed to get BT Adapter");
2942 return enBTRCoreInvalidAdapter;
2947 if (apstBTRCoreAdapter) {
2948 apstBTRCoreAdapter->adapter_number = 0;
2949 apstBTRCoreAdapter->pcAdapterPath = pstlhBTRCore->curAdapterPath;
2950 apstBTRCoreAdapter->pcAdapterDevName = NULL;
2953 return enBTRCoreSuccess;
2959 tBTRCoreHandle hBTRCore,
2966 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
2967 return enBTRCoreNotInitialized;
2972 pathlen = strlen(pstlhBTRCore->curAdapterPath);
2973 switch (adapter_number) {
2975 pstlhBTRCore->curAdapterPath[pathlen-1]=
'0';
2978 pstlhBTRCore->curAdapterPath[pathlen-1]=
'1';
2981 pstlhBTRCore->curAdapterPath[pathlen-1]=
'2';
2984 pstlhBTRCore->curAdapterPath[pathlen-1]=
'3';
2987 pstlhBTRCore->curAdapterPath[pathlen-1]=
'4';
2990 pstlhBTRCore->curAdapterPath[pathlen-1]=
'5';
2993 BTRCORELOG_INFO (
"max adapter value is 5, setting default\n");
2994 pstlhBTRCore->curAdapterPath[pathlen-1]=
'0';
2998 BTRCORELOG_INFO (
"Now current adatper is %s\n", pstlhBTRCore->curAdapterPath);
3000 return enBTRCoreSuccess;
3006 tBTRCoreHandle hBTRCore,
3015 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3016 return enBTRCoreNotInitialized;
3022 BTRCORELOG_ERROR (
"BTRCore_EnableAdapter\n");
3023 apstBTRCoreAdapter->enable =
TRUE;
3024 lunBtOpAdapProp.enBtAdapterProp = enBTAdPropPowered;
3026 if (
BtrCore_BTSetProp(pstlhBTRCore->connHdl, pstlhBTRCore->curAdapterPath, enBTAdapter, lunBtOpAdapProp, &powered)) {
3027 BTRCORELOG_ERROR (
"Set Adapter Property enBTAdPropPowered - FAILED\n");
3028 return enBTRCoreFailure;
3031 return enBTRCoreSuccess;
3037 tBTRCoreHandle hBTRCore,
3045 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3046 return enBTRCoreNotInitialized;
3051 BTRCORELOG_ERROR (
"BTRCore_DisableAdapter\n");
3052 apstBTRCoreAdapter->enable = FALSE;
3053 lunBtOpAdapProp.enBtAdapterProp = enBTAdPropPowered;
3055 if (
BtrCore_BTSetProp(pstlhBTRCore->connHdl, pstlhBTRCore->curAdapterPath, enBTAdapter, lunBtOpAdapProp, &powered)) {
3056 BTRCORELOG_ERROR (
"Set Adapter Property enBTAdPropPowered - FAILED\n");
3057 return enBTRCoreFailure;
3060 return enBTRCoreSuccess;
3066 tBTRCoreHandle hBTRCore,
3067 unsigned char aui8adapterIdx,
3068 char* apui8adapterAddr
3071 enBTRCoreRet lenBTRCoreRet= enBTRCoreFailure;
3075 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3076 return enBTRCoreNotInitialized;
3078 else if (!apui8adapterAddr) {
3079 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3080 return enBTRCoreInvalidArg;
3085 for (i = 0; i < pstlhBTRCore->numOfAdapters; i++) {
3086 if (aui8adapterIdx == i) {
3087 strncpy(apui8adapterAddr, pstlhBTRCore->adapterAddr[i], (strlen(pstlhBTRCore->adapterAddr[i]) < BD_NAME_LEN) ? strlen(pstlhBTRCore->adapterAddr[i]) : BD_NAME_LEN - 1);
3088 lenBTRCoreRet = enBTRCoreSuccess;
3093 return lenBTRCoreRet;
3099 tBTRCoreHandle hBTRCore,
3100 const char* pAdapterPath,
3101 unsigned char discoverable
3105 int isDiscoverable = (int) discoverable;
3108 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3109 return enBTRCoreNotInitialized;
3111 else if (!pAdapterPath) {
3112 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3113 return enBTRCoreInvalidArg;
3118 lunBtOpAdapProp.enBtAdapterProp = enBTAdPropDiscoverable;
3120 if (
BtrCore_BTSetProp(pstlhBTRCore->connHdl, pstlhBTRCore->curAdapterPath, enBTAdapter, lunBtOpAdapProp, &isDiscoverable)) {
3121 BTRCORELOG_ERROR (
"Set Adapter Property enBTAdPropDiscoverable - FAILED\n");
3122 return enBTRCoreFailure;
3125 return enBTRCoreSuccess;
3131 tBTRCoreHandle hBTRCore,
3132 const char* pAdapterPath,
3133 unsigned short timeout
3137 unsigned int givenTimeout = (
unsigned int)timeout;
3140 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3141 return enBTRCoreNotInitialized;
3143 else if (!pAdapterPath) {
3144 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3145 return enBTRCoreInvalidArg;
3151 lunBtOpAdapProp.enBtAdapterProp = enBTAdPropDiscoverableTimeOut;
3153 if (
BtrCore_BTSetProp(pstlhBTRCore->connHdl, pstlhBTRCore->curAdapterPath, enBTAdapter, lunBtOpAdapProp, &givenTimeout)) {
3154 BTRCORELOG_ERROR (
"Set Adapter Property enBTAdPropDiscoverableTimeOut - FAILED\n");
3155 return enBTRCoreFailure;
3158 return enBTRCoreSuccess;
3164 tBTRCoreHandle hBTRCore,
3165 const char* pAdapterPath,
3166 unsigned char* pDiscoverable
3170 int discoverable = 0;
3173 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3174 return enBTRCoreNotInitialized;
3176 else if ((!pAdapterPath) || (!pDiscoverable)) {
3177 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3178 return enBTRCoreInvalidArg;
3182 lunBtOpAdapProp.enBtAdapterProp = enBTAdPropDiscoverable;
3183 if (!
BtrCore_BTGetProp(pstlhBTRCore->connHdl, pAdapterPath, enBTAdapter, lunBtOpAdapProp, &discoverable)) {
3184 BTRCORELOG_INFO (
"Get value for org.bluez.Adapter.Discoverable = %d\n", discoverable);
3185 *pDiscoverable = (
unsigned char) discoverable;
3186 return enBTRCoreSuccess;
3189 return enBTRCoreFailure;
3195 tBTRCoreHandle hBTRCore,
3197 char* apcAdapterDeviceName
3203 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3204 return enBTRCoreNotInitialized;
3206 else if (!apcAdapterDeviceName) {
3207 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3208 return enBTRCoreInvalidArg;
3213 if(apstBTRCoreAdapter->pcAdapterDevName) {
3214 g_free(apstBTRCoreAdapter->pcAdapterDevName);
3215 apstBTRCoreAdapter->pcAdapterDevName = NULL;
3218 apstBTRCoreAdapter->pcAdapterDevName = g_strndup(apcAdapterDeviceName, BTRCORE_MAX_STR_LEN - 1);
3219 lunBtOpAdapProp.enBtAdapterProp = enBTAdPropName;
3221 if (
BtrCore_BTSetProp(pstlhBTRCore->connHdl, pstlhBTRCore->curAdapterPath, enBTAdapter, lunBtOpAdapProp, &(apstBTRCoreAdapter->pcAdapterDevName))) {
3222 BTRCORELOG_ERROR (
"Set Adapter Property enBTAdPropName - FAILED\n");
3223 return enBTRCoreFailure;
3226 return enBTRCoreSuccess;
3232 tBTRCoreHandle hBTRCore,
3233 const char* pAdapterPath,
3234 const char* pAdapterName
3240 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3241 return enBTRCoreNotInitialized;
3243 else if ((!pAdapterPath) ||(!pAdapterName)) {
3244 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3245 return enBTRCoreInvalidArg;
3249 lunBtOpAdapProp.enBtAdapterProp = enBTAdPropName;
3251 if (
BtrCore_BTSetProp(pstlhBTRCore->connHdl, pstlhBTRCore->curAdapterPath, enBTAdapter, lunBtOpAdapProp, &pAdapterName)) {
3252 BTRCORELOG_ERROR (
"Set Adapter Property enBTAdPropName - FAILED\n");
3253 return enBTRCoreFailure;
3256 return enBTRCoreSuccess;
3262 tBTRCoreHandle hBTRCore,
3263 const char* pAdapterPath,
3269 char name[BD_NAME_LEN + 1] = {
'\0'};
3270 memset (name,
'\0',
sizeof(
char) * (BD_NAME_LEN + 1));
3273 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3274 return enBTRCoreNotInitialized;
3276 else if ((!pAdapterPath) || (!pAdapterName)) {
3277 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3278 return enBTRCoreInvalidArg;
3282 lunBtOpAdapProp.enBtAdapterProp = enBTAdPropName;
3283 if (!
BtrCore_BTGetProp(pstlhBTRCore->connHdl, pAdapterPath, enBTAdapter, lunBtOpAdapProp, name)) {
3284 BTRCORELOG_INFO (
"Get value for org.bluez.Adapter.Name = %s\n", name);
3285 strncpy(pAdapterName, name, strlen(name) < BD_NAME_LEN ? strlen(name) : BD_NAME_LEN -1);
3286 return enBTRCoreSuccess;
3289 return enBTRCoreFailure;
3295 tBTRCoreHandle hBTRCore,
3296 const char* pAdapterPath,
3297 unsigned char powerStatus
3301 int power = powerStatus;
3304 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3305 return enBTRCoreNotInitialized;
3307 else if (!pAdapterPath) {
3308 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3309 return enBTRCoreInvalidArg;
3313 lunBtOpAdapProp.enBtAdapterProp = enBTAdPropPowered;
3315 if (
BtrCore_BTSetProp(pstlhBTRCore->connHdl, pstlhBTRCore->curAdapterPath, enBTAdapter, lunBtOpAdapProp, &power)) {
3316 BTRCORELOG_ERROR (
"Set Adapter Property enBTAdPropPowered - FAILED\n");
3317 return enBTRCoreFailure;
3320 return enBTRCoreSuccess;
3326 tBTRCoreHandle hBTRCore,
3327 const char* pAdapterPath,
3328 unsigned char* pAdapterPower
3332 int powerStatus = 0;
3335 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3336 return enBTRCoreNotInitialized;
3338 else if ((!pAdapterPath) || (!pAdapterPower)) {
3339 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3340 return enBTRCoreInvalidArg;
3344 lunBtOpAdapProp.enBtAdapterProp = enBTAdPropPowered;
3345 if (!
BtrCore_BTGetProp(pstlhBTRCore->connHdl, pAdapterPath, enBTAdapter, lunBtOpAdapProp, &powerStatus)) {
3346 BTRCORELOG_INFO (
"Get value for org.bluez.Adapter.powered = %d\n", powerStatus);
3347 *pAdapterPower = (
unsigned char) powerStatus;
3348 return enBTRCoreSuccess;
3351 return enBTRCoreFailure;
3357 tBTRCoreHandle hBTRCore,
3361 char lBtIfceName[BTRCORE_STR_LEN];
3362 char lBtVersion[BTRCORE_STR_LEN];
3365 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3366 return enBTRCoreNotInitialized;
3368 else if (!apcBtVersion) {
3369 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3370 return enBTRCoreInvalidArg;
3375 memset(lBtIfceName,
'\0', BTRCORE_STR_LEN);
3376 memset(lBtVersion,
'\0', BTRCORE_STR_LEN);
3379 strncpy(apcBtVersion, lBtIfceName, strlen(lBtIfceName));
3380 strncat(apcBtVersion,
"-",
sizeof(apcBtVersion) - strlen(apcBtVersion) -1);
3381 strncat(apcBtVersion, lBtVersion, strlen(lBtVersion));
3382 BTRCORELOG_INFO (
"Ifce: %s Version: %s", lBtIfceName, lBtVersion);
3383 BTRCORELOG_INFO (
"Out: %s\n", apcBtVersion);
3384 return enBTRCoreSuccess;
3387 return enBTRCoreFailure;
3393 tBTRCoreHandle hBTRCore,
3394 const char* pAdapterPath,
3395 enBTRCoreDeviceType aenBTRCoreDevType,
3396 unsigned int aui32DiscDuration
3401 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3402 return enBTRCoreNotInitialized;
3404 else if (!pAdapterPath) {
3405 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3406 return enBTRCoreInvalidArg;
3411 btrCore_ClearScannedDevicesList(pstlhBTRCore);
3414 pstlhBTRCore->aenDeviceDiscoveryType = aenBTRCoreDevType;
3416 if (aenBTRCoreDevType == enBTRCoreLE) {
3418 return enBTRCoreDiscoveryFailure;
3421 if (aui32DiscDuration) {
3422 sleep(aui32DiscDuration);
3424 return enBTRCoreDiscoveryFailure;
3428 else if ((aenBTRCoreDevType == enBTRCoreSpeakers) || (aenBTRCoreDevType == enBTRCoreHeadSet) ||
3429 (aenBTRCoreDevType == enBTRCoreMobileAudioIn) || (aenBTRCoreDevType == enBTRCorePCAudioIn)) {
3431 return enBTRCoreDiscoveryFailure;
3434 if (aui32DiscDuration) {
3435 sleep(aui32DiscDuration);
3437 return enBTRCoreDiscoveryFailure;
3443 return enBTRCoreDiscoveryFailure;
3446 if (aui32DiscDuration) {
3447 sleep(aui32DiscDuration);
3449 return enBTRCoreDiscoveryFailure;
3454 return enBTRCoreSuccess;
3460 tBTRCoreHandle hBTRCore,
3461 const char* pAdapterPath,
3462 enBTRCoreDeviceType aenBTRCoreDevType
3467 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3468 return enBTRCoreNotInitialized;
3470 else if (!pAdapterPath) {
3471 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3472 return enBTRCoreInvalidArg;
3478 if (aenBTRCoreDevType == enBTRCoreLE) {
3480 return enBTRCoreDiscoveryFailure;
3483 else if ((aenBTRCoreDevType == enBTRCoreSpeakers) || (aenBTRCoreDevType == enBTRCoreHeadSet) ||
3484 (aenBTRCoreDevType == enBTRCoreMobileAudioIn) || (aenBTRCoreDevType == enBTRCorePCAudioIn)) {
3486 return enBTRCoreDiscoveryFailure;
3491 return enBTRCoreDiscoveryFailure;
3495 return enBTRCoreSuccess;
3501 tBTRCoreHandle hBTRCore,
3508 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3509 return enBTRCoreNotInitialized;
3511 else if (!pListOfScannedDevices) {
3512 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3513 return enBTRCoreInvalidArg;
3519 BTRCORELOG_TRACE (
"adapter path is %s\n", pstlhBTRCore->curAdapterPath);
3520 for (i = 0; i < BTRCORE_MAX_NUM_BT_DEVICES; i++) {
3521 if (pstlhBTRCore->stScannedDevicesArr[i].bFound) {
3522 BTRCORELOG_TRACE (
"Device : %d\n", i);
3523 BTRCORELOG_TRACE (
"Name : %s\n", pstlhBTRCore->stScannedDevicesArr[i].pcDeviceName);
3524 BTRCORELOG_TRACE (
"Mac Ad : %s\n", pstlhBTRCore->stScannedDevicesArr[i].pcDeviceAddress);
3525 BTRCORELOG_TRACE (
"Rssi : %d dbmV\n", pstlhBTRCore->stScannedDevicesArr[i].i32RSSI);
3526 btrCore_ShowSignalStrength(pstlhBTRCore->stScannedDevicesArr[i].i32RSSI);
3528 memcpy (&pListOfScannedDevices->devices[pListOfScannedDevices->numberOfDevices++], &pstlhBTRCore->stScannedDevicesArr[i], sizeof (
stBTRCoreBTDevice));
3532 BTRCORELOG_TRACE (
"Copied scanned details of %d devices\n", pListOfScannedDevices->numberOfDevices);
3534 return enBTRCoreSuccess;
3540 tBTRCoreHandle hBTRCore,
3541 tBTRCoreDevId aBTRCoreDevId
3544 const char* pDeviceAddress = NULL;
3550 char lpcBtVersion[BTRCORE_STR_LEN] = {
'\0'};
3553 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3554 return enBTRCoreNotInitialized;
3556 else if (aBTRCoreDevId < 0) {
3557 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3558 return enBTRCoreInvalidArg;
3563 if (aBTRCoreDevId < BTRCORE_MAX_NUM_BT_DEVICES) {
3564 pstScannedDev = &pstlhBTRCore->stScannedDevicesArr[aBTRCoreDevId];
3567 for (i32LoopIdx = 0; i32LoopIdx < pstlhBTRCore->numOfScannedDevices; i32LoopIdx++) {
3568 if (aBTRCoreDevId == pstlhBTRCore->stScannedDevicesArr[i32LoopIdx].tDeviceId) {
3569 pstScannedDev = &pstlhBTRCore->stScannedDevicesArr[i32LoopIdx];
3577 pDeviceAddress = pstScannedDev->pcDeviceAddress;
3580 if (!pstScannedDev || !pDeviceAddress || !strlen(pDeviceAddress)) {
3581 BTRCORELOG_ERROR (
"Failed to find device in Scanned devices list\n");
3582 return enBTRCoreDeviceNotFound;
3585 BTRCORELOG_DEBUG (
"We will pair %s\n", pstScannedDev->pcDeviceName);
3586 BTRCORELOG_DEBUG (
"We will address %s\n", pDeviceAddress);
3588 if ((pstScannedDev->enDeviceType == enBTRCore_DC_HID_Keyboard) ||
3589 (pstScannedDev->enDeviceType == enBTRCore_DC_HID_Mouse) ||
3590 (pstScannedDev->enDeviceType == enBTRCore_DC_HID_MouseKeyBoard) ||
3592 (pstScannedDev->enDeviceType == enBTRCore_DC_HID_Joystick) ||
3593 (pstScannedDev->enDeviceType == enBTRCore_DC_HID_GamePad)) {
3595 if ((pstScannedDev->enDeviceType == enBTRCore_DC_HID_GamePad) &&
3597 && (!strncmp(lpcBtVersion,
"Bluez-5.48", strlen(
"Bluez-5.48")))) {
3598 BTRCORELOG_DEBUG (
" sky devices Bluez-5.48 \n");
3599 lunBtOpAdapProp.enBtAdapterProp = enBTAdPropPairable;
3601 if (
BtrCore_BTSetProp(pstlhBTRCore->connHdl, pstlhBTRCore->curAdapterPath, enBTAdapter, lunBtOpAdapProp, &ispairable)) {
3602 BTRCORELOG_ERROR (
"Set Adapter Property enBTAdPropPairable - FAILED\n");
3603 return enBTRCoreFailure;
3606 BTRCORELOG_DEBUG (
" Non sky devices or non HID Gamepad\n");
3608 BTRCORELOG_DEBUG (
"We will do a Async Pairing for the HID Devices\n");
3609 pairingOp = enBTAdpOpCreatePairedDevASync;
3613 pstlhBTRCore->curAdapterPath,
3614 pstlhBTRCore->agentPath,
3617 BTRCORELOG_ERROR (
"Failed to pair a device\n");
3618 return enBTRCorePairingFailed;
3622 btrCore_PopulateListOfPairedDevices(pstlhBTRCore, pstlhBTRCore->curAdapterPath);
3624 BTRCORELOG_INFO (
"Pairing Success\n");
3625 return enBTRCoreSuccess;
3631 tBTRCoreHandle hBTRCore,
3632 tBTRCoreDevId aBTRCoreDevId
3636 const char* pDeviceAddress = NULL;
3640 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
3642 enBTRCoreDeviceType aenBTRCoreDevType = enBTRCoreUnknown;
3647 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3648 return enBTRCoreNotInitialized;
3650 else if (aBTRCoreDevId < 0) {
3651 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3652 return enBTRCoreInvalidArg;
3657 if ((lenBTRCoreRet = btrCore_GetDeviceInfoKnown(pstlhBTRCore, aBTRCoreDevId, aenBTRCoreDevType,
3658 &lenBTDeviceType, &pstKnownDevice, &lpstKnownDevStInfo, &pDeviceAddress)) != enBTRCoreSuccess) {
3659 BTRCORELOG_ERROR (
"Failed to Get Device Information\n");
3660 return lenBTRCoreRet;
3665 pstlhBTRCore->curAdapterPath,
3666 pstlhBTRCore->agentPath,
3668 enBTAdpOpRemovePairedDev) != 0) {
3669 BTRCORELOG_ERROR (
"Failed to unpair a device\n");
3670 return enBTRCorePairingFailed;
3674 btrCore_RemoveDeviceFromKnownDevicesArr(pstlhBTRCore, aBTRCoreDevId);
3677 btrCore_PopulateListOfPairedDevices(pstlhBTRCore, pstlhBTRCore->curAdapterPath);
3681 if (btrCore_GetScannedDeviceAddress(pstlhBTRCore, aBTRCoreDevId)) {
3682 lenBTRCoreRet = btrCore_RemoveDeviceFromScannedDevicesArr (pstlhBTRCore, aBTRCoreDevId, &pstScannedDevice);
3684 if (!(enBTRCoreSuccess == lenBTRCoreRet && pstScannedDevice.tDeviceId)) {
3685 BTRCORELOG_ERROR (
"Remove device %lld from Scanned List Failed!\n", aBTRCoreDevId);
3689 BTRCORELOG_INFO (
"UnPairing Success\n");
3690 return enBTRCoreSuccess;
3696 tBTRCoreHandle hBTRCore,
3703 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3704 return enBTRCoreNotInitialized;
3706 else if (!pListOfDevices) {
3707 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3708 return enBTRCoreInvalidArg;
3713 if (btrCore_PopulateListOfPairedDevices(pstlhBTRCore, pstlhBTRCore->curAdapterPath) == enBTRCoreSuccess) {
3714 pListOfDevices->numberOfDevices = pstlhBTRCore->numOfPairedDevices;
3715 for (i32DevIdx = 0; i32DevIdx < pListOfDevices->numberOfDevices; i32DevIdx++) {
3716 memcpy (&pListOfDevices->devices[i32DevIdx], &pstlhBTRCore->stKnownDevicesArr[i32DevIdx],
sizeof(
stBTRCoreBTDevice));
3719 return enBTRCoreSuccess;
3722 return enBTRCoreFailure;
3728 tBTRCoreHandle hBTRCore,
3729 tBTRCoreDevId aBTRCoreDevId
3735 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3736 return enBTRCoreNotInitialized;
3740 pstScannedDevice = &pstlhBTRCore->stScannedDevicesArr[aBTRCoreDevId];
3742 BTRCORELOG_DEBUG (
" We will try to find %s\n"
3744 pstlhBTRCore->stScannedDevicesArr[aBTRCoreDevId].pcDeviceName,
3745 pstlhBTRCore->stScannedDevicesArr[aBTRCoreDevId].pcDeviceAddress);
3748 pstlhBTRCore->curAdapterPath,
3749 pstlhBTRCore->agentPath,
3750 pstScannedDevice->pcDeviceAddress,
3751 enBTAdpOpFindPairedDev) < 0) {
3753 return enBTRCoreFailure;
3756 return enBTRCoreSuccess;
3763 tBTRCoreHandle hBTRCore,
3764 tBTRCoreDevId aBTRCoreDevId,
3771 const char* pDeviceAddress = NULL;
3775 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
3777 enBTRCoreDeviceType aenBTRCoreDevType = enBTRCoreUnknown;
3780 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3781 return enBTRCoreNotInitialized;
3787 if ((lenBTRCoreRet = btrCore_GetDeviceInfoKnown(pstlhBTRCore, aBTRCoreDevId, aenBTRCoreDevType,
3788 &lenBTDeviceType, &pstKnownDevice, &lpstKnownDevStInfo, &pDeviceAddress)) != enBTRCoreSuccess) {
3789 BTRCORELOG_ERROR (
"Failed to Get Device Information\n");
3790 return lenBTRCoreRet;
3793 BTRCORELOG_INFO (
"Checking for service %s on %s\n", UUID, pDeviceAddress);
3796 return enBTRCoreFailure;
3799 return enBTRCoreSuccess;
3805 tBTRCoreHandle hBTRCore,
3806 tBTRCoreDevId aBTRCoreDevId,
3811 const char* lpcBTRCoreBTDevicePath = NULL;
3815 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
3817 enBTRCoreDeviceType aenBTRCoreDevType = enBTRCoreUnknown;
3818 unsigned int ui32LoopIdx = 0;
3824 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3825 return enBTRCoreNotInitialized;
3827 else if ((!pProfileList) || (!aBTRCoreDevId)) {
3828 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3829 return enBTRCoreInvalidArg;
3835 if ((lenBTRCoreRet = btrCore_GetDeviceInfoKnown(pstlhBTRCore, aBTRCoreDevId, aenBTRCoreDevType,
3836 &lenBTDeviceType, &lpstBTRCoreBTDevice, &lpstBTRCoreDevStateInfo, &lpcBTRCoreBTDevicePath)) != enBTRCoreSuccess) {
3837 BTRCORELOG_ERROR (
"Failed to Get Device Information\n");
3838 return lenBTRCoreRet;
3848 return enBTRCoreFailure;
3851 BTRCORELOG_INFO (
"Successfully received the supported services... \n");
3853 pProfileList->numberOfService = profileList.numberOfService;
3854 for (ui32LoopIdx = 0; ui32LoopIdx < profileList.numberOfService; ui32LoopIdx++) {
3855 pProfileList->profile[ui32LoopIdx].uuid_value = profileList.profile[ui32LoopIdx].uuid_value;
3856 strncpy (pProfileList->profile[ui32LoopIdx].profile_name, profileList.profile[ui32LoopIdx].profile_name, 30);
3859 return enBTRCoreSuccess;
3865 tBTRCoreHandle hBTRCore,
3866 tBTRCoreDevId aBTRCoreDevId
3869 const char* pDeviceMac = NULL;
3874 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3875 return enBTRCoreNotInitialized;
3877 else if (aBTRCoreDevId < 0) {
3878 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3879 return enBTRCoreInvalidArg;
3884 if (!pstlhBTRCore->numOfPairedDevices) {
3885 BTRCORELOG_DEBUG (
"Possibly the list is not populated; like booted and connecting\n");
3887 btrCore_PopulateListOfPairedDevices(pstlhBTRCore, pstlhBTRCore->curAdapterPath);
3890 if (!pstlhBTRCore->numOfPairedDevices) {
3891 BTRCORELOG_ERROR (
"There is no device paried for this adapter\n");
3892 return enBTRCoreFailure;
3895 if (aBTRCoreDevId < BTRCORE_MAX_NUM_BT_DEVICES) {
3896 pstKnownDevice = &pstlhBTRCore->stKnownDevicesArr[aBTRCoreDevId];
3897 pDeviceMac = pstKnownDevice->pcDeviceAddress;
3900 pDeviceMac = btrCore_GetKnownDeviceMac(pstlhBTRCore, aBTRCoreDevId);
3904 if (!pDeviceMac || !strlen(pDeviceMac)) {
3905 BTRCORELOG_ERROR (
"Failed to find device in paired devices list\n");
3906 return enBTRCoreDeviceNotFound;
3911 BTRCORELOG_ERROR (
"Device NOT CONNECTABLE\n");
3912 return enBTRCoreFailure;
3915 BTRCORELOG_INFO (
"Device CONNECTABLE\n");
3916 return enBTRCoreSuccess;
3922 tBTRCoreHandle hBTRCore,
3923 tBTRCoreDevId aBTRCoreDevId,
3924 enBTRCoreDeviceType aenBTRCoreDevType
3927 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
3931 const char* lpcBTRCoreBTDevicePath = NULL;
3932 const char* lpcBTRCoreBTDeviceName = NULL;
3936 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
3937 return enBTRCoreNotInitialized;
3939 else if (aBTRCoreDevId < 0) {
3940 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
3941 return enBTRCoreInvalidArg;
3946 if ((lenBTRCoreRet = btrCore_GetDeviceInfo(pstlhBTRCore, aBTRCoreDevId, aenBTRCoreDevType,
3947 &lenBTDeviceType, &lpstBTRCoreBTDevice, &lpstBTRCoreDevStateInfo,
3948 &lpcBTRCoreBTDevicePath, &lpcBTRCoreBTDeviceName)) != enBTRCoreSuccess) {
3949 BTRCORELOG_ERROR (
"Failed to Get Device Information - %llu\n", aBTRCoreDevId);
3950 return lenBTRCoreRet;
3954 if ((lenBTDeviceType == enBTDevHID) &&
3955 strstr(lpcBTRCoreBTDeviceName,
"Xbox")) {
3957 BTRCORELOG_ERROR (
"Failed to Disable ERTM\n");
3965 BTRCORELOG_ERROR (
"Connect to device failed - %llu\n", aBTRCoreDevId);
3966 return enBTRCoreFailure;
3969 BTRCORELOG_INFO (
"Connected to device %s Successfully. = %llu\n", lpcBTRCoreBTDeviceName, aBTRCoreDevId);
3973 lpstBTRCoreBTDevice->bDeviceConnected =
TRUE;
3974 if ((lpstBTRCoreDevStateInfo->eDevicePrevState != enBTRCoreDevStConnected) &&
3975 (lpstBTRCoreDevStateInfo->eDeviceCurrState != enBTRCoreDevStPlaying)) {
3976 lpstBTRCoreDevStateInfo->eDevicePrevState = lpstBTRCoreDevStateInfo->eDeviceCurrState;
3979 if ((lpstBTRCoreDevStateInfo->eDeviceCurrState != enBTRCoreDevStConnected) &&
3980 (lpstBTRCoreDevStateInfo->eDeviceCurrState != enBTRCoreDevStPlaying) ) {
3981 lpstBTRCoreDevStateInfo->eDeviceCurrState = enBTRCoreDevStConnecting;
3983 lenBTRCoreRet = enBTRCoreSuccess;
3987 BTRCORELOG_DEBUG (
"Ret - %d - %llu\n", lenBTRCoreRet, aBTRCoreDevId);
3988 return enBTRCoreSuccess;
3994 tBTRCoreHandle hBTRCore,
3995 tBTRCoreDevId aBTRCoreDevId,
3996 enBTRCoreDeviceType aenBTRCoreDevType
3999 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
4003 const char* lpcBTRCoreBTDevicePath = NULL;
4004 const char* lpcBTRCoreBTDeviceName = NULL;
4008 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
4009 return enBTRCoreNotInitialized;
4011 else if (aBTRCoreDevId < 0) {
4012 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
4013 return enBTRCoreInvalidArg;
4018 if ((lenBTRCoreRet = btrCore_GetDeviceInfo(pstlhBTRCore, aBTRCoreDevId, aenBTRCoreDevType,
4019 &lenBTDeviceType, &lpstBTRCoreBTDevice, &lpstBTRCoreDevStateInfo,
4020 &lpcBTRCoreBTDevicePath, &lpcBTRCoreBTDeviceName)) != enBTRCoreSuccess) {
4021 BTRCORELOG_ERROR (
"Failed to Get Device Information - %llu\n", aBTRCoreDevId);
4022 return lenBTRCoreRet;
4029 BTRCORELOG_ERROR (
"DisConnect from device failed - %llu\n", aBTRCoreDevId);
4030 return enBTRCoreFailure;
4033 BTRCORELOG_INFO (
"DisConnected from device %s Successfully.\n", lpcBTRCoreBTDeviceName);
4036 lpstBTRCoreBTDevice->bDeviceConnected = FALSE;
4038 if (lpstBTRCoreDevStateInfo->eDeviceCurrState != enBTRCoreDevStDisconnected &&
4039 lpstBTRCoreDevStateInfo->eDeviceCurrState != enBTRCoreDevStLost) {
4040 lpstBTRCoreDevStateInfo->eDevicePrevState = lpstBTRCoreDevStateInfo->eDeviceCurrState;
4041 lpstBTRCoreDevStateInfo->eDeviceCurrState = enBTRCoreDevStDisconnecting;
4043 lenBTRCoreRet = enBTRCoreSuccess;
4047 if ((lenBTDeviceType == enBTDevHID) &&
4048 strstr(lpcBTRCoreBTDeviceName,
"Xbox")) {
4050 BTRCORELOG_ERROR (
"Failed to Enable ERTM\n");
4055 BTRCORELOG_DEBUG (
"Ret - %d - %llu\n", lenBTRCoreRet, aBTRCoreDevId);
4056 return enBTRCoreSuccess;
4062 tBTRCoreHandle hBTRCore,
4063 tBTRCoreDevId aBTRCoreDevId,
4064 enBTRCoreDeviceType aenBTRCoreDevType
4067 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
4071 const char* lpcBTRCoreBTDevicePath = NULL;
4072 const char* lpcBTRCoreBTDeviceName = NULL;
4076 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
4077 return enBTRCoreNotInitialized;
4079 else if (aBTRCoreDevId < 0) {
4080 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
4081 return enBTRCoreInvalidArg;
4086 if ((lenBTRCoreRet = btrCore_GetDeviceInfo(pstlhBTRCore, aBTRCoreDevId, aenBTRCoreDevType,
4087 &lenBTDeviceType, &lpstBTRCoreBTDevice, &lpstBTRCoreDevStateInfo,
4088 &lpcBTRCoreBTDevicePath, &lpcBTRCoreBTDeviceName)) != enBTRCoreSuccess) {
4089 BTRCORELOG_ERROR (
"Failed to Get Device Information\n");
4090 return lenBTRCoreRet;
4094 (void)lenBTDeviceType;
4096 if ((lpstBTRCoreDevStateInfo->eDeviceCurrState == enBTRCoreDevStConnected) ||
4097 (lpstBTRCoreDevStateInfo->eDeviceCurrState == enBTRCoreDevStPlaying)) {
4098 BTRCORELOG_DEBUG (
"enBTRCoreDevStConnected = %s\n", lpcBTRCoreBTDeviceName);
4099 lenBTRCoreRet = enBTRCoreSuccess;
4102 lenBTRCoreRet = enBTRCoreFailure;
4105 BTRCORELOG_DEBUG (
"Ret - %d : CurrState - %d\n", lenBTRCoreRet, lpstBTRCoreDevStateInfo->eDeviceCurrState);
4106 return lenBTRCoreRet;
4112 tBTRCoreHandle hBTRCore,
4113 tBTRCoreDevId aBTRCoreDevId,
4114 enBTRCoreDeviceType aenBTRCoreDevType
4117 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
4121 const char* lpcBTRCoreBTDevicePath = NULL;
4122 const char* lpcBTRCoreBTDeviceName = NULL;
4126 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
4127 return enBTRCoreNotInitialized;
4129 else if (aBTRCoreDevId < 0) {
4130 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
4131 return enBTRCoreInvalidArg;
4136 if ((lenBTRCoreRet = btrCore_GetDeviceInfo(pstlhBTRCore, aBTRCoreDevId, aenBTRCoreDevType,
4137 &lenBTDeviceType, &lpstBTRCoreBTDevice, &lpstBTRCoreDevStateInfo,
4138 &lpcBTRCoreBTDevicePath, &lpcBTRCoreBTDeviceName)) != enBTRCoreSuccess) {
4139 BTRCORELOG_ERROR (
"Failed to Get Device Information\n");
4140 return lenBTRCoreRet;
4144 (void)lenBTDeviceType;
4146 if ((lpstBTRCoreDevStateInfo->eDeviceCurrState == enBTRCoreDevStDisconnected) ||
4147 (lpstBTRCoreDevStateInfo->eDeviceCurrState == enBTRCoreDevStLost)) {
4148 BTRCORELOG_DEBUG (
"enBTRCoreDevStDisconnected = %s\n", lpcBTRCoreBTDeviceName);
4149 lenBTRCoreRet = enBTRCoreSuccess;
4152 lenBTRCoreRet = enBTRCoreFailure;
4155 BTRCORELOG_DEBUG (
"Ret - %d : CurrState - %d\n", lenBTRCoreRet, lpstBTRCoreDevStateInfo->eDeviceCurrState);
4156 return lenBTRCoreRet;
4162 tBTRCoreHandle hBTRCore,
4163 tBTRCoreDevId aBTRCoreDevId,
4164 enBTRCoreDeviceType* apenBTRCoreDevTy,
4165 enBTRCoreDeviceClass* apenBTRCoreDevCl
4172 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
4173 return enBTRCoreNotInitialized;
4175 else if (aBTRCoreDevId < 0) {
4176 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
4177 return enBTRCoreInvalidArg;
4179 else if (!apenBTRCoreDevTy || !apenBTRCoreDevCl) {
4180 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
4181 return enBTRCoreInvalidArg;
4187 if (pstlhBTRCore->numOfPairedDevices) {
4188 if (aBTRCoreDevId < BTRCORE_MAX_NUM_BT_DEVICES) {
4189 pstBTDevice = &pstlhBTRCore->stKnownDevicesArr[aBTRCoreDevId];
4192 for (i32LoopIdx = 0; i32LoopIdx < pstlhBTRCore->numOfPairedDevices; i32LoopIdx++) {
4193 if (aBTRCoreDevId == pstlhBTRCore->stKnownDevicesArr[i32LoopIdx].tDeviceId) {
4194 pstBTDevice = &pstlhBTRCore->stKnownDevicesArr[i32LoopIdx];
4202 if (!pstBTDevice && pstlhBTRCore->numOfScannedDevices) {
4203 if (aBTRCoreDevId < BTRCORE_MAX_NUM_BT_DEVICES) {
4204 pstBTDevice = &pstlhBTRCore->stScannedDevicesArr[aBTRCoreDevId];
4207 for (i32LoopIdx = 0; i32LoopIdx < pstlhBTRCore->numOfScannedDevices; i32LoopIdx++) {
4208 if (aBTRCoreDevId == pstlhBTRCore->stScannedDevicesArr[i32LoopIdx].tDeviceId) {
4209 pstBTDevice = &pstlhBTRCore->stScannedDevicesArr[i32LoopIdx];
4218 *apenBTRCoreDevTy = enBTRCoreUnknown;
4219 *apenBTRCoreDevCl = enBTRCore_DC_Unknown;
4220 return enBTRCoreFailure;
4224 *apenBTRCoreDevCl = pstBTDevice->enDeviceType;
4225 *apenBTRCoreDevTy = btrCore_MapDevClassToDevType(pstBTDevice->enDeviceType);
4227 return enBTRCoreSuccess;
4233 tBTRCoreHandle hBTRCore,
4234 tBTRCoreDevId aBTRCoreDevId,
4235 enBTRCoreDeviceType aenBTRCoreDevType,
4240 const char* pDeviceAddress = NULL;
4244 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
4247 unsigned int ui32AVMCodecInfoSize = 0;
4251 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
4252 return enBTRCoreNotInitialized;
4254 else if ((aBTRCoreDevId < 0) || !apstBTRCoreDevMediaInfo || !apstBTRCoreDevMediaInfo->pstBtrCoreDevMCodecInfo) {
4255 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
4256 return enBTRCoreInvalidArg;
4262 if ((lenBTRCoreRet = btrCore_GetDeviceInfoKnown(pstlhBTRCore, aBTRCoreDevId, aenBTRCoreDevType,
4263 &lenBTDeviceType, &pstKnownDevice, &lpstKnownDevStInfo, &pDeviceAddress)) != enBTRCoreSuccess) {
4264 BTRCORELOG_ERROR (
"Failed to Get Device Information\n");
4265 return lenBTRCoreRet;
4269 BTRCORELOG_INFO (
" We will get Media Info for %s - DevTy %d\n", pDeviceAddress, lenBTDeviceType);
4271 switch (lenBTDeviceType) {
4272 case enBTDevAudioSink:
4273 lstBtrCoreMediaInfo.eBtrCoreAVMFlow = eBTRCoreAVMediaFlowOut;
4275 case enBTDevAudioSource:
4276 lstBtrCoreMediaInfo.eBtrCoreAVMFlow = eBTRCoreAVMediaFlowIn;
4278 case enBTDevHFPHeadset:
4279 lstBtrCoreMediaInfo.eBtrCoreAVMFlow = eBTRCoreAVMediaFlowInOut;
4281 case enBTDevHFPAudioGateway:
4282 lstBtrCoreMediaInfo.eBtrCoreAVMFlow = eBTRCoreAVMediaFlowInOut;
4285 lstBtrCoreMediaInfo.eBtrCoreAVMFlow = eBTRCoreAVMediaFlowUnknown;
4287 case enBTDevUnknown:
4288 lstBtrCoreMediaInfo.eBtrCoreAVMFlow = eBTRCoreAVMediaFlowUnknown;
4291 lstBtrCoreMediaInfo.eBtrCoreAVMFlow = eBTRCoreAVMediaFlowUnknown;
4299 lstBtrCoreMediaInfo.eBtrCoreAVMType = eBTRCoreAVMTypeUnknown;
4300 if (!(lstBtrCoreMediaInfo.pstBtrCoreAVMCodecInfo = g_malloc0(ui32AVMCodecInfoSize))) {
4301 BTRCORELOG_ERROR (
"AVMedia_GetCurMediaInfo - Unable to alloc Memory\n");
4302 return lenBTRCoreRet;
4308 BTRCORELOG_ERROR (
"AVMedia_GetCurMediaInfo ERROR occurred\n");
4309 g_free(lstBtrCoreMediaInfo.pstBtrCoreAVMCodecInfo);
4310 return lenBTRCoreRet;
4313 switch (lstBtrCoreMediaInfo.eBtrCoreAVMType) {
4314 case eBTRCoreAVMTypePCM:
4315 apstBTRCoreDevMediaInfo->eBtrCoreDevMType = eBTRCoreDevMediaTypePCM;
4317 case eBTRCoreAVMTypeSBC: {
4321 apstBTRCoreDevMediaInfo->eBtrCoreDevMType = eBTRCoreDevMediaTypeSBC;
4323 switch (lpstBtrCoreAVMSbcInfo->eAVMAChan) {
4324 case eBTRCoreAVMAChanMono:
4325 lapstBtrCoreDevMCodecInfo->eDevMAChan = eBTRCoreDevMediaAChanMono;
4327 case eBTRCoreAVMAChanDualChannel:
4328 lapstBtrCoreDevMCodecInfo->eDevMAChan = eBTRCoreDevMediaAChanDualChannel;
4330 case eBTRCoreAVMAChanStereo:
4331 lapstBtrCoreDevMCodecInfo->eDevMAChan = eBTRCoreDevMediaAChanStereo;
4333 case eBTRCoreAVMAChanJointStereo:
4334 lapstBtrCoreDevMCodecInfo->eDevMAChan = eBTRCoreDevMediaAChanJointStereo;
4336 case eBTRCoreAVMAChan5_1:
4337 lapstBtrCoreDevMCodecInfo->eDevMAChan = eBTRCoreDevMediaAChan5_1;
4339 case eBTRCoreAVMAChan7_1:
4340 lapstBtrCoreDevMCodecInfo->eDevMAChan = eBTRCoreDevMediaAChan7_1;
4342 case eBTRCoreAVMAChanUnknown:
4344 lapstBtrCoreDevMCodecInfo->eDevMAChan = eBTRCoreDevMediaAChanUnknown;
4348 lapstBtrCoreDevMCodecInfo->ui32DevMSFreq = lpstBtrCoreAVMSbcInfo->ui32AVMSFreq;
4349 lapstBtrCoreDevMCodecInfo->ui8DevMSbcAllocMethod = lpstBtrCoreAVMSbcInfo->ui8AVMSbcAllocMethod;
4350 lapstBtrCoreDevMCodecInfo->ui8DevMSbcSubbands = lpstBtrCoreAVMSbcInfo->ui8AVMSbcSubbands;
4351 lapstBtrCoreDevMCodecInfo->ui8DevMSbcBlockLength = lpstBtrCoreAVMSbcInfo->ui8AVMSbcBlockLength;
4352 lapstBtrCoreDevMCodecInfo->ui8DevMSbcMinBitpool = lpstBtrCoreAVMSbcInfo->ui8AVMSbcMinBitpool;
4353 lapstBtrCoreDevMCodecInfo->ui8DevMSbcMaxBitpool = lpstBtrCoreAVMSbcInfo->ui8AVMSbcMaxBitpool;
4354 lapstBtrCoreDevMCodecInfo->ui16DevMSbcFrameLen = lpstBtrCoreAVMSbcInfo->ui16AVMSbcFrameLen;
4355 lapstBtrCoreDevMCodecInfo->ui16DevMSbcBitrate = lpstBtrCoreAVMSbcInfo->ui16AVMSbcBitrate;
4359 case eBTRCoreAVMTypeMPEG:
4360 apstBTRCoreDevMediaInfo->eBtrCoreDevMType = eBTRCoreDevMediaTypeMPEG;
4362 case eBTRCoreAVMTypeAAC: {
4366 apstBTRCoreDevMediaInfo->eBtrCoreDevMType = eBTRCoreDevMediaTypeAAC;
4368 switch (lpstBtrCoreAVMAacInfo->eAVMAChan) {
4369 case eBTRCoreAVMAChanMono:
4370 lapstBtrCoreDevMCodecInfo->eDevMAChan = eBTRCoreDevMediaAChanMono;
4372 case eBTRCoreAVMAChanDualChannel:
4373 lapstBtrCoreDevMCodecInfo->eDevMAChan = eBTRCoreDevMediaAChanDualChannel;
4375 case eBTRCoreAVMAChanStereo:
4376 lapstBtrCoreDevMCodecInfo->eDevMAChan = eBTRCoreDevMediaAChanStereo;
4378 case eBTRCoreAVMAChanJointStereo:
4379 lapstBtrCoreDevMCodecInfo->eDevMAChan = eBTRCoreDevMediaAChanJointStereo;
4381 case eBTRCoreAVMAChan5_1:
4382 lapstBtrCoreDevMCodecInfo->eDevMAChan = eBTRCoreDevMediaAChan5_1;
4384 case eBTRCoreAVMAChan7_1:
4385 lapstBtrCoreDevMCodecInfo->eDevMAChan = eBTRCoreDevMediaAChan7_1;
4387 case eBTRCoreAVMAChanUnknown:
4389 lapstBtrCoreDevMCodecInfo->eDevMAChan = eBTRCoreDevMediaAChanUnknown;
4393 lapstBtrCoreDevMCodecInfo->ui32DevMSFreq = lpstBtrCoreAVMAacInfo->ui32AVMSFreq;
4394 lapstBtrCoreDevMCodecInfo->ui8DevMMpegCrc = lpstBtrCoreAVMAacInfo->ui8AVMMpegCrc;
4395 lapstBtrCoreDevMCodecInfo->ui8DevMMpegLayer = lpstBtrCoreAVMAacInfo->ui8AVMMpegLayer;
4396 lapstBtrCoreDevMCodecInfo->ui8DevMMpegMpf = lpstBtrCoreAVMAacInfo->ui8AVMMpegMpf;
4397 lapstBtrCoreDevMCodecInfo->ui8DevMMpegRfa = lpstBtrCoreAVMAacInfo->ui8AVMMpegRfa;
4398 lapstBtrCoreDevMCodecInfo->ui16DevMMpegFrameLen = lpstBtrCoreAVMAacInfo->ui16AVMMpegFrameLen;
4399 lapstBtrCoreDevMCodecInfo->ui16DevMMpegBitrate = lpstBtrCoreAVMAacInfo->ui16AVMMpegBitrate;
4403 case eBTRCoreAVMTypeUnknown:
4405 apstBTRCoreDevMediaInfo->eBtrCoreDevMType = eBTRCoreDevMediaTypeUnknown;
4409 g_free(lstBtrCoreMediaInfo.pstBtrCoreAVMCodecInfo);
4410 return enBTRCoreSuccess;
4416 tBTRCoreHandle hBTRCore,
4417 tBTRCoreDevId aBTRCoreDevId,
4418 enBTRCoreDeviceType aenBTRCoreDevType,
4421 int* aidataWriteMTU,
4422 unsigned int* apui32Delay
4426 const char* pDeviceAddress = NULL;
4430 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
4431 enBTRCoreDeviceState lenDevPrevState = enBTRCoreDevStUnknown;
4432 enBTRCoreDeviceState lenDevCurrState = enBTRCoreDevStUnknown;
4435 int lidataReadMTU = 0;
4436 int lidataWriteMTU = 0;
4437 unsigned int ui32Delay = 0xFFFFu;
4441 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
4442 return enBTRCoreNotInitialized;
4444 else if (!aiDataPath || !aidataReadMTU || !aidataWriteMTU || !apui32Delay || (aBTRCoreDevId < 0)) {
4445 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
4446 return enBTRCoreInvalidArg;
4452 if ((lenBTRCoreRet = btrCore_GetDeviceInfoKnown(pstlhBTRCore, aBTRCoreDevId, aenBTRCoreDevType,
4453 &lenBTDeviceType, &pstKnownDevice, &lpstKnownDevStInfo, &pDeviceAddress)) != enBTRCoreSuccess) {
4454 BTRCORELOG_ERROR (
"Failed to Get Device Information\n");
4455 return lenBTRCoreRet;
4458 lenDevPrevState = lpstKnownDevStInfo->eDevicePrevState;
4459 lenDevCurrState = lpstKnownDevStInfo->eDeviceCurrState;
4460 lpstKnownDevStInfo->eDevicePrevState = lpstKnownDevStInfo->eDeviceCurrState;
4461 if (lpstKnownDevStInfo->eDeviceCurrState != enBTRCoreDevStPlaying) {
4462 lpstKnownDevStInfo->eDeviceCurrState = enBTRCoreDevStPlaying;
4465 BTRCORELOG_INFO (
" We will Acquire Data Path for %s\n", pDeviceAddress);
4466 if (
BTRCore_AVMedia_AcquireDataPath(pstlhBTRCore->avMediaHdl, pDeviceAddress, &liDataPath, &lidataReadMTU, &lidataWriteMTU, &ui32Delay) != enBTRCoreSuccess) {
4467 BTRCORELOG_ERROR (
"AVMedia_AcquireDataPath ERROR occurred\n");
4468 lpstKnownDevStInfo->eDevicePrevState = lenDevPrevState;
4469 lpstKnownDevStInfo->eDeviceCurrState = lenDevCurrState;
4470 return enBTRCoreFailure;
4473 *aiDataPath = liDataPath;
4474 *aidataReadMTU = lidataReadMTU;
4475 *aidataWriteMTU = lidataWriteMTU;
4476 *apui32Delay = ui32Delay;
4478 return enBTRCoreSuccess;
4484 tBTRCoreHandle hBTRCore,
4485 tBTRCoreDevId aBTRCoreDevId,
4486 enBTRCoreDeviceType aenBTRCoreDevType
4490 const char* pDeviceAddress = NULL;
4494 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
4498 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
4499 return enBTRCoreNotInitialized;
4501 else if (aBTRCoreDevId < 0) {
4502 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
4503 return enBTRCoreInvalidArg;
4509 if ((lenBTRCoreRet = btrCore_GetDeviceInfoKnown(pstlhBTRCore, aBTRCoreDevId, aenBTRCoreDevType,
4510 &lenBTDeviceType, &pstKnownDevice, &lpstKnownDevStInfo, &pDeviceAddress)) != enBTRCoreSuccess) {
4511 BTRCORELOG_ERROR (
"Failed to Get Device Information\n");
4512 return lenBTRCoreRet;
4516 (void)lenBTDeviceType;
4518 BTRCORELOG_INFO (
" We will Release Data Path for %s\n", pDeviceAddress);
4523 BTRCORELOG_ERROR (
"AVMedia_ReleaseDataPath ERROR occurred\n");
4524 return enBTRCoreFailure;
4527 return enBTRCoreSuccess;
4533 tBTRCoreHandle hBTRCore,
4534 unsigned int aui32AckTOutms
4539 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
4540 return enBTRCoreNotInitialized;
4546 BTRCORELOG_ERROR (
"Failed to SetDevDataAckTimeout\n");
4547 return enBTRCoreFailure;
4550 return enBTRCoreSuccess;
4556 tBTRCoreHandle hBTRCore,
4557 tBTRCoreDevId aBTRCoreDevId,
4558 enBTRCoreDeviceType aenBTRCoreDevType,
4559 enBTRCoreMediaCtrl aenBTRCoreMediaCtrl,
4564 const char* pDeviceAddress = NULL;
4568 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
4570 BOOLEAN lbBTDeviceConnected = FALSE;
4571 enBTRCoreAVMediaCtrl lenBTRCoreAVMediaCtrl = 0;
4572 eBTRCoreAVMediaFlow lenBTRCoreAVMediaFlow = eBTRCoreAVMediaFlowUnknown;
4577 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
4578 return enBTRCoreNotInitialized;
4580 else if (aBTRCoreDevId < 0) {
4581 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
4582 return enBTRCoreInvalidArg;
4588 if ((lenBTRCoreRet = btrCore_GetDeviceInfoKnown(pstlhBTRCore, aBTRCoreDevId, aenBTRCoreDevType,
4589 &lenBTDeviceType, &pstKnownDevice, &lpstKnownDevStInfo, &pDeviceAddress)) != enBTRCoreSuccess) {
4590 BTRCORELOG_ERROR (
"Failed to Get Device Information\n");
4591 return lenBTRCoreRet;
4594 if ((lbBTDeviceConnected = pstKnownDevice->bDeviceConnected) == FALSE) {
4595 BTRCORELOG_ERROR (
"Device is not Connected!!!\n");
4596 return enBTRCoreFailure;
4600 switch (lenBTDeviceType) {
4601 case enBTDevAudioSink:
4602 lenBTRCoreAVMediaFlow = eBTRCoreAVMediaFlowOut;
4604 case enBTDevAudioSource:
4605 lenBTRCoreAVMediaFlow = eBTRCoreAVMediaFlowIn;
4607 case enBTDevHFPHeadset:
4608 lenBTRCoreAVMediaFlow = eBTRCoreAVMediaFlowInOut;
4610 case enBTDevHFPAudioGateway:
4611 lenBTRCoreAVMediaFlow = eBTRCoreAVMediaFlowInOut;
4614 lenBTRCoreAVMediaFlow = eBTRCoreAVMediaFlowUnknown;
4616 case enBTDevUnknown:
4617 lenBTRCoreAVMediaFlow = eBTRCoreAVMediaFlowUnknown;
4620 lenBTRCoreAVMediaFlow = eBTRCoreAVMediaFlowUnknown;
4624 switch (aenBTRCoreMediaCtrl) {
4625 case enBTRCoreMediaCtrlPlay:
4626 lenBTRCoreAVMediaCtrl = enBTRCoreAVMediaCtrlPlay;
4628 case enBTRCoreMediaCtrlPause:
4629 lenBTRCoreAVMediaCtrl = enBTRCoreAVMediaCtrlPause;
4631 case enBTRCoreMediaCtrlStop:
4632 lenBTRCoreAVMediaCtrl = enBTRCoreAVMediaCtrlStop;
4634 case enBTRCoreMediaCtrlNext:
4635 lenBTRCoreAVMediaCtrl = enBTRCoreAVMediaCtrlNext;
4637 case enBTRCoreMediaCtrlPrevious:
4638 lenBTRCoreAVMediaCtrl = enBTRCoreAVMediaCtrlPrevious;
4640 case enBTRCoreMediaCtrlFastForward:
4641 lenBTRCoreAVMediaCtrl = enBTRCoreAVMediaCtrlFastForward;
4643 case enBTRCoreMediaCtrlRewind:
4644 lenBTRCoreAVMediaCtrl = enBTRCoreAVMediaCtrlRewind;
4646 case enBTRCoreMediaCtrlVolumeUp:
4647 lenBTRCoreAVMediaCtrl = enBTRCoreAVMediaCtrlVolumeUp;
4649 case enBTRCoreMediaCtrlVolumeDown:
4650 lenBTRCoreAVMediaCtrl = enBTRCoreAVMediaCtrlVolumeDown;
4652 case enBTRCoreMediaCtrlEqlzrOff:
4653 lenBTRCoreAVMediaCtrl = enBTRcoreAVMediaCtrlEqlzrOff;
4655 case enBTRCoreMediaCtrlEqlzrOn:
4656 lenBTRCoreAVMediaCtrl = enBTRcoreAVMediaCtrlEqlzrOn;
4658 case enBTRCoreMediaCtrlShflOff:
4659 lenBTRCoreAVMediaCtrl = enBTRCoreAVMediaCtrlShflOff;
4661 case enBTRCoreMediaCtrlShflAllTracks:
4662 lenBTRCoreAVMediaCtrl = enBTRCoreAVMediaCtrlShflAllTracks;
4664 case enBTRCoreMediaCtrlShflGroup:
4665 lenBTRCoreAVMediaCtrl = enBTRCoreAVMediaCtrlShflGroup;
4667 case enBTRCoreMediaCtrlRptOff:
4668 lenBTRCoreAVMediaCtrl = enBTRCoreAVMediaCtrlRptOff;
4670 case enBTRCoreMediaCtrlRptSingleTrack:
4671 lenBTRCoreAVMediaCtrl = enBTRCoreAVMediaCtrlRptSingleTrack;
4673 case enBTRCoreMediaCtrlRptAllTracks:
4674 lenBTRCoreAVMediaCtrl = enBTRCoreAVMediaCtrlRptAllTracks;
4676 case enBTRCoreMediaCtrlRptGroup:
4677 lenBTRCoreAVMediaCtrl = enBTRCoreAVMediaCtrlRptGroup;
4680 lenBTRCoreAVMediaCtrl = enBTRCoreAVMediaCtrlUnknown;
4684 if (lenBTRCoreAVMediaCtrl == enBTRCoreAVMediaCtrlUnknown) {
4685 BTRCORELOG_ERROR (
"Media Play Control Unknown!\n");
4686 lenBTRCoreRet = enBTRCoreFailure;
4691 if (apstBTRCoreMediaCData != NULL) {
4692 lstBTRCoreAVMCtData.m_mediaAbsTransportVolume = apstBTRCoreMediaCData->m_mediaAbsoluteVolume;
4693 lpstBTRCoreAVMCtData = &lstBTRCoreAVMCtData;
4696 BTRCORELOG_INFO (
" We will Perform Media Control for %s - DevTy %d - Ctrl %d - Flow %d\n", pDeviceAddress, lenBTDeviceType, lenBTRCoreAVMediaCtrl, lenBTRCoreAVMediaFlow);
4699 lenBTRCoreAVMediaCtrl,
4700 lenBTRCoreAVMediaFlow,
4701 lpstBTRCoreAVMCtData)) != enBTRCoreSuccess) {
4702 BTRCORELOG_ERROR (
"Media Play Control Failed!!!\n");
4706 return lenBTRCoreRet;
4711 tBTRCoreHandle hBTRCore,
4712 tBTRCoreDevId aBTRCoreDevId,
4713 enBTRCoreDeviceType aenBTRCoreDevType,
4718 const char* pDeviceAddress = NULL;
4722 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
4724 BOOLEAN lbBTDeviceConnected = FALSE;
4728 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
4729 return enBTRCoreNotInitialized;
4732 if (aBTRCoreDevId < 0) {
4733 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
4734 return enBTRCoreInvalidArg;
4740 if ((lenBTRCoreRet = btrCore_GetDeviceInfoKnown(pstlhBTRCore, aBTRCoreDevId, aenBTRCoreDevType,
4741 &lenBTDeviceType, &pstKnownDevice, &lpstKnownDevStInfo, &pDeviceAddress)) != enBTRCoreSuccess) {
4742 BTRCORELOG_ERROR (
"Failed to Get Device Information\n");
4743 return lenBTRCoreRet;
4746 if ((lbBTDeviceConnected = pstKnownDevice->bDeviceConnected) == FALSE) {
4747 BTRCORELOG_ERROR (
"Device is not Connected!!!\n");
4748 return enBTRCoreFailure;
4755 BTRCORELOG_ERROR (
"AVMedia get media track information Failed!!!\n");
4756 return enBTRCoreFailure;
4759 return enBTRCoreSuccess;
4764 tBTRCoreHandle hBTRCore,
4765 tBTRCoreDevId aBTRCoreDevId,
4766 enBTRCoreDeviceType aenBTRCoreDevType,
4767 tBTRCoreMediaElementId aBtrMediaElementId,
4772 const char* pDeviceAddress = NULL;
4776 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
4778 BOOLEAN lbBTDeviceConnected = FALSE;
4782 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
4783 return enBTRCoreNotInitialized;
4786 if (aBTRCoreDevId < 0) {
4787 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
4788 return enBTRCoreInvalidArg;
4794 if ((lenBTRCoreRet = btrCore_GetDeviceInfoKnown(pstlhBTRCore, aBTRCoreDevId, aenBTRCoreDevType,
4795 &lenBTDeviceType, &pstKnownDevice, &lpstKnownDevStInfo, &pDeviceAddress)) != enBTRCoreSuccess) {
4796 BTRCORELOG_ERROR (
"Failed to Get Device Information\n");
4797 return lenBTRCoreRet;
4800 if ((lbBTDeviceConnected = pstKnownDevice->bDeviceConnected) == FALSE) {
4801 BTRCORELOG_ERROR (
"Device is not Connected!!!\n");
4802 return enBTRCoreFailure;
4810 BTRCORELOG_ERROR (
"AVMedia get media track information Failed!!!\n");
4811 return enBTRCoreFailure;
4814 return enBTRCoreSuccess;
4821 tBTRCoreHandle hBTRCore,
4822 tBTRCoreDevId aBTRCoreDevId,
4823 enBTRCoreDeviceType aenBTRCoreDevType,
4828 const char* pDeviceAddress = NULL;
4832 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
4834 BOOLEAN lbBTDeviceConnected = FALSE;
4838 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
4839 return enBTRCoreNotInitialized;
4842 if (aBTRCoreDevId < 0) {
4843 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
4844 return enBTRCoreInvalidArg;
4850 if ((lenBTRCoreRet = btrCore_GetDeviceInfoKnown(pstlhBTRCore, aBTRCoreDevId, aenBTRCoreDevType,
4851 &lenBTDeviceType, &pstKnownDevice, &lpstKnownDevStInfo, &pDeviceAddress)) != enBTRCoreSuccess) {
4852 BTRCORELOG_ERROR (
"Failed to Get Device Information\n");
4853 return lenBTRCoreRet;
4856 if ((lbBTDeviceConnected = pstKnownDevice->bDeviceConnected) == FALSE) {
4857 BTRCORELOG_ERROR (
"Device is not Connected!!!\n");
4858 return enBTRCoreFailure;
4865 BTRCORELOG_ERROR (
"AVMedia get Media Position Info Failed!!!\n");
4866 return enBTRCoreFailure;
4869 return enBTRCoreSuccess;
4876 tBTRCoreHandle hBTRCore,
4877 tBTRCoreDevId aBTRCoreDevId,
4878 enBTRCoreDeviceType aenBTRCoreDevType,
4879 const char* mediaPropertyKey,
4880 void* mediaPropertyValue
4884 const char* pDeviceAddress = NULL;
4888 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
4890 BOOLEAN lbBTDeviceConnected = FALSE;
4894 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
4895 return enBTRCoreNotInitialized;
4898 if (aBTRCoreDevId < 0) {
4899 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
4900 return enBTRCoreInvalidArg;
4906 if ((lenBTRCoreRet = btrCore_GetDeviceInfoKnown(pstlhBTRCore, aBTRCoreDevId, aenBTRCoreDevType,
4907 &lenBTDeviceType, &pstKnownDevice, &lpstKnownDevStInfo, &pDeviceAddress)) != enBTRCoreSuccess) {
4908 BTRCORELOG_ERROR (
"Failed to Get Device Information\n");
4909 return lenBTRCoreRet;
4912 if ((lbBTDeviceConnected = pstKnownDevice->bDeviceConnected) == FALSE) {
4913 BTRCORELOG_ERROR (
"Device is not Connected!!!\n");
4914 return enBTRCoreFailure;
4921 mediaPropertyValue) != enBTRCoreSuccess) {
4922 BTRCORELOG_ERROR (
"AVMedia get property Failed!!!\n");
4923 return enBTRCoreFailure;
4926 return enBTRCoreSuccess;
4932 tBTRCoreHandle hBTRCore,
4933 tBTRCoreDevId aBTRCoreDevId,
4934 tBTRCoreMediaElementId aBtrMediaElementId,
4935 enBTRCoreDeviceType aenBTRCoreDevType,
4936 eBTRCoreMedElementType aenBTRCoreMedElementType
4940 const char* pDeviceAddress = NULL;
4944 eBTRCoreAVMElementType lAVMediaElementType = eBTRCoreAVMETypeUnknown;
4945 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
4946 char isPlayable = 0;
4949 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
4950 return enBTRCoreNotInitialized;
4953 if (aBTRCoreDevId < 0 || aBtrMediaElementId < 0) {
4954 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
4955 return enBTRCoreInvalidArg;
4961 if ((lenBTRCoreRet = btrCore_GetDeviceInfoKnown(pstlhBTRCore, aBTRCoreDevId, aenBTRCoreDevType,
4962 &lenBTDeviceType, &pstKnownDevice, &lpstKnownDevStInfo, &pDeviceAddress)) != enBTRCoreSuccess) {
4963 BTRCORELOG_ERROR (
"Failed to Get Device Information\n");
4964 return lenBTRCoreRet;
4967 if (pstKnownDevice->bDeviceConnected == FALSE) {
4968 BTRCORELOG_ERROR (
"Device is not Connected!!!\n");
4969 return enBTRCoreFailure;
4972 switch (aenBTRCoreMedElementType) {
4973 case enBTRCoreMedETypeAlbum:
4974 lAVMediaElementType = eBTRCoreAVMETypeAlbum;
4976 case enBTRCoreMedETypeArtist:
4977 lAVMediaElementType = eBTRCoreAVMETypeArtist;
4979 case enBTRCoreMedETypeGenre:
4980 lAVMediaElementType = eBTRCoreAVMETypeGenre;
4982 case enBTRCoreMedETypeCompilation:
4983 lAVMediaElementType = eBTRCoreAVMETypeCompilation;
4985 case enBTRCoreMedETypePlayList:
4986 lAVMediaElementType = eBTRCoreAVMETypePlayList;
4988 case enBTRCoreMedETypeTrackList:
4989 lAVMediaElementType = eBTRCoreAVMETypeTrackList;
4991 case enBTRCoreMedETypeTrack:
4992 lAVMediaElementType = eBTRCoreAVMETypeTrack;
5001 &isPlayable) != enBTRCoreSuccess) {
5002 BTRCORELOG_ERROR (
"Failed to MediaElement's playable state!\n");
5003 return enBTRCoreFailure;
5009 BTRCORELOG_ERROR (
"AVMedia Play Media Track by Element Id(%llu) Failed!!!\n", aBtrMediaElementId);
5010 return enBTRCoreFailure;
5018 lAVMediaElementType) != enBTRCoreSuccess) {
5019 BTRCORELOG_ERROR (
"AVMedia change browser location to %llu Failed!\n", aBtrMediaElementId);
5020 return enBTRCoreFailure;
5024 (void)lAVMediaElementType;
5025 return lenBTRCoreRet;
5031 tBTRCoreHandle hBTRCore,
5032 tBTRCoreDevId aBTRCoreDevId,
5033 tBTRCoreMediaElementId aBtrMediaElementId,
5034 unsigned short aui16BtrMedElementStartIdx,
5035 unsigned short aui16BtrMedElementEndIdx,
5036 enBTRCoreDeviceType aenBTRCoreDevType,
5037 eBTRCoreMedElementType aenBTRCoreMedElementType,
5042 const char* pDeviceAddress = NULL;
5046 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
5050 if (!hBTRCore || !apstMediaElementListInfo) {
5051 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
5052 return enBTRCoreNotInitialized;
5055 if (aBTRCoreDevId < 0 || aBtrMediaElementId < 0) {
5056 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
5057 return enBTRCoreInvalidArg;
5063 if ((lenBTRCoreRet = btrCore_GetDeviceInfoKnown(pstlhBTRCore, aBTRCoreDevId, aenBTRCoreDevType,
5064 &lenBTDeviceType, &pstKnownDevice, &lpstKnownDevStInfo, &pDeviceAddress)) != enBTRCoreSuccess) {
5065 BTRCORELOG_ERROR (
"Failed to Get Device Information\n");
5066 return lenBTRCoreRet;
5069 if (pstKnownDevice->bDeviceConnected == FALSE) {
5070 BTRCORELOG_ERROR (
"Device is not Connected!!!\n");
5071 return enBTRCoreFailure;
5078 aui16BtrMedElementStartIdx,
5079 aui16BtrMedElementEndIdx) != enBTRCoreSuccess) {
5080 BTRCORELOG_ERROR (
"AVMedia Select Media Browser Elements Failed for %llu (%u - %u)!\n", aBtrMediaElementId
5081 , aui16BtrMedElementStartIdx, aui16BtrMedElementEndIdx);
5090 aui16BtrMedElementStartIdx,
5091 aui16BtrMedElementEndIdx,
5092 aenBTRCoreMedElementType,
5093 &lpstAVMediaElementInfoList) != enBTRCoreSuccess) {
5094 BTRCORELOG_ERROR (
"AVMedia Get Media Item List Failed for %llu (%u - %u)!\n", aBtrMediaElementId, aui16BtrMedElementStartIdx, aui16BtrMedElementEndIdx);
5095 return enBTRCoreFailure;
5100 return lenBTRCoreRet;
5105 tBTRCoreHandle hBTRCore,
5106 tBTRCoreDevId aBTRCoreDevId,
5107 tBTRCoreMediaElementId aBtrMediaElementId,
5108 enBTRCoreDeviceType aenBTRCoreDevType,
5109 eBTRCoreMedElementType aenBTRCoreMedElementType
5113 const char* pDeviceAddress = NULL;
5117 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
5118 char isPlayable = 0;
5121 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
5122 return enBTRCoreNotInitialized;
5125 if (aBTRCoreDevId < 0 || aBtrMediaElementId < 0) {
5126 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
5127 return enBTRCoreInvalidArg;
5133 if ((lenBTRCoreRet = btrCore_GetDeviceInfoKnown(pstlhBTRCore, aBTRCoreDevId, aenBTRCoreDevType,
5134 &lenBTDeviceType, &pstKnownDevice, &lpstKnownDevStInfo, &pDeviceAddress)) != enBTRCoreSuccess) {
5135 BTRCORELOG_ERROR (
"Failed to Get Device Information\n");
5136 return lenBTRCoreRet;
5139 if (pstKnownDevice->bDeviceConnected == FALSE) {
5140 BTRCORELOG_ERROR (
"Device is not Connected!!!\n");
5141 return enBTRCoreFailure;
5146 BTRCORELOG_ERROR (
"BTRCore_AVMedia_IsMediaElementPlayable calling !\n");
5150 &isPlayable) != enBTRCoreSuccess) {
5151 BTRCORELOG_ERROR (
"Failed to MediaElement's playable state!\n");
5152 return enBTRCoreFailure;
5158 pDeviceAddress, aBtrMediaElementId)) != enBTRCoreSuccess) {
5159 BTRCORELOG_ERROR (
"AVMedia Set Media Track by Element Id(%llu) Failed!!!\n", aBtrMediaElementId);
5160 return enBTRCoreFailure;
5168 return lenBTRCoreRet;
5174 tBTRCoreHandle hBTRCore,
5175 tBTRCoreDevId aBTRCoreDevId,
5176 const char* apcBTRCoreLEUuid,
5177 enBTRCoreLeProp aenBTRCoreLeProp,
5178 void* apvBTRCorePropValue
5181 if (!hBTRCore || !apcBTRCoreLEUuid || aBTRCoreDevId < 0) {
5182 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
5183 return enBTRCoreInvalidArg;
5188 tBTRCoreDevId ltBTRCoreDevId = 0;
5191 if (aBTRCoreDevId < BTRCORE_MAX_NUM_BT_DEVICES) {
5192 pstScannedDev = &pstlhBTRCore->stScannedDevicesArr[aBTRCoreDevId];
5195 for (i32LoopIdx = 0; i32LoopIdx < pstlhBTRCore->numOfScannedDevices; i32LoopIdx++) {
5196 if (aBTRCoreDevId == pstlhBTRCore->stScannedDevicesArr[i32LoopIdx].tDeviceId) {
5197 pstScannedDev = &pstlhBTRCore->stScannedDevicesArr[i32LoopIdx];
5203 if (pstScannedDev) {
5204 ltBTRCoreDevId = pstScannedDev->tDeviceId;
5207 if (!pstScannedDev || !ltBTRCoreDevId) {
5208 BTRCORELOG_ERROR (
"Failed to find device in Scanned devices list\n");
5209 return enBTRCoreDeviceNotFound;
5212 BTRCORELOG_DEBUG (
"Get LE Property for Device : %s\n", pstScannedDev->pcDeviceName);
5213 BTRCORELOG_DEBUG (
"LE DeviceID %llu\n", ltBTRCoreDevId);
5215 enBTRCoreLEGattProp lenBTRCoreLEGattProp = enBTRCoreLEGPropUnknown;
5217 switch (aenBTRCoreLeProp) {
5219 case enBTRCoreLePropGUUID:
5220 lenBTRCoreLEGattProp = enBTRCoreLEGPropUUID;
5222 case enBTRCoreLePropGPrimary:
5223 lenBTRCoreLEGattProp = enBTRCoreLEGPropPrimary;
5225 case enBTRCoreLePropGDevice:
5226 lenBTRCoreLEGattProp = enBTRCoreLEGPropDevice;
5228 case enBTRCoreLePropGService:
5229 lenBTRCoreLEGattProp = enBTRCoreLEGPropService;
5231 case enBTRCoreLePropGValue:
5232 lenBTRCoreLEGattProp = enBTRCoreLEGPropValue;
5234 case enBTRCoreLePropGNotifying:
5235 lenBTRCoreLEGattProp = enBTRCoreLEGPropNotifying;
5237 case enBTRCoreLePropGFlags:
5238 lenBTRCoreLEGattProp = enBTRCoreLEGPropFlags;
5240 case enBTRCoreLePropGChar:
5241 lenBTRCoreLEGattProp = enBTRCoreLEGPropChar;
5243 case enBTRCoreLePropUnknown:
5245 lenBTRCoreLEGattProp = enBTRCoreLEGPropUnknown;
5251 lenBTRCoreLEGattProp,
5252 apvBTRCorePropValue) != enBTRCoreSuccess) {
5253 BTRCORELOG_ERROR (
"Failed to get Gatt Property %d!!!\n", lenBTRCoreLEGattProp);
5254 return enBTRCoreFailure;
5257 return enBTRCoreSuccess;
5263 tBTRCoreHandle hBTRCore,
5264 tBTRCoreDevId aBTRCoreDevId,
5265 const char* apBtUuid,
5266 enBTRCoreLeOp aenBTRCoreLeOp,
5271 if (!hBTRCore || !apBtUuid || aBTRCoreDevId < 0) {
5272 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg\n");
5273 return enBTRCoreInvalidArg;
5278 tBTRCoreDevId ltBTRCoreDevId = 0;
5281 if (aBTRCoreDevId < BTRCORE_MAX_NUM_BT_DEVICES) {
5282 pstScannedDev = &pstlhBTRCore->stScannedDevicesArr[aBTRCoreDevId];
5285 for (i32LoopIdx = 0; i32LoopIdx < pstlhBTRCore->numOfScannedDevices; i32LoopIdx++) {
5286 if (aBTRCoreDevId == pstlhBTRCore->stScannedDevicesArr[i32LoopIdx].tDeviceId) {
5287 pstScannedDev = &pstlhBTRCore->stScannedDevicesArr[i32LoopIdx];
5293 if (pstScannedDev) {
5294 ltBTRCoreDevId = pstScannedDev->tDeviceId;
5297 if (!pstScannedDev || !ltBTRCoreDevId) {
5298 BTRCORELOG_ERROR (
"Failed to find device in Scanned devices list\n");
5299 return enBTRCoreDeviceNotFound;
5302 if (!pstScannedDev->bFound || !pstScannedDev->bDeviceConnected) {
5303 BTRCORELOG_ERROR (
"Le Device is not connected, Please connect and perform LE method operation\n");
5304 return enBTRCoreDeviceNotFound;
5307 BTRCORELOG_DEBUG (
"Perform LE Op for Device : %s\n", pstScannedDev->pcDeviceName);
5308 BTRCORELOG_DEBUG (
"LE DeviceID %llu\n", ltBTRCoreDevId);
5310 enBTRCoreLEGattOp lenBTRCoreLEGattOp = enBTRCoreLEGOpUnknown;
5312 switch (aenBTRCoreLeOp) {
5314 case enBTRCoreLeOpGReadValue:
5315 lenBTRCoreLEGattOp = enBTRCoreLEGOpReadValue;
5317 case enBTRCoreLeOpGWriteValue:
5318 lenBTRCoreLEGattOp = enBTRCoreLEGOpWriteValue;
5320 case enBTRCoreLeOpGStartNotify:
5321 lenBTRCoreLEGattOp = enBTRCoreLEGOpStartNotify;
5323 case enBTRCoreLeOpGStopNotify:
5324 lenBTRCoreLEGattOp = enBTRCoreLEGOpStopNotify;
5326 case enBTRCoreLeOpUnknown:
5328 lenBTRCoreLEGattOp = enBTRCoreLEGOpUnknown;
5336 rpLeOpRes) != enBTRCoreSuccess) {
5337 BTRCORELOG_ERROR (
"Failed to Perform LE Method Op %d!!!\n", aenBTRCoreLeOp);
5338 return enBTRCoreFailure;
5341 return enBTRCoreSuccess;
5346 tBTRCoreHandle hBTRCore
5349 enBTRCoreRet lenBTRCoreRet = enBTRCoreSuccess;
5351 if (NULL == hBTRCore) {
5352 BTRCORELOG_ERROR(
"enBTRCoreNotInitialized\n");
5353 lenBTRCoreRet = enBTRCoreNotInitialized;
5360 return lenBTRCoreRet;
5365 tBTRCoreHandle hBTRCore
5368 enBTRCoreRet lenBTRCoreRet = enBTRCoreSuccess;
5370 if (NULL == hBTRCore) {
5371 BTRCORELOG_ERROR(
"enBTRCoreNotInitialized\n");
5372 lenBTRCoreRet = enBTRCoreNotInitialized;
5379 return lenBTRCoreRet;
5384 tBTRCoreHandle hBTRCore,
5387 enBTRCoreLeProp aElement
5389 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
5392 if ((NULL == hBTRCore) || (NULL == aUUID) || (NULL == aValue)) {
5393 BTRCORELOG_ERROR(
"enBTRCoreNotInitialized\n");
5394 lenBTRCoreRet = enBTRCoreNotInitialized;
5399 return lenBTRCoreRet;
5404 tBTRCoreHandle hBTRCore,
5408 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
5410 if ((NULL != hBTRCore) && ( NULL != aAdvtType)) {
5415 return lenBTRCoreRet;
5420 tBTRCoreHandle hBTRCore,
5424 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
5426 if ((NULL != hBTRCore) && (NULL != aUUID)) {
5431 return lenBTRCoreRet;
5436 tBTRCoreHandle hBTRCore,
5437 unsigned short aManfId,
5438 unsigned char* aDeviceDetails,
5442 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
5444 if ((NULL != hBTRCore) && (NULL != aDeviceDetails)) {
5450 return lenBTRCoreRet;
5455 tBTRCoreHandle hBTRCore,
5459 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
5461 if (NULL != hBTRCore) {
5466 return lenBTRCoreRet;
5471 tBTRCoreHandle hBTRCore,
5476 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
5477 int lNumGattServices = 0;
5479 if ((NULL != hBTRCore) && (NULL != aUUID)) {
5481 if (NULL !=
BTRCore_LE_AddGattServiceInfo(pstlhBTRCore->leHdl, pstlhBTRCore->curAdapterPath, pstlhBTRCore->curAdapterAddr, aUUID, aServiceType, &lNumGattServices)) {
5483 lenBTRCoreRet = enBTRCoreSuccess;
5486 return lenBTRCoreRet;
5491 tBTRCoreHandle hBTRCore,
5494 unsigned short aFlags,
5496 enBTRCoreLeProp aElement
5498 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
5501 if ((NULL != hBTRCore) && (NULL != aParentUUID) && (NULL != aUUID) && (NULL != aValue)) {
5504 if (enBTRCoreLePropGChar == aElement) {
5505 if (NULL !=
BTRCore_LE_AddGattCharInfo(pstlhBTRCore->leHdl, pstlhBTRCore->curAdapterPath, pstlhBTRCore->curAdapterAddr, aParentUUID, aUUID, aFlags, aValue)) {
5506 lenBTRCoreRet = enBTRCoreSuccess;
5510 if (NULL !=
BTRCore_LE_AddGattDescInfo(pstlhBTRCore->leHdl, pstlhBTRCore->curAdapterPath, pstlhBTRCore->curAdapterAddr, aParentUUID, aUUID, aFlags, aValue)) {
5511 lenBTRCoreRet = enBTRCoreSuccess;
5516 return lenBTRCoreRet;
5521 tBTRCoreHandle hBTRCore,
5524 enBTRCoreLeProp aElement
5529 BTRCORELOG_ERROR(
"enBTRCoreNotInitialized\n");
5530 return enBTRCoreNotInitialized;
5533 BTRCORELOG_ERROR(
"enBTRCoreInvalidArg\n");
5534 return enBTRCoreInvalidArg;
5540 BTRCORELOG_ERROR(
"Set Gatt Property value - FAILED\n");
5541 return enBTRCoreFailure;
5544 return enBTRCoreSuccess;
5550 BTRCore_RegisterDiscoveryCb (
5551 tBTRCoreHandle hBTRCore,
5552 fPtr_BTRCore_DeviceDiscCb afpcBBTRCoreDeviceDisc,
5558 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
5559 return enBTRCoreNotInitialized;
5564 if (!pstlhBTRCore->fpcBBTRCoreDeviceDisc) {
5565 pstlhBTRCore->fpcBBTRCoreDeviceDisc = afpcBBTRCoreDeviceDisc;
5566 pstlhBTRCore->pvcBDevDiscUserData = apUserData;
5567 BTRCORELOG_INFO (
"Device Discovery Callback Registered Successfully\n");
5570 BTRCORELOG_INFO (
"Device Discovery Callback Already Registered - Not Registering current CB\n");
5573 return enBTRCoreSuccess;
5578 BTRCore_RegisterStatusCb (
5579 tBTRCoreHandle hBTRCore,
5580 fPtr_BTRCore_StatusCb afpcBBTRCoreStatus,
5586 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
5587 return enBTRCoreNotInitialized;
5592 if (!pstlhBTRCore->fpcBBTRCoreStatus) {
5593 pstlhBTRCore->fpcBBTRCoreStatus = afpcBBTRCoreStatus;
5594 pstlhBTRCore->pvcBStatusUserData= apUserData;
5595 BTRCORELOG_INFO (
"BT Status Callback Registered Successfully\n");
5598 BTRCORELOG_INFO (
"BT Status Callback Already Registered - Not Registering current CB\n");
5601 return enBTRCoreSuccess;
5606 BTRCore_RegisterMediaStatusCb (
5607 tBTRCoreHandle hBTRCore,
5608 fPtr_BTRCore_MediaStatusCb afpcBBTRCoreMediaStatus,
5614 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
5615 return enBTRCoreNotInitialized;
5620 if (!pstlhBTRCore->fpcBBTRCoreMediaStatus) {
5621 pstlhBTRCore->fpcBBTRCoreMediaStatus = afpcBBTRCoreMediaStatus;
5622 pstlhBTRCore->pvcBMediaStatusUserData= apUserData;
5623 BTRCORELOG_INFO (
"BT Media Status Callback Registered Successfully\n");
5626 BTRCORELOG_INFO (
"BT Media Status Callback Already Registered - Not Registering current CB\n");
5629 return enBTRCoreSuccess;
5634 BTRCore_RegisterConnectionIntimationCb (
5635 tBTRCoreHandle hBTRCore,
5636 fPtr_BTRCore_ConnIntimCb afpcBBTRCoreConnIntim,
5642 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
5643 return enBTRCoreNotInitialized;
5650 if (!pstlhBTRCore->fpcBBTRCoreConnIntim) {
5651 pstlhBTRCore->fpcBBTRCoreConnIntim = afpcBBTRCoreConnIntim;
5652 pstlhBTRCore->pvcBConnIntimUserData= apUserData;
5653 BTRCORELOG_INFO (
"BT Conn In Intimation Callback Registered Successfully\n");
5656 BTRCORELOG_INFO (
"BT Conn In Intimation Callback Already Registered - Not Registering current CB\n");
5659 return enBTRCoreSuccess;
5664 BTRCore_RegisterConnectionAuthenticationCb (
5665 tBTRCoreHandle hBTRCore,
5666 fPtr_BTRCore_ConnAuthCb afpcBBTRCoreConnAuth,
5672 BTRCORELOG_ERROR (
"enBTRCoreNotInitialized\n");
5673 return enBTRCoreNotInitialized;
5680 if (!pstlhBTRCore->fpcBBTRCoreConnAuth) {
5681 pstlhBTRCore->fpcBBTRCoreConnAuth = afpcBBTRCoreConnAuth;
5682 pstlhBTRCore->pvcBConnAuthUserData= apUserData;
5683 BTRCORELOG_INFO (
"BT Conn Auth Callback Registered Successfully\n");
5686 BTRCORELOG_INFO (
"BT Conn Auth Callback Already Registered - Not Registering current CB\n");
5689 return enBTRCoreSuccess;
5694 btrCore_BTAdapterStatusUpdateCb (
5700 enBTRCoreRet lenBTRCoreRet = enBTRCoreSuccess;
5704 if (!apstBTAdapterInfo || !apUserData) {
5705 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg!!!");
5709 if (!apstBTAdapterInfo->pcPath ||
5710 !(pathlen = strlen (apstBTAdapterInfo->pcPath)) ||
5711 strcmp(apstBTAdapterInfo->pcPath, lpstlhBTRCore->curAdapterPath)) {
5712 BTRCORELOG_INFO (
"Dropping event for non-current adapter path %s\n", apstBTAdapterInfo->pcPath ? apstBTAdapterInfo->pcPath :
"<null>");
5716 lstAdapterInfo.adapter_number = atoi(apstBTAdapterInfo->pcPath+pathlen-1);
5718 BTRCORELOG_DEBUG (
"adapter number = %d, path = %s, discovering = %d\n",
5719 lstAdapterInfo.adapter_number, apstBTAdapterInfo->pcPath, apstBTAdapterInfo->bDiscovering);
5721 switch (aeBtAdapterProp) {
5722 case enBTAdPropDiscoveryStatus: {
5723 lstAdapterInfo.discoverable = apstBTAdapterInfo->bDiscoverable;
5724 lstAdapterInfo.bDiscovering = apstBTAdapterInfo->bDiscovering;
5726 if ((lenBTRCoreRet = btrCore_OutTaskAddOp(lpstlhBTRCore->pGAQueueOutTask,
5727 enBTRCoreTaskOpProcess,
5728 enBTRCoreTaskPTcBAdapterStatus,
5729 &lstAdapterInfo)) != enBTRCoreSuccess) {
5730 BTRCORELOG_WARN(
"Failure btrCore_OutTaskAddOp enBTRCoreTaskOpProcess enBTRCoreTaskPTcBAdapterStatus %d\n", lenBTRCoreRet);
5734 case enBTAdPropUnknown: {
5746 btrCore_BTDeviceStatusUpdateCb (
5752 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
5753 enBTRCoreDeviceType lenBTRCoreDevType = enBTRCoreUnknown;
5756 BTRCORELOG_INFO (
"enBTDeviceType = %d enBTDeviceState = %d apstBTDeviceInfo = %p\n", aeBtDeviceType, aeBtDeviceState, apstBTDeviceInfo);
5758 lenBTRCoreDevType = btrCore_MapClassIDToDevType(apstBTDeviceInfo->ui32Class, aeBtDeviceType);
5760 switch (aeBtDeviceState) {
5761 case enBTDevStCreated: {
5764 case enBTDevStScanInProgress: {
5767 case enBTDevStFound: {
5770 if (lpstlhBTRCore && apstBTDeviceInfo) {
5772 tBTRCoreDevId lBTRCoreDevId = 0;
5774 BTRCORELOG_TRACE (
"bPaired = %d\n", apstBTDeviceInfo->bPaired);
5775 BTRCORELOG_TRACE (
"bConnected = %d\n", apstBTDeviceInfo->bConnected);
5776 BTRCORELOG_TRACE (
"bTrusted = %d\n", apstBTDeviceInfo->bTrusted);
5777 BTRCORELOG_TRACE (
"bBlocked = %d\n", apstBTDeviceInfo->bBlocked);
5778 BTRCORELOG_TRACE (
"ui16Vendor = %d\n", apstBTDeviceInfo->ui16Vendor);
5779 BTRCORELOG_TRACE (
"ui16VendorSource = %d\n", apstBTDeviceInfo->ui16VendorSource);
5780 BTRCORELOG_TRACE (
"ui16Product = %d\n", apstBTDeviceInfo->ui16Product);
5781 BTRCORELOG_TRACE (
"ui16Version = %d\n", apstBTDeviceInfo->ui16Version);
5782 BTRCORELOG_TRACE (
"ui32Class = %d\n", apstBTDeviceInfo->ui32Class);
5783 BTRCORELOG_TRACE (
"i32RSSI = %d\n", apstBTDeviceInfo->i32RSSI);
5784 BTRCORELOG_TRACE (
"pcName = %s\n", apstBTDeviceInfo->pcName);
5785 BTRCORELOG_TRACE (
"pcAddress = %s\n", apstBTDeviceInfo->pcAddress);
5786 BTRCORELOG_TRACE (
"pcAlias = %s\n", apstBTDeviceInfo->pcAlias);
5787 BTRCORELOG_TRACE (
"pcIcon = %s\n", apstBTDeviceInfo->pcIcon);
5788 BTRCORELOG_TRACE (
"pcDevicePath = %s\n", apstBTDeviceInfo->pcDevicePath);
5791 if (apstBTDeviceInfo->aUUIDs[j][0] ==
'\0')
5794 BTRCORELOG_INFO (
"aUUIDs = %s\n", apstBTDeviceInfo->aUUIDs[j]);
5797 lBTRCoreDevId = btrCore_GenerateUniqueDeviceID(apstBTDeviceInfo->pcAddress);
5799 if (btrCore_GetScannedDeviceAddress(lpstlhBTRCore, lBTRCoreDevId)) {
5800 BTRCORELOG_INFO (
"Already we have a entry in the list; Skip Parsing now \n");
5805 lstOTskInData.bTRCoreDevId = lBTRCoreDevId;
5806 lstOTskInData.enBTRCoreDevType = lenBTRCoreDevType;
5807 lstOTskInData.pstBTDevInfo = apstBTDeviceInfo;
5809 if ((lenBTRCoreRet = btrCore_OutTaskAddOp(lpstlhBTRCore->pGAQueueOutTask, enBTRCoreTaskOpProcess, enBTRCoreTaskPTcBDeviceDisc, &lstOTskInData)) != enBTRCoreSuccess) {
5810 BTRCORELOG_WARN(
"Failure btrCore_OutTaskAddOp enBTRCoreTaskOpProcess enBTRCoreTaskPTcBDeviceDisc %d\n", lenBTRCoreRet);
5817 case enBTDevStLost: {
5820 if (lpstlhBTRCore && apstBTDeviceInfo) {
5821 tBTRCoreDevId lBTRCoreDevId = btrCore_GenerateUniqueDeviceID(apstBTDeviceInfo->pcAddress);
5823 if (btrCore_GetKnownDeviceMac(lpstlhBTRCore, lBTRCoreDevId)) {
5826 lstOTskInData.bTRCoreDevId = lBTRCoreDevId;
5827 lstOTskInData.enBTRCoreDevType = lenBTRCoreDevType;
5828 lstOTskInData.pstBTDevInfo = apstBTDeviceInfo;
5830 if ((lenBTRCoreRet = btrCore_OutTaskAddOp(lpstlhBTRCore->pGAQueueOutTask, enBTRCoreTaskOpProcess, enBTRCoreTaskPTcBDeviceLost, &lstOTskInData)) != enBTRCoreSuccess) {
5831 BTRCORELOG_WARN(
"Failure btrCore_OutTaskAddOp enBTRCoreTaskOpProcess enBTRCoreTaskPTcBDeviceLost%d\n", lenBTRCoreRet);
5834 else if (btrCore_GetScannedDeviceAddress(lpstlhBTRCore, lBTRCoreDevId)) {
5837 lstOTskInData.bTRCoreDevId = lBTRCoreDevId;
5838 lstOTskInData.enBTRCoreDevType = lenBTRCoreDevType;
5839 lstOTskInData.pstBTDevInfo = apstBTDeviceInfo;
5841 if ((lenBTRCoreRet = btrCore_OutTaskAddOp(lpstlhBTRCore->pGAQueueOutTask, enBTRCoreTaskOpProcess, enBTRCoreTaskPTcBDeviceRemoved, &lstOTskInData)) != enBTRCoreSuccess) {
5842 BTRCORELOG_WARN(
"Failure btrCore_OutTaskAddOp enBTRCoreTaskOpProcess enBTRCoreTaskPTcBDeviceRemoved %d\n", lenBTRCoreRet);
5846 BTRCORELOG_INFO (
"We dont have a entry in the list; Skip Parsing now \n");
5851 case enBTDevStPairingRequest: {
5854 case enBTDevStPairingInProgress: {
5857 case enBTDevStPaired: {
5860 case enBTDevStUnPaired: {
5863 case enBTDevStConnectInProgress: {
5866 case enBTDevStConnected: {
5869 case enBTDevStDisconnected: {
5872 case enBTDevStPropChanged: {
5875 if (lpstlhBTRCore && apstBTDeviceInfo) {
5876 tBTRCoreDevId lBTRCoreDevId = btrCore_GenerateUniqueDeviceID(apstBTDeviceInfo->pcAddress);
5878 if (btrCore_GetKnownDeviceMac(lpstlhBTRCore, lBTRCoreDevId)) {
5881 lstOTskInData.bTRCoreDevId = lBTRCoreDevId;
5882 lstOTskInData.enBTRCoreDevType = lenBTRCoreDevType;
5883 lstOTskInData.pstBTDevInfo = apstBTDeviceInfo;
5885 if ((lenBTRCoreRet = btrCore_OutTaskAddOp(lpstlhBTRCore->pGAQueueOutTask, enBTRCoreTaskOpProcess, enBTRCoreTaskPTcBDeviceStatus, &lstOTskInData)) != enBTRCoreSuccess) {
5886 BTRCORELOG_WARN(
"Failure btrCore_OutTaskAddOp enBTRCoreTaskOpProcess enBTRCoreTaskPTcBDeviceStatus %d\n", lenBTRCoreRet);
5889 else if (btrCore_GetScannedDeviceAddress(lpstlhBTRCore, lBTRCoreDevId)) {
5892 lstOTskInData.bTRCoreDevId = lBTRCoreDevId;
5893 lstOTskInData.enBTRCoreDevType = lenBTRCoreDevType;
5894 lstOTskInData.pstBTDevInfo = apstBTDeviceInfo;
5896 if ((lenBTRCoreRet = btrCore_OutTaskAddOp(lpstlhBTRCore->pGAQueueOutTask, enBTRCoreTaskOpProcess, enBTRCoreTaskPTcBDeviceStatus, &lstOTskInData)) != enBTRCoreSuccess) {
5897 BTRCORELOG_WARN(
"Failure btrCore_OutTaskAddOp enBTRCoreTaskOpProcess enBTRCoreTaskPTcBDeviceStatus %d\n", lenBTRCoreRet);
5904 case enBTDevStRSSIUpdate: {
5905 BTRCORELOG_INFO (
"Received RSSI Update...\n");
5908 case enBTDevStUnknown: {
5921 btrCore_BTDeviceConnectionIntimationCb (
5924 unsigned int aui32devPassKey,
5925 unsigned char ucIsReqConfirmation,
5928 int i32DevConnIntimRet = 0;
5930 enBTRCoreDeviceType lenBTRCoreDevType = enBTRCoreUnknown;
5932 lenBTRCoreDevType = btrCore_MapClassIDToDevType(apstBTDeviceInfo->ui32Class, aeBtDeviceType);
5935 if (lpstlhBTRCore) {
5937 int i32ScannedDevIdx = -1;
5939 if ((i32ScannedDevIdx = btrCore_AddDeviceToScannedDevicesArr(lpstlhBTRCore, apstBTDeviceInfo, &lstFoundDevice)) != -1) {
5940 BTRCORELOG_DEBUG (
"btrCore_AddDeviceToScannedDevicesArr - Success Index = %d\n", i32ScannedDevIdx);
5943 BTRCORELOG_DEBUG(
"btrCore_BTDeviceConnectionIntimationCb\n");
5944 lpstlhBTRCore->stConnCbInfo.ui32devPassKey = aui32devPassKey;
5945 lpstlhBTRCore->stConnCbInfo.ucIsReqConfirmation = ucIsReqConfirmation;
5947 if (apstBTDeviceInfo->pcName)
5948 strncpy(lpstlhBTRCore->stConnCbInfo.cConnAuthDeviceName, apstBTDeviceInfo->pcName, (strlen(apstBTDeviceInfo->pcName) < (BTRCORE_STR_LEN - 1)) ? strlen(apstBTDeviceInfo->pcName) : BTRCORE_STR_LEN - 1);
5951 memcpy (&lpstlhBTRCore->stConnCbInfo.stFoundDevice, &lstFoundDevice,
sizeof(
stBTRCoreBTDevice));
5952 lpstlhBTRCore->stConnCbInfo.stFoundDevice.bFound =
TRUE;
5954 if ((lenBTRCoreDevType == enBTRCoreMobileAudioIn) || (lenBTRCoreDevType == enBTRCorePCAudioIn) || (lenBTRCoreDevType == enBTRCoreHID)) {
5955 if (lpstlhBTRCore->fpcBBTRCoreConnIntim) {
5956 if (lpstlhBTRCore->fpcBBTRCoreConnIntim(&lpstlhBTRCore->stConnCbInfo, &i32DevConnIntimRet, lpstlhBTRCore->pvcBConnIntimUserData) != enBTRCoreSuccess) {
5961 else if ((lenBTRCoreDevType == enBTRCoreSpeakers) || (lenBTRCoreDevType == enBTRCoreHeadSet)) {
5962 if (lpstlhBTRCore->numOfPairedDevices) {
5963 unsigned int i32LoopIdx = 0;
5966 for (i32LoopIdx = 0; i32LoopIdx < lpstlhBTRCore->numOfPairedDevices; i32LoopIdx++) {
5967 if (lpstlhBTRCore->stKnownDevicesArr[i32LoopIdx].tDeviceId == lpstlhBTRCore->stConnCbInfo.stFoundDevice.tDeviceId) {
5968 BTRCORELOG_DEBUG(
"ACCEPT INCOMING INTIMATION stKnownDevice : %s", lpstlhBTRCore->stKnownDevicesArr[i32LoopIdx].pcDeviceName);
5969 i32DevConnIntimRet = 1;
5975 i32DevConnIntimRet = 1;
5979 return i32DevConnIntimRet;
5983 btrCore_BTDeviceAuthenticationCb (
5988 int i32DevAuthRet = 0;
5990 enBTRCoreDeviceType lenBTRCoreDevType = enBTRCoreUnknown;
5992 lenBTRCoreDevType = btrCore_MapClassIDToDevType(apstBTDeviceInfo->ui32Class, aeBtDeviceType);
5995 if (lpstlhBTRCore) {
5997 int i32ScannedDevIdx = -1;
5998 int i32KnownDevIdx = -1;
6000 if ((i32ScannedDevIdx = btrCore_AddDeviceToScannedDevicesArr(lpstlhBTRCore, apstBTDeviceInfo, &lstFoundDevice)) != -1) {
6001 BTRCORELOG_DEBUG (
"btrCore_AddDeviceToScannedDevicesArr - Success Index = %d\n", i32ScannedDevIdx);
6004 BTRCORELOG_DEBUG(
"btrCore_BTDeviceAuthenticationCb\n");
6005 if (apstBTDeviceInfo->pcName)
6006 strncpy(lpstlhBTRCore->stConnCbInfo.cConnAuthDeviceName, apstBTDeviceInfo->pcName, (strlen(apstBTDeviceInfo->pcName) < (BTRCORE_STR_LEN - 1)) ? strlen(apstBTDeviceInfo->pcName) : BTRCORE_STR_LEN - 1);
6009 if ((i32KnownDevIdx = btrCore_AddDeviceToKnownDevicesArr(lpstlhBTRCore, apstBTDeviceInfo)) != -1) {
6010 memcpy (&lpstlhBTRCore->stConnCbInfo.stKnownDevice, &lpstlhBTRCore->stKnownDevicesArr[i32KnownDevIdx],
sizeof(
stBTRCoreBTDevice));
6011 BTRCORELOG_DEBUG (
"btrCore_AddDeviceToKnownDevicesArr - Success Index = %d Unique DevID = %lld\n", i32KnownDevIdx, lpstlhBTRCore->stConnCbInfo.stKnownDevice.tDeviceId);
6014 if (lpstlhBTRCore->fpcBBTRCoreConnAuth) {
6015 if (lpstlhBTRCore->fpcBBTRCoreConnAuth(&lpstlhBTRCore->stConnCbInfo, &i32DevAuthRet, lpstlhBTRCore->pvcBConnAuthUserData) != enBTRCoreSuccess) {
6021 if (lpstlhBTRCore->numOfPairedDevices && i32DevAuthRet) {
6023 if ((lenBTRCoreDevType == enBTRCoreMobileAudioIn) ||
6024 (lenBTRCoreDevType == enBTRCorePCAudioIn)) {
6025 unsigned int i32LoopIdx = 0;
6027 for (i32LoopIdx = 0; i32LoopIdx < lpstlhBTRCore->numOfPairedDevices; i32LoopIdx++) {
6028 if (lpstlhBTRCore->stKnownDevicesArr[i32LoopIdx].tDeviceId == lpstlhBTRCore->stConnCbInfo.stKnownDevice.tDeviceId) {
6030 if (lpstlhBTRCore->stKnownDevStInfoArr[i32LoopIdx].eDeviceCurrState == enBTRCoreDevStInitialized) {
6031 lpstlhBTRCore->stKnownDevStInfoArr[i32LoopIdx].eDevicePrevState = lpstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDevicePrevState;
6032 lpstlhBTRCore->stKnownDevStInfoArr[i32LoopIdx].eDeviceCurrState = lpstlhBTRCore->stScannedDevStInfoArr[i32ScannedDevIdx].eDeviceCurrState;
6035 lpstlhBTRCore->stConnCbInfo.stKnownDevice.bDeviceConnected =
TRUE;
6036 lpstlhBTRCore->stKnownDevicesArr[i32LoopIdx].bDeviceConnected =
TRUE;
6037 BTRCORELOG_DEBUG(
"stKnownDevice.device_connected set : %d\n", lpstlhBTRCore->stKnownDevicesArr[i32LoopIdx].bDeviceConnected);
6041 else if ((lenBTRCoreDevType == enBTRCoreSpeakers) ||
6042 (lenBTRCoreDevType == enBTRCoreHeadSet)) {
6043 unsigned int i32LoopIdx = 0;
6046 for (i32LoopIdx = 0; i32LoopIdx < lpstlhBTRCore->numOfPairedDevices; i32LoopIdx++) {
6047 if (lpstlhBTRCore->stKnownDevicesArr[i32LoopIdx].tDeviceId == lpstlhBTRCore->stConnCbInfo.stKnownDevice.tDeviceId) {
6048 BTRCORELOG_DEBUG(
"ACCEPTED INCOMING CONNECT stKnownDevice : %s\n", lpstlhBTRCore->stKnownDevicesArr[i32LoopIdx].pcDeviceName);
6049 if ((lpstlhBTRCore->stKnownDevStInfoArr[i32LoopIdx].eDevicePrevState != enBTRCoreDevStPlaying) &&
6050 (lpstlhBTRCore->stKnownDevStInfoArr[i32LoopIdx].eDeviceCurrState != enBTRCoreDevStConnected)) {
6051 lpstlhBTRCore->stKnownDevStInfoArr[i32LoopIdx].eDevicePrevState = lpstlhBTRCore->stKnownDevStInfoArr[i32LoopIdx].eDeviceCurrState;
6053 if (lpstlhBTRCore->stKnownDevStInfoArr[i32LoopIdx].eDeviceCurrState != enBTRCoreDevStPlaying)
6054 lpstlhBTRCore->stKnownDevStInfoArr[i32LoopIdx].eDeviceCurrState = enBTRCoreDevStConnected;
6059 else if ((lenBTRCoreDevType == enBTRCoreHID) &&
6060 strstr(apstBTDeviceInfo->pcName,
"Xbox")) {
6062 BTRCORELOG_ERROR (
"Failed to Disable ERTM\n");
6069 return i32DevAuthRet;
6074 btrCore_BTMediaStatusUpdateCb (
6076 const char* apBtdevAddr,
6080 enBTRCoreRet lenBTRCoreRet = enBTRCoreSuccess;
6081 tBTRCoreDevId lBTRCoreDevId = 0;
6085 if (!apMediaStreamStatus || !apBtdevAddr || !apUserData) {
6086 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg!!!");
6087 return enBTRCoreInvalidArg;
6091 lBTRCoreDevId = btrCore_GenerateUniqueDeviceID(apBtdevAddr);
6092 if (!btrCore_GetKnownDeviceMac(lpstlhBTRCore, lBTRCoreDevId)) {
6093 BTRCORELOG_INFO (
"We dont have a entry in the list; Skip Parsing now \n");
6094 return enBTRCoreDeviceNotFound;
6099 switch (apMediaStreamStatus->eAVMediaState) {
6101 case eBTRCoreAVMediaTrkStStarted:
6102 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaTrkStStarted;
6103 memcpy (&lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.m_mediaPositionInfo, &apMediaStreamStatus->m_mediaPositionInfo,
sizeof(
stBTRCoreMediaPositionInfo));
6105 case eBTRCoreAVMediaTrkStPlaying:
6106 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaTrkStPlaying;
6107 memcpy (&lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.m_mediaPositionInfo, &apMediaStreamStatus->m_mediaPositionInfo,
sizeof(
stBTRCoreMediaPositionInfo));
6109 case eBTRCoreAVMediaTrkStPaused:
6110 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaTrkStPaused;
6111 memcpy (&lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.m_mediaPositionInfo, &apMediaStreamStatus->m_mediaPositionInfo,
sizeof(
stBTRCoreMediaPositionInfo));
6113 case eBTRCoreAVMediaTrkStStopped:
6114 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaTrkStStopped;
6115 memcpy (&lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.m_mediaPositionInfo, &apMediaStreamStatus->m_mediaPositionInfo,
sizeof(
stBTRCoreMediaPositionInfo));
6117 case eBTRCoreAVMediaTrkStChanged:
6118 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaTrkStChanged;
6119 memcpy (&lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.m_mediaTrackInfo, &apMediaStreamStatus->m_mediaTrackInfo,
sizeof(
stBTRCoreMediaTrackInfo));
6121 case eBTRCoreAVMediaTrkPosition:
6122 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaTrkPosition;
6123 memcpy (&lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.m_mediaTrackInfo, &apMediaStreamStatus->m_mediaTrackInfo,
sizeof(
stBTRCoreMediaTrackInfo));
6125 case eBTRCoreAVMediaPlaybackEnded:
6126 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaPlaybackEnded;
6128 case eBTRCoreAVMediaPlyrName:
6129 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaPlyrName;
6130 strncpy (lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.m_mediaPlayerName, apMediaStreamStatus->m_mediaPlayerName, BTRCORE_MAX_STR_LEN -1);
6132 case eBTRCoreAVMediaPlyrEqlzrStOff:
6133 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaPlyrEqlzrStOff;
6135 case eBTRCoreAVMediaPlyrEqlzrStOn:
6136 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaPlyrEqlzrStOn;
6138 case eBTRCoreAVMediaPlyrShflStOff:
6139 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaPlyrShflStOff;
6141 case eBTRCoreAVMediaPlyrShflStAllTracks:
6142 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaPlyrShflStAllTracks;
6144 case eBTRCoreAVMediaPlyrShflStGroup:
6145 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaPlyrShflStGroup;
6147 case eBTRCoreAVMediaPlyrRptStOff:
6148 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaPlyrRptStOff;
6150 case eBTRCoreAVMediaPlyrRptStSingleTrack:
6151 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaPlyrRptStSingleTrack;
6153 case eBTRCoreAVMediaPlyrRptStAllTracks:
6154 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaPlyrRptStAllTracks;
6156 case eBTRCoreAVMediaPlyrRptStGroup:
6157 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaPlyrRptStGroup;
6159 case eBTRCoreAVMediaPlyrVolume:
6160 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaPlyrVolume;
6161 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.m_mediaPlayerVolume = apMediaStreamStatus->m_mediaPlayerTransportVolume;
6162 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.bIsMediaCtrlAvailable = (apMediaStreamStatus->bIsAVMediaCtrlAvail == 1) ?
TRUE : FALSE;
6164 case eBTRCoreAVMediaElementAdded:
6168 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaElementInScope;
6170 mediaElement->ui32MediaElementId = apMediaStreamStatus->m_mediaElementInfo.ui32AVMediaElementId;
6171 mediaElement->eAVMedElementType = btrCore_GetMediaElementType (apMediaStreamStatus->m_mediaElementInfo.eAVMElementType);
6173 if ((mediaElement->bIsPlayable = apMediaStreamStatus->m_mediaElementInfo.bIsPlayable)) {
6174 memcpy (&mediaElement->m_mediaTrackInfo, &apMediaStreamStatus->m_mediaElementInfo.m_mediaTrackInfo,
sizeof(
stBTRCoreMediaTrackInfo));
6177 strncpy (mediaElement->m_mediaElementName, apMediaStreamStatus->m_mediaElementInfo.m_mediaElementName, BTRCORE_MAX_STR_LEN -1);
6181 case eBTRCoreAVMediaElementRemoved:
6182 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.eBTMediaStUpdate = eBTRCoreMediaElementOofScope;
6183 lstMediaStatusUpdateCbInfo.m_mediaStatusUpdate.m_mediaElementInfo.ui32MediaElementId = apMediaStreamStatus->m_mediaElementInfo.ui32AVMediaElementId;
6190 lstMediaStatusUpdateCbInfo.deviceId = lBTRCoreDevId;
6192 if ((lenBTRCoreRet = btrCore_OutTaskAddOp(lpstlhBTRCore->pGAQueueOutTask, enBTRCoreTaskOpProcess, enBTRCoreTaskPTcBMediaStatus, &lstMediaStatusUpdateCbInfo)) != enBTRCoreSuccess) {
6193 BTRCORELOG_WARN(
"Failure btrCore_OutTaskAddOp enBTRCoreTaskOpProcess enBTRCoreTaskPTcBMediaStatus %d\n", lenBTRCoreRet);
6194 lenBTRCoreRet = enBTRCoreFailure;
6198 return lenBTRCoreRet;
6203 btrCore_BTLeStatusUpdateCb (
6205 const char* apcBtdevAddr,
6209 enBTRCoreRet lenBTRCoreRet = enBTRCoreFailure;
6213 const char* pDevicePath = NULL;
6214 const char* pDeviceName = NULL;
6215 tBTRCoreDevId lBTRCoreDevId = 0;
6219 if (!apstBtrLeInfo || !apcBtdevAddr || !apvUserData) {
6220 BTRCORELOG_ERROR (
"enBTRCoreInvalidArg!!!\n");
6221 return enBTRCoreInvalidArg;
6226 lBTRCoreDevId = btrCore_GenerateUniqueDeviceID(apcBtdevAddr);
6227 if ((lenBTRCoreRet = btrCore_GetDeviceInfo(lpstlhBTRCore, lBTRCoreDevId, enBTRCoreLE, &lenBTDeviceType,
6228 &lpstScannedDevice, &lpstScannedDevStInfo, &pDevicePath, &pDeviceName)) != enBTRCoreSuccess) {
6229 BTRCORELOG_ERROR (
"Failed to find Device in ScannedList!\n");
6230 return enBTRCoreDeviceNotFound;
6234 BTRCORELOG_DEBUG (
"LE Dev %s Path %s\n", pDeviceName, pDevicePath);
6236 lstDevStatusCbInfo.deviceId = lBTRCoreDevId;
6237 lstDevStatusCbInfo.eDeviceType = enBTRCoreLE;
6238 lstDevStatusCbInfo.eDeviceClass = lpstScannedDevice->enDeviceType;
6239 lstDevStatusCbInfo.ui32DevClassBtSpec = lpstScannedDevice->ui32DevClassBtSpec;
6240 lstDevStatusCbInfo.isPaired = 0;
6241 lstDevStatusCbInfo.eDevicePrevState = lpstScannedDevStInfo->eDeviceCurrState;
6242 strncpy(lstDevStatusCbInfo.deviceName, pDeviceName, BD_NAME_LEN);
6243 strncpy(lstDevStatusCbInfo.deviceAddress, apcBtdevAddr, BTRCORE_MAX_STR_LEN - 1);
6245 lstDevStatusCbInfo.eCoreLeProp = apstBtrLeInfo->enLeProp;
6246 lstDevStatusCbInfo.eDeviceType = enBTRCoreLE;
6247 lstDevStatusCbInfo.eCoreLeOper = apstBtrLeInfo->enLeOper;
6249 switch (apstBtrLeInfo->enLeOper) {
6250 case enBTRCoreLEGOpReady:
6251 lstDevStatusCbInfo.eDeviceCurrState = enBTRCoreDevStOpReady;
6252 strncpy(lstDevStatusCbInfo.devOpResponse, apstBtrLeInfo->pui8Value, BTRCORE_MAX_DEV_OP_DATA_LEN - 1);
6254 case enBTRCoreLEGOpReadValue:
6255 lstDevStatusCbInfo.eDeviceCurrState = enBTRCoreDevStOpInfo;
6256 strncpy(lstDevStatusCbInfo.uuid, apstBtrLeInfo->pui8Uuid, BTRCORE_UUID_LEN - 1);
6257 memset(lstDevStatusCbInfo.devOpResponse,
'\0', BTRCORE_MAX_DEV_OP_DATA_LEN);
6258 strncpy(lstDevStatusCbInfo.devOpResponse, apstBtrLeInfo->pui8Value, BTRCORE_MAX_DEV_OP_DATA_LEN - 1);
6260 case enBTRCoreLEGOpWriteValue:
6261 lstDevStatusCbInfo.eDeviceCurrState = enBTRCoreDevStOpInfo;
6262 strncpy(lstDevStatusCbInfo.uuid, apstBtrLeInfo->pui8Uuid, BTRCORE_UUID_LEN - 1);
6263 memset(lstDevStatusCbInfo.devOpResponse,
'\0', BTRCORE_MAX_DEV_OP_DATA_LEN);
6264 strncpy(lstDevStatusCbInfo.devOpResponse, apstBtrLeInfo->pui8Value, BTRCORE_MAX_DEV_OP_DATA_LEN - 1);
6266 case enBTRCoreLEGOpStartNotify:
6267 lstDevStatusCbInfo.eDeviceCurrState = enBTRCoreDevStOpInfo;
6268 memset(lstDevStatusCbInfo.devOpResponse,
'\0', BTRCORE_MAX_DEV_OP_DATA_LEN);
6269 strncpy(lstDevStatusCbInfo.devOpResponse, apstBtrLeInfo->pui8Value, BTRCORE_MAX_DEV_OP_DATA_LEN - 1);
6271 case enBTRCoreLEGOpStopNotify:
6272 lstDevStatusCbInfo.eDeviceCurrState = enBTRCoreDevStOpInfo;
6273 memset(lstDevStatusCbInfo.devOpResponse,
'\0', BTRCORE_MAX_DEV_OP_DATA_LEN);
6274 strncpy(lstDevStatusCbInfo.devOpResponse, apstBtrLeInfo->pui8Value, BTRCORE_MAX_DEV_OP_DATA_LEN - 1);
6276 case enBTRCoreLEGOpUnknown:
6281 if ((enBTRCoreLEGOpReadValue == apstBtrLeInfo->enLeOper) && (lpstScannedDevice->enDeviceType != enBTRCore_DC_Tile)) {
6282 if (lpstlhBTRCore->fpcBBTRCoreStatus) {
6283 BTRCORELOG_INFO(
" Not adding to the task queue !!!!!!\n");
6285 if (enBTRCoreSuccess != lpstlhBTRCore->fpcBBTRCoreStatus(&lstDevStatusCbInfo, lpstlhBTRCore->pvcBStatusUserData) ) {
6286 BTRCORELOG_ERROR(
" CallBack Error !!!!!!\n");
6287 lenBTRCoreRet = enBTRCoreFailure;
6290 strncpy(apstBtrLeInfo->pui8Value, lstDevStatusCbInfo.devOpResponse, BTRCORE_MAX_DEV_OP_DATA_LEN - 1);
6295 if ((lenBTRCoreRet = btrCore_OutTaskAddOp(lpstlhBTRCore->pGAQueueOutTask, enBTRCoreTaskOpProcess, enBTRCoreTaskPTcBDevOpInfoStatus, &lstDevStatusCbInfo)) != enBTRCoreSuccess) {
6296 BTRCORELOG_WARN(
"Failure btrCore_OutTaskAddOp enBTRCoreTaskOpProcess enBTRCoreTaskPTcBDeviceStatus %d\n", lenBTRCoreRet);
6301 return lenBTRCoreRet;
6306 const char *name = &dev->pcDeviceName[0];
6307 const char *mac = &dev->pcDeviceAddress[0];
6312 #define btrCore_ByteCompare(A) (name[A] == mac[A])
6315 btrCore_ByteCompare(0) && btrCore_ByteCompare(1) &&
6317 btrCore_ByteCompare(3) && btrCore_ByteCompare(4) &&
6319 btrCore_ByteCompare(6) && btrCore_ByteCompare(7) &&
6321 btrCore_ByteCompare(9) && btrCore_ByteCompare(10) &&
6323 btrCore_ByteCompare(12) && btrCore_ByteCompare(13) &&
6325 btrCore_ByteCompare(15) && btrCore_ByteCompare(16);