RDK Documentation (Open Sourced RDK Components)
btrMgr_test.c
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <unistd.h>
23 #include "btmgr.h"
24 
25 #ifndef BUILD_FOR_PI
26 #include "rfcapi.h"
27 #endif
28 
29 /* Tile Specific TOA msg feilds */
30 # define _1_BYTE_TOA_CID "00"
31 # define _4_BYTE_TOA_SESSION_TOKEN "00000000"
32 # define _14_BYTE_TOA_RAND_A "0000000000000000000000000000"
33 # define _14_BYTE_TOA_MSG_PAYLOAD "0000000000000000000000000000"
34 # define _14_BYTE_TOA_SONG_PAYLOAD "020103"
35 # define _4_BYTE_TOA_MIC "00000000"
36 
37 # define _1_BYTE_TOA_CMD_OPEN_CHANNEL "10"
38 # define _1_BYTE_TOA_CMD_READY "12"
39 # define _1_BYTE_TOA_CMD_SONG_PLAY "05"
40 
41 # define _1_BYTE_TOA_RSP_OPEN_CHANNEL "12"
42 # define _1_BYTE_TOA_RSP_READY "01"
43 
44 volatile int wait = 1;
45 volatile unsigned char gReceivedNotification = 0;
46 char gNotificationData[BTRMGR_MAX_STR_LEN] = "\0";
47 int uselection = 0;
48 int cliDisabled = 0;
49 int cliArgCounter = 0;
50 char** gArgv;
51 int gArgc;
52 BTRMgrDeviceHandle gDeviceHandle = 0;
53 
55 {
56  0x02 ,
57  0x01 ,
58  0x06 ,
59  0x05 ,
60  0x03 ,
61  0x0A ,
62  0x18 ,
63  0xB9 ,
64  0xFD ,
65  0x0B ,
66  0xFF ,
67  0xA3 ,
68  0x07 ,
69  0x0101,
70  {
71  0xC8,
72  0xB3,
73  0x73,
74  0x32,
75  0xEA,
76  0x3D
77  }
78 };
79 
80 static void printOptions (void)
81 {
82  printf ("\n\n");
83  printf (" 1. Get Number of Adapter\n");
84  printf (" 2. Set Name to your Adapter\n");
85  printf (" 3. Get Name of your Adapter\n");
86  printf (" 4. Set Adapter Power; 0 to OFF & 1 to ON\n");
87  printf (" 5. Get Adapter Power\n");
88  printf (" 6. Set Discoverable\n");
89  printf (" 7. Is it Discoverable\n");
90  printf (" 8. Start Discovering\n");
91  printf (" 9. Stop Discovering\n");
92  printf ("10. Get List of Discovered Devices\n");
93  printf ("11. Pair a Device\n");
94  printf ("12. UnPair a Device\n");
95  printf ("13. Get List of Paired Devices\n");
96  printf ("14. Connect to Device\n");
97  printf ("15. DisConnect from Device\n");
98  printf ("16. Get Device Properties\n");
99  printf ("17. Start Streaming\n");
100  printf ("18. Stop Streaming\n");
101  printf ("19. Get StreamingOut Status\n");
102  printf ("20. Check auto connection of external Device\n");
103  printf ("21. Accept External Pair Request\n");
104  printf ("22. Deny External Pair Request\n");
105  printf ("23. Accept External Connect Request\n");
106  printf ("24. Deny External Connect Request\n");
107  printf ("25. Accept External Playback Request\n");
108  printf ("26. Deny External Playback Request\n");
109  printf ("27. Start Streaming-In\n");
110  printf ("28. Stop Streaming-In\n");
111  printf ("29. Perform Media Control Options\n");
112  printf ("30. Get Current Media Track Information\n");
113  printf ("31. Get Media Current Play Position\n");
114  printf ("32. Get StreamingIn Status\n");
115  printf ("33. Get LE Property\n");
116  printf ("34. Perform LE Operation\n");
117  printf ("35. Reset Bluetooth Adapter\n");
118  printf ("36. Get Discovery State \n");
119  printf ("37. Set StreamOut Type Auxiliary\n");
120  printf ("40. Ring A Tile (Just for POC)\n");
121  printf ("41. (RFC)Set AudioIn - Enabled/Disabled\n");
122  printf ("42. Set AudioIn - Enabled/Disabled\n");
123  printf ("43. Set Media Element Active\n");
124  printf ("44. Get Media Element List\n");
125  printf ("45. Select Media Element to Play/Explore\n");
126  printf ("46. Get Media Track Information by Media Element\n");
127  printf ("47. Set Device Media volume and mute info\n");
128  printf ("48. Get Device Media volume and mute info\n");
129  printf ("50. Set advertisement data and services and start advertisement\n");
130  printf ("51. Add service/gatt/descriptor info\n");
131  printf ("52. Stop Advertisement\n");
132  printf ("53. Begin advertisement for Xcam2\n");
133  printf ("54. (RFC)Set GamePad - Enabled/Disabled\n");
134  printf ("55. Set GamePad - Enabled/Disabled\n");
135  printf ("56. Quit\n");
136  printf ("\n\n");
137  printf ("Please enter the option that you want to test\t");
138 
139  return;
140 }
141 
142 static void printOptionsCli (void)
143 {
144  printf ("\n\n");
145  printf (" 1. Get Number of Adapter\n Usage: btrMgrTest 1\n");
146  printf (" 2. Set Name to your Adapter\n Usage: btrMgrTest 2 <Name>\n");
147  printf (" 3. Get Name of your Adapter\n Usage: btrMgrTest 3\n");
148  printf (" 4. Set Adapter Power; 0 to OFF & 1 to ON\n Usage: btrMgrTest 4 <PowerMode>\n");
149  printf (" 5. Get Adapter Power\n Usage: btrMgrTest 5\n");
150  printf (" 6. Set Discoverable\n Usage: btrMgrTest 6 <Discoverable> <TimeOut> \n 1 or 0 to Make it Discoverable ON or OFF\n");
151  printf (" 7. Is it Discoverable\n Usage: btrMgrTest 7\n");
152  printf (" 8. Start Discovering\n Usage: btrMgrTest 8 <ScanType> \n 0 - Normal(BR/EDR) | 1 - LE (BLE)\n");
153  printf (" 9. Stop Discovering\n Usage: btrMgrTest 9 <ScanType> \n 0 - Normal(BR/EDR) | 1 - LE (BLE)\n");
154  printf ("10. Get List of Discovered Devices\n Usage: btrMgrTest 10\n");
155  printf ("11. Pair a Device\n Usage: btrMgrTest 11 <Handle>\n");
156  printf ("12. UnPair a Device\n Usage: btrMgrTest 12 <Handle>\n");
157  printf ("13. Get List of Paired Devices\n Usage: btrMgrTest 13\n");
158  printf ("14. Connect to Device\n Usage: btrMgrTest 14 <Handle> <ConnectType>\n Device ConnectAs Type : [0 - AUDIO_OUTPUT | 1 - AUDIO_INPUT | 2 - LE ]\n");
159  printf ("15. DisConnect from Device\n Usage: btrMgrTest 15 <Handle>\n");
160  printf ("16. Get Device Properties\n Usage: btrMgrTest 16 <Handle>\n");
161  printf ("17. Start Streaming\n Usage: btrMgrTest 17 <Handle> <StreamingPref>\n[0 - AUDIO_OUTPUT | 1 - AUDIO_INPUT | 2 - LE ]\n");
162  printf ("18. Stop Streaming\n Usage: btrMgrTest 18 <Handle>\n");
163  printf ("19. Get StreamingOut Status\n Usage: btrMgrTest 19 \n");
164  printf ("20. Check auto connection of external Device\n Usage: btrMgrTest 20 \n");
165  printf ("21. Accept External Pair Request\n Usage: btrMgrTest 21 \n");
166  printf ("22. Deny External Pair Request\nUsage: btrMgrTest 22 \n");
167  printf ("23. Accept External Connect Request\n Usage: btrMgrTest 23 \n");
168  printf ("24. Deny External Connect Request\n Usage: btrMgrTest 24 \n");
169  printf ("25. Accept External Playback Request\n Usage: btrMgrTest 25 \n");
170  printf ("26. Deny External Playback Request\n Usage: btrMgrTest 26 \n");
171  printf ("27. Start Streaming-In\n Usage: btrMgrTest 27 <Handle> <StreamingPref> \n");
172  printf ("28. Stop Streaming-In\n Usage: btrMgrTest 28 <Handle> \n");
173  printf ("29. Perform Media Control Options\n Usage: btrMgrTest 29 <Handle> <MediaControlOpt> \n Medio Control Options [0 - Play | 1 - Pause | 2 - Stop | 3 - Next | 4 - Previous \n");
174  printf ("30. Get Current Media Track Information\n Usage: btrMgrTest 30 <Handle> \n");
175  printf ("31. Get Media Current Play Position\n Usage: btrMgrTest 31 <Handle>\n");
176  printf ("32. Get StreamingIn Status\n Usage: btrMgrTest 32 \n");
177  printf ("33. Get LE Property\n Usage: btrMgrTest 33 <Handle> <UUID> <Property>\n property to query: [0 - Uuid | 1 - Primary | 2 - Device | 3 - Service | 4 - Value | 5 - Notifying | 6 - Flags | 7 -Character]\n");
178  printf ("34. Perform LE Operation\n Usage: btrMgrTest 34 <Handle> <UUID> <Option> \nEnter Option : [ReadValue - 0 | WriteValue - 1 | StartNotify - 2 | StopNotify - 3]\n");
179  printf ("35. Reset Bluetooth Adapter\n Usage: btrMgrTest 35\n");
180  printf ("36. Get Discovery State \n");
181  printf ("37. Set StreamOut Type Auxiliary\n Usage: btrMgrTest 37\n");
182  printf ("40. Ring A Tile (Just for POC)\n");
183  printf ("55. Quit\n");
184  printf ("\n\n");
185 
186  return;
187 }
188 
189 static int getUserSelection (void)
190 {
191  int mychoice = 0;
192  if (cliDisabled)
193  {
194  printf("Enter a choice...\n");
195  if (scanf("%d", &mychoice)) {
196  }
197  getchar();//to catch newline
198  }
199  else
200  {
201  cliArgCounter++;
202  if (cliArgCounter < gArgc){
203  mychoice = atoi(gArgv[cliArgCounter]);
204  }
205  else{
206  printf("\n No Value entered , Sending 0\n");
207  }
208  }
209  return mychoice;
210 }
211 
212 static BTRMgrDeviceHandle getDeviceSelection(void)
213 {
214  BTRMgrDeviceHandle mychoice = 0;
215  if (cliDisabled)
216  {
217  printf("Enter a choice...\n");
218  if (scanf("%llu", &mychoice)) {
219  }
220  getchar();//to catch newline
221  }
222  else
223  {
224  cliArgCounter++;
225  if (cliArgCounter < gArgc){
226  mychoice = strtoll(gArgv[cliArgCounter],NULL, 0);
227  }
228  else{
229  printf("\n No Value entered , Sending 0\n");
230  }
231 
232  }
233  return mychoice;
234 }
235 
236 
237 void getString (char* mychoice)
238 {
239  if (cliDisabled)
240  {
241  char *tmp = NULL;
242  if (fgets (mychoice, BTRMGR_NAME_LEN_MAX, stdin)) {
243  }
244 
245  tmp = strchr(mychoice, '\n');
246  if (tmp)
247  *tmp = '\0';
248  }
249  else
250  {
251  cliArgCounter++;
252  if (cliArgCounter < gArgc){
253  strcpy(mychoice , gArgv[cliArgCounter]);
254  }
255  else{
256  printf("\n No Value entered , Sending NULL \n");
257  }
258  }
259 }
260 
261 static int
262 getBitsToString (
263  unsigned short flagBits
264 ) {
265  unsigned char i = 0;
266  for (; i<15; i++) {
267  printf("%d", (flagBits >> i) & 1);
268  }
269  return 0;
270 }
271 
272 
273 const char* getEventAsString (BTRMGR_Events_t etype)
274 {
275  char *event = "\0";
276  switch(etype)
277  {
278  case BTRMGR_EVENT_DEVICE_OUT_OF_RANGE : event = "DEVICE_OUT_OF_RANGE_OR_LOST"; break;
279  case BTRMGR_EVENT_DEVICE_DISCOVERY_STARTED : event = "DEVICE_DISCOVERY_STARTED"; break;
280  case BTRMGR_EVENT_DEVICE_DISCOVERY_UPDATE : event = "DEVICE_DISCOVERY_UPDATE"; break;
281  case BTRMGR_EVENT_DEVICE_DISCOVERY_COMPLETE : event = "DEVICE_DISCOVERY_COMPLETE"; break;
282  case BTRMGR_EVENT_DEVICE_PAIRING_COMPLETE : event = "DEVICE_PAIRING_COMPLETE"; break;
283  case BTRMGR_EVENT_DEVICE_UNPAIRING_COMPLETE : event = "DEVICE_UNPAIRING_COMPLETE"; break;
284  case BTRMGR_EVENT_DEVICE_CONNECTION_COMPLETE : event = "DEVICE_CONNECTION_COMPLETE"; break;
285  case BTRMGR_EVENT_DEVICE_DISCONNECT_COMPLETE : event = "DEVICE_DISCONNECT_COMPLETE"; break;
286  case BTRMGR_EVENT_DEVICE_PAIRING_FAILED : event = "DEVICE_PAIRING_FAILED"; break;
287  case BTRMGR_EVENT_DEVICE_UNPAIRING_FAILED : event = "DEVICE_UNPAIRING_FAILED"; break;
288  case BTRMGR_EVENT_DEVICE_CONNECTION_FAILED : event = "DEVICE_CONNECTION_FAILED"; break;
289  case BTRMGR_EVENT_DEVICE_DISCONNECT_FAILED : event = "DEVICE_DISCONNECT_FAILED"; break;
290  case BTRMGR_EVENT_RECEIVED_EXTERNAL_PAIR_REQUEST : event = "RECEIVED_EXTERNAL_PAIR_REQUEST"; break;
291  case BTRMGR_EVENT_RECEIVED_EXTERNAL_CONNECT_REQUEST : event = "RECEIVED_EXTERNAL_CONNECT_REQUEST"; break;
292  case BTRMGR_EVENT_DEVICE_FOUND : event = "DEVICE_FOUND"; break;
293  case BTRMGR_EVENT_MEDIA_TRACK_STARTED : event = "MEDIA_TRACK_STARTED"; break;
294  case BTRMGR_EVENT_MEDIA_TRACK_PLAYING : event = "MEDIA_TRACK_PLAYING"; break;
295  case BTRMGR_EVENT_MEDIA_TRACK_PAUSED : event = "MEDIA_TRACK_PAUSED"; break;
296  case BTRMGR_EVENT_MEDIA_TRACK_STOPPED : event = "MEDIA_TRACK_STOPPED"; break;
297  case BTRMGR_EVENT_MEDIA_TRACK_POSITION : event = "MEDIA_TRACK_POSITION"; break;
298  case BTRMGR_EVENT_MEDIA_TRACK_CHANGED : event = "MEDIA_TRACK_CHANGED"; break;
299  case BTRMGR_EVENT_MEDIA_PLAYBACK_ENDED : event = "MEDIA_PLAYBACK_ENDED"; break;
300  case BTRMGR_EVENT_DEVICE_OP_READY : event = "DEVICE_OP_READY"; break;
301  case BTRMGR_EVENT_DEVICE_OP_INFORMATION : event = "DEVICE_OP_INFORMATION"; break;
302  case BTRMGR_EVENT_MEDIA_PLAYER_NAME : event = "MEDIA_PLAYER_NAME"; break;
303  case BTRMGR_EVENT_MEDIA_PLAYER_VOLUME : event = "MEDIA_PLAYER_VOLUME"; break;
304  case BTRMGR_EVENT_MEDIA_PLAYER_EQUALIZER_OFF : event = "MEDIA_PLAYER_EQUALIZER_OFF"; break;
305  case BTRMGR_EVENT_MEDIA_PLAYER_EQUALIZER_ON : event = "MEDIA_PLAYER_EQUALIZER_ON"; break;
306  case BTRMGR_EVENT_MEDIA_PLAYER_SHUFFLE_OFF : event = "MEDIA_PLAYER_SHUFFLE_OFF"; break;
307  case BTRMGR_EVENT_MEDIA_PLAYER_SHUFFLE_ALLTRACKS : event = "MEDIA_PLAYER_SHUFFLE_ALLTRACKS"; break;
308  case BTRMGR_EVENT_MEDIA_PLAYER_SHUFFLE_GROUP : event = "MEDIA_PLAYER_SHUFFLE_GROUP"; break;
309  case BTRMGR_EVENT_MEDIA_PLAYER_REPEAT_OFF : event = "MEDIA_PLAYER_REPEAT_OFF"; break;
310  case BTRMGR_EVENT_MEDIA_PLAYER_REPEAT_SINGLETRACK : event = "MEDIA_PLAYER_REPEAT_SINGLETRACK"; break;
311  case BTRMGR_EVENT_MEDIA_PLAYER_REPEAT_ALLTRACKS : event = "MEDIA_PLAYER_REPEAT_ALLTRACKS"; break;
312  case BTRMGR_EVENT_MEDIA_PLAYER_REPEAT_GROUP : event = "MEDIA_PLAYER_REPEAT_GROUP"; break;
313  case BTRMGR_EVENT_MEDIA_ALBUM_INFO : event = "MEDIA_PLAYER_ALBUM_INFO"; break;
314  case BTRMGR_EVENT_MEDIA_ARTIST_INFO : event = "MEDIA_PLAYER_ARTIST_INFO"; break;
315  case BTRMGR_EVENT_MEDIA_GENRE_INFO : event = "MEDIA_PLAYER_GENRE_INFO"; break;
316  case BTRMGR_EVENT_MEDIA_COMPILATION_INFO : event = "MEDIA_PLAYER_COMPILATION_INFO"; break;
317  case BTRMGR_EVENT_MEDIA_PLAYLIST_INFO : event = "MEDIA_PLAYER_PLAYLIST_INFO"; break;
318  case BTRMGR_EVENT_MEDIA_TRACKLIST_INFO : event = "MEDIA_PLAYER_TRACKLIST_INFO"; break;
319  case BTRMGR_EVENT_MEDIA_PLAYER_MUTE : event = "MEDIA_PLAYER_MUTE"; break;
320  case BTRMGR_EVENT_MEDIA_PLAYER_UNMUTE : event = "MEDIA_PLAYER_UNMUTE"; break;
321  case BTRMGR_EVENT_DEVICE_MEDIA_STATUS : event = "DEVICE_MEDIA_STATUS"; break;
322  default : event = "##INVALID##";
323  }
324  return event;
325 }
326 
327 
328 BTRMGR_Result_t eventCallback (BTRMGR_EventMessage_t event)
329 {
330 #if 0
331  printf ("\n\t@@@@@@@@ %s : %s eventCallback :::: Event ID %d @@@@@@@@\n", BTRMGR_GetDeviceTypeAsString(event.m_pairedDevice.m_deviceType)
332  , event.m_pairedDevice.m_name
333  , event.m_eventType);
334 #endif
335  switch(event.m_eventType) {
336  case BTRMGR_EVENT_DEVICE_OUT_OF_RANGE:
337  printf("\tReceived %s Event from BTRMgr\n", getEventAsString(event.m_eventType));
338  printf("\tYour device %s has either been Lost or Out of Range\n", event.m_pairedDevice.m_name);
339  break;
340  case BTRMGR_EVENT_DEVICE_FOUND:
341  printf("\tReceived %s Event from BTRMgr\n", getEventAsString(event.m_eventType));
342  printf("\tYour device %s is Up and Ready\n", event.m_pairedDevice.m_name);
343 
344  if(event.m_pairedDevice.m_isLastConnectedDevice) {
345  if( 20 == uselection ) {
346  printf("\tDo you want to Connect? (1 for Yes / 0 for No)\n\t");
347  if ( getUserSelection() ) {
348  if (BTRMGR_StartAudioStreamingOut(0, event.m_pairedDevice.m_deviceHandle, 1) == BTRMGR_RESULT_SUCCESS)
349  printf ("\tConnection Success....\n");
350  else
351  printf ("\tConnection Failed.....\n");
352  }
353  else {
354  printf ("\tDevice Connection skipped\n");
355  }
356  wait = 0;
357  }
358  else {
359  printf("\tDefault Action: Accept connection from Last connected device..\n");
360  BTRMGR_StartAudioStreamingOut(0, event.m_pairedDevice.m_deviceHandle, 1);
361  }
362  }
363  break;
364  case BTRMGR_EVENT_RECEIVED_EXTERNAL_PAIR_REQUEST:
365  printf ("\tReceiver External Pair Request\n");
366  printf ("\t DevHandle = %lld\n", event.m_externalDevice.m_deviceHandle);
367  printf ("\t DevName = %s\n", event.m_externalDevice.m_name);
368  printf ("\t DevAddr = %s\n", event.m_externalDevice.m_deviceAddress);
369  printf ("\t PassCode = %06d\n", event.m_externalDevice.m_externalDevicePIN);
370  if (event.m_externalDevice.m_requestConfirmation) {
371  printf ("\t Enter Option 21 to Accept Pairing Request\n");
372  printf ("\t Enter Option 22 to Deny Pairing Request\n");
373  gDeviceHandle = event.m_externalDevice.m_deviceHandle;
374  }
375  else {
376  printf("\n\n\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
377  printf("\tEnter PIN: %06d in Your \"%s\" to make them paired\n", event.m_externalDevice.m_externalDevicePIN, event.m_externalDevice.m_name);
378  printf("\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n");
379  }
380  break;
381  case BTRMGR_EVENT_RECEIVED_EXTERNAL_CONNECT_REQUEST:
382  printf ("\tReceiver External Connect Request\n");
383  printf ("\t DevHandle = %lld\n", event.m_externalDevice.m_deviceHandle);
384  printf ("\t DevName = %s\n", event.m_externalDevice.m_name);
385  printf ("\t DevAddr = %s\n", event.m_externalDevice.m_deviceAddress);
386  printf ("\t Enter Option 23 to Accept Connect Request\n");
387  printf ("\t Enter Option 24 to Deny Connect Request\n");
388  gDeviceHandle = event.m_externalDevice.m_deviceHandle;
389  break;
390  case BTRMGR_EVENT_RECEIVED_EXTERNAL_PLAYBACK_REQUEST:
391  printf ("\tReceiver External Playback Request\n");
392  printf ("\t DevHandle = %lld\n", event.m_externalDevice.m_deviceHandle);
393  printf ("\t DevName = %s\n", event.m_externalDevice.m_name);
394  printf ("\t DevAddr = %s\n", event.m_externalDevice.m_deviceAddress);
395  printf ("\t Enter Option 25 to Accept Playback Request\n");
396  printf ("\t Enter Option 26 to Deny Playback Request\n");
397  gDeviceHandle = event.m_externalDevice.m_deviceHandle;
398  break;
399  case BTRMGR_EVENT_DEVICE_PAIRING_COMPLETE:
400  case BTRMGR_EVENT_DEVICE_PAIRING_FAILED:
401  printf("\tReceived %s %s Event from BTRMgr\n", event.m_discoveredDevice.m_name, getEventAsString(event.m_eventType));
402  printf("\t DevHandle = %lld\n", event.m_discoveredDevice.m_deviceHandle);
403  printf("\t DevType = %s\n", BTRMGR_GetDeviceTypeAsString(event.m_discoveredDevice.m_deviceType));
404  printf("\t DevAddr = %s\n", event.m_discoveredDevice.m_deviceAddress);
405  break;
406  case BTRMGR_EVENT_DEVICE_UNPAIRING_COMPLETE:
407  case BTRMGR_EVENT_DEVICE_UNPAIRING_FAILED:
408  case BTRMGR_EVENT_DEVICE_CONNECTION_FAILED:
409  case BTRMGR_EVENT_DEVICE_DISCONNECT_FAILED:
410  case BTRMGR_EVENT_DEVICE_CONNECTION_COMPLETE:
411  case BTRMGR_EVENT_DEVICE_DISCONNECT_COMPLETE:
412  printf("\tReceived %s %s Event from BTRMgr\n", event.m_pairedDevice.m_name, getEventAsString(event.m_eventType));
413  printf("\t DevHandle = %lld\n", event.m_pairedDevice.m_deviceHandle);
414  printf("\t DevType = %s\n", BTRMGR_GetDeviceTypeAsString(event.m_pairedDevice.m_deviceType));
415  printf("\t DevAddr = %s\n", event.m_pairedDevice.m_deviceAddress);
416  break;
417  case BTRMGR_EVENT_MEDIA_TRACK_STARTED:
418  case BTRMGR_EVENT_MEDIA_TRACK_PLAYING:
419  case BTRMGR_EVENT_MEDIA_TRACK_PAUSED:
420  case BTRMGR_EVENT_MEDIA_TRACK_STOPPED:
421  case BTRMGR_EVENT_MEDIA_TRACK_POSITION:
422  printf("\t[%s] at position %d.%02d of %d.%02d\n", getEventAsString(event.m_eventType)
423  , event.m_mediaInfo.m_mediaPositionInfo.m_mediaPosition/60000
424  , (event.m_mediaInfo.m_mediaPositionInfo.m_mediaPosition/1000)%60
425  , event.m_mediaInfo.m_mediaPositionInfo.m_mediaDuration/60000
426  , (event.m_mediaInfo.m_mediaPositionInfo.m_mediaDuration/1000)%60);
427  break;
428  case BTRMGR_EVENT_MEDIA_TRACK_CHANGED:
429  printf("\tRecieved %s Event from BTRMgr\n", getEventAsString(event.m_eventType));
430  printf("\tDevice %s changed track successfully\n", event.m_mediaInfo.m_name);
431  printf ("\t---Current Media Track Info--- \n"
432  "\tAlbum : %s\n"
433  "\tArtist : %s\n"
434  "\tTitle : %s\n"
435  "\tGenre : %s\n"
436  "\tNumberOfTracks : %d\n"
437  "\tTrackNumber : %d\n"
438  "\tDuration : %d\n\n"
439  , event.m_mediaInfo.m_mediaTrackInfo.pcAlbum
440  , event.m_mediaInfo.m_mediaTrackInfo.pcArtist
441  , event.m_mediaInfo.m_mediaTrackInfo.pcTitle
442  , event.m_mediaInfo.m_mediaTrackInfo.pcGenre
443  , event.m_mediaInfo.m_mediaTrackInfo.ui32NumberOfTracks
444  , event.m_mediaInfo.m_mediaTrackInfo.ui32TrackNumber
445  , event.m_mediaInfo.m_mediaTrackInfo.ui32Duration);
446 
447  break;
448  case BTRMGR_EVENT_MEDIA_PLAYBACK_ENDED:
449  printf("\tRecieved %s Event from BTRMgr\n", getEventAsString(event.m_eventType));
450  printf("\tDevice %s ended streaming successfully\n", event.m_mediaInfo.m_name);
451  break;
452  case BTRMGR_EVENT_DEVICE_OP_READY:
453  printf("\tRecieved %s Event from BTRMgr\n", getEventAsString(event.m_eventType));
454  printf("\tDevice %s Op Ready\n", event.m_deviceOpInfo.m_name);
455  break;
456  case BTRMGR_EVENT_DEVICE_OP_INFORMATION:
457  printf("\tRecieved %s Event from BTRMgr\n", getEventAsString(event.m_eventType));
458  printf("\tDevice %s Op Information\n", event.m_deviceOpInfo.m_name);
459  printf("\tUUID is %s\n", event.m_deviceOpInfo.m_uuid);
460  if (BTRMGR_DEVICE_TYPE_TILE == event.m_deviceOpInfo.m_deviceType)
461  {
462  printf("\t%s\n", event.m_deviceOpInfo.m_notifyData);
463  }
464  else if(BTRMGR_LE_OP_WRITE_VALUE == event.m_deviceOpInfo.m_leOpType)
465  {
466  printf("\t%s\n", event.m_deviceOpInfo.m_writeData);
467  {
468  BTRMGR_SysDiagInfo(0, event.m_deviceOpInfo.m_uuid, event.m_deviceOpInfo.m_writeData, event.m_deviceOpInfo.m_leOpType);
469  }
470  }
471  else if (BTRMGR_LE_OP_READ_VALUE == event.m_deviceOpInfo.m_leOpType)
472  {
473  BTRMGR_SysDiagInfo(0, event.m_deviceOpInfo.m_uuid, event.m_deviceOpInfo.m_writeData, event.m_deviceOpInfo.m_leOpType);
474  printf("Writing %s for UUID %s\n", event.m_deviceOpInfo.m_writeData, event.m_deviceOpInfo.m_uuid);
475 
476  /* Send event response */
477  BTRMGR_EventResponse_t lstBtrMgrEvtRsp;
478 
479  memset(&lstBtrMgrEvtRsp, 0, sizeof(lstBtrMgrEvtRsp));
480  lstBtrMgrEvtRsp.m_eventResp = 1;
481  lstBtrMgrEvtRsp.m_eventType = BTRMGR_EVENT_DEVICE_OP_INFORMATION;
482  strncpy(lstBtrMgrEvtRsp.m_writeData, event.m_deviceOpInfo.m_writeData, BTRMGR_MAX_DEV_OP_DATA_LEN - 1);
483  if (BTRMGR_RESULT_SUCCESS != BTRMGR_SetEventResponse(0, &lstBtrMgrEvtRsp)) {
484  printf("Failed to send event response");
485  }
486  gDeviceHandle = 0;
487  }
488  break;
489  case BTRMGR_EVENT_DEVICE_DISCOVERY_UPDATE:
490  printf ("\n\tDiscovered %s device of type %s\n", event.m_discoveredDevice.m_name, BTRMGR_GetDeviceTypeAsString(event.m_discoveredDevice.m_deviceType));
491  break;
492  case BTRMGR_EVENT_DEVICE_MEDIA_STATUS:
493  printf("\n\t[%s] set %s Vol %d Mute %d Ctrl %d %% \n", event.m_mediaInfo.m_name, getEventAsString(event.m_eventType), event.m_mediaInfo.m_mediaDevStatus.m_ui8mediaDevVolume, event.m_mediaInfo.m_mediaDevStatus.m_ui8mediaDevMute, event.m_mediaInfo.m_mediaDevStatus.m_enmediaCtrlCmd);
494  break;
495  case BTRMGR_EVENT_MEDIA_PLAYER_NAME:
496  printf("\n\t[%s] set %s %s \n", event.m_mediaInfo.m_name, getEventAsString(event.m_eventType), event.m_mediaInfo.m_mediaPlayerName);
497  break;
498  case BTRMGR_EVENT_MEDIA_PLAYER_VOLUME:
499  printf("\n\t[%s] set %s %d%% \n", event.m_mediaInfo.m_name, getEventAsString(event.m_eventType), event.m_mediaInfo.m_mediaPlayerVolume);
500  break;
501  case BTRMGR_EVENT_MEDIA_PLAYER_EQUALIZER_OFF:
502  case BTRMGR_EVENT_MEDIA_PLAYER_EQUALIZER_ON:
503  case BTRMGR_EVENT_MEDIA_PLAYER_SHUFFLE_OFF:
504  case BTRMGR_EVENT_MEDIA_PLAYER_SHUFFLE_ALLTRACKS:
505  case BTRMGR_EVENT_MEDIA_PLAYER_SHUFFLE_GROUP:
506  case BTRMGR_EVENT_MEDIA_PLAYER_REPEAT_OFF:
507  case BTRMGR_EVENT_MEDIA_PLAYER_REPEAT_SINGLETRACK:
508  case BTRMGR_EVENT_MEDIA_PLAYER_REPEAT_ALLTRACKS:
509  case BTRMGR_EVENT_MEDIA_PLAYER_REPEAT_GROUP:
510  printf("\n\t[%s] set %s\n", event.m_mediaInfo.m_name, getEventAsString(event.m_eventType));
511  break;
512  break;
513  case BTRMGR_EVENT_MEDIA_ALBUM_INFO:
514  case BTRMGR_EVENT_MEDIA_ARTIST_INFO:
515  case BTRMGR_EVENT_MEDIA_GENRE_INFO:
516  case BTRMGR_EVENT_MEDIA_COMPILATION_INFO:
517  case BTRMGR_EVENT_MEDIA_PLAYLIST_INFO:
518  case BTRMGR_EVENT_MEDIA_TRACKLIST_INFO:
519  case BTRMGR_EVENT_MEDIA_TRACK_INFO:
520  if (event.m_mediaInfo.m_mediaTrackListInfo.m_mediaElementInfo[0].m_IsPlayable) {
521  printf("\t%50s\t\t%020llu\n", event.m_mediaInfo.m_mediaTrackListInfo.m_mediaElementInfo[0].m_mediaTrackInfo.pcTitle
522  , event.m_mediaInfo.m_mediaTrackListInfo.m_mediaElementInfo[0].m_mediaElementHdl);
523  }
524  else {
525  printf("\t%50s\t\t%020llu\n", event.m_mediaInfo.m_mediaTrackListInfo.m_mediaElementInfo[0].m_mediaElementName
526  , event.m_mediaInfo.m_mediaTrackListInfo.m_mediaElementInfo[0].m_mediaElementHdl);
527  }
528  break;
529 
530  default:
531  printf("\tReceived %s Event from BTRMgr\n", getEventAsString(event.m_eventType));
532  break;
533  }
534 
535  return BTRMGR_RESULT_SUCCESS;
536 }
537 
538 
539 int main(int argc, char *argv[])
540 {
541  BTRMGR_Result_t rc = BTRMGR_RESULT_SUCCESS;
542  int loop = 1, i = 0;
543  char array[64] = ""; //CID 23413: Out-of-bounds access
544  BTRMgrDeviceHandle handle = 0;
545  int counter;
546  size_t sz;
547 
548  rc = BTRMGR_Init();
549 
550  if (BTRMGR_RESULT_SUCCESS != rc)
551  {
552  printf ("Failed to init BTRMgr.. Quiting.. \n");
553  loop = 0;
554  return 0;
555  }
556 
557  BTRMGR_RegisterEventCallback (eventCallback);
558  if(argc==1){
559  printf("\nNo Extra Command Line Argument Passed Other Than Program Name");
560  cliDisabled = 1;
561  }
562  else
563  {
564  printf("\n Executing in CLI mode\n");
565  printOptionsCli();
566  gArgv = malloc(argc * sizeof (char*));
567  gArgc = argc;
568  for (counter = 0; counter < argc; ++counter) {
569  sz = strlen(argv[counter]) + 1;
570  gArgv[counter] = malloc(sz * sizeof (char));
571  strcpy(gArgv[counter], argv[counter]);
572  }
573 
574  for (counter = 0; counter < argc; ++counter) {
575  printf("%s\n", gArgv[counter]);
576  }
577 
578  }
579  do
580  {
581  printOptions();
582  i = getUserSelection();
583  switch (i)
584  {
585  case 1:
586  {
587  unsigned char numOfAdapters = 0;
588  rc = BTRMGR_GetNumberOfAdapters(&numOfAdapters);
589  if (BTRMGR_RESULT_SUCCESS != rc)
590  printf ("failed\n");
591  else
592  printf ("\nSuccess.... Count = %d\n", numOfAdapters);
593  }
594  break;
595  case 2:
596  {
597  memset (array, '\0', sizeof(array));
598  printf ("Please Enter the name that you want to set to your adapter\t: ");
599  getString(array);
600 
601  printf ("We received @@%s@@ from you.. Hope this is correct. Let me try to set it..\n", array);
602  rc = BTRMGR_SetAdapterName(0, array);
603  if (BTRMGR_RESULT_SUCCESS != rc)
604  printf ("failed\n");
605  else
606  printf ("\nSuccess....\n");
607  }
608  break;
609  case 3:
610  {
611  memset (array, '\0', sizeof(array));
612  rc = BTRMGR_GetAdapterName(0, array);
613  if (BTRMGR_RESULT_SUCCESS != rc)
614  printf ("failed\n");
615  else
616  printf ("We received @@%s@@\n", array);
617  }
618  break;
619  case 4:
620  {
621  unsigned char power_status = 0;
622 
623  printf ("Please set the power status \t");
624  power_status = (unsigned char) getUserSelection();
625 
626  rc = BTRMGR_SetAdapterPowerStatus(0, power_status);
627  if (BTRMGR_RESULT_SUCCESS != rc)
628  printf ("failed\n");
629  else
630  printf ("Success\n");
631  }
632  break;
633  case 5:
634  {
635  unsigned char power_status = 0;
636 
637  rc = BTRMGR_GetAdapterPowerStatus (0, &power_status);
638  if (BTRMGR_RESULT_SUCCESS != rc)
639  printf ("failed\n");
640  else
641  printf ("Success; Status = %u\n", power_status);
642  }
643  break;
644  case 6:
645  {
646  unsigned char power_status = 0;
647  int timeout = -1;
648 
649  printf ("Please enter 1 or 0 to Make it Discoverable ON or OFF \t");
650  power_status = (unsigned char) getUserSelection();
651 
652  printf ("Please set the timeout for the discoverable \t");
653  timeout = (int) getUserSelection();
654  printf ("timeout = %d\t\n",timeout);
655 
656  rc = BTRMGR_SetAdapterDiscoverable(0, power_status, timeout);
657  if (BTRMGR_RESULT_SUCCESS != rc)
658  printf ("failed\n");
659  else
660  printf ("Success;\n");
661  }
662  break;
663  case 7:
664  {
665  unsigned char power_status = 0;
666 
667  rc = BTRMGR_IsAdapterDiscoverable(0, &power_status);
668  if (BTRMGR_RESULT_SUCCESS != rc)
669  printf ("failed\n");
670  else
671  printf ("Success; Status = %u\n", power_status);
672  }
673  break;
674  case 8:
675  {
676  int ch = 0;
677  BTRMGR_DeviceOperationType_t discoveryType = BTRMGR_DEVICE_OP_TYPE_AUDIO_OUTPUT;
678  printf ("Enter Scan Type : [0 - Normal(BR/EDR) | 1 - LE (BLE) | 2 - HID ]\n");
679  ch = getDeviceSelection();
680  if (0 == ch)
681  discoveryType = BTRMGR_DEVICE_OP_TYPE_AUDIO_OUTPUT;
682  else if (1 == ch)
683  discoveryType = BTRMGR_DEVICE_OP_TYPE_LE;
684  else if (2 == ch)
685  discoveryType = BTRMGR_DEVICE_OP_TYPE_HID;
686 
687  rc = BTRMGR_StartDeviceDiscovery(0, discoveryType);
688  if (BTRMGR_RESULT_SUCCESS != rc)
689  printf ("failed\n");
690  else
691  printf ("Success;\n");
692  }
693  break;
694  case 9:
695  {
696  int ch = 0;
697  BTRMGR_DeviceOperationType_t discoveryType = BTRMGR_DEVICE_OP_TYPE_AUDIO_OUTPUT;
698  printf ("Enter Scan Type : [0 - Normal(BR/EDR) | 1 - LE (BLE) | 2 - HID ]\n");
699  ch = getDeviceSelection();
700  if (0 == ch)
701  discoveryType = BTRMGR_DEVICE_OP_TYPE_AUDIO_OUTPUT;
702  else if (1 == ch)
703  discoveryType = BTRMGR_DEVICE_OP_TYPE_LE;
704  else if (2 == ch)
705  discoveryType = BTRMGR_DEVICE_OP_TYPE_HID;
706 
707  rc = BTRMGR_StopDeviceDiscovery(0, discoveryType);
708  if (BTRMGR_RESULT_SUCCESS != rc)
709  printf ("failed\n");
710  else
711  printf ("Success;\n");
712  }
713  break;
714  case 10:
715  {
716  BTRMGR_DiscoveredDevicesList_t discoveredDevices;
717 
718  memset (&discoveredDevices, 0, sizeof(discoveredDevices));
719  rc = BTRMGR_GetDiscoveredDevices(0, &discoveredDevices);
720  if (BTRMGR_RESULT_SUCCESS != rc)
721  printf ("failed\n");
722  else
723  {
724  int j = 0;
725  printf ("\nSuccess.... Discovered Devices (%d) are, \n", discoveredDevices.m_numOfDevices);
726  printf ("\n\tSN %-17s %-30s %-17s %s\n\n", "Device Id", "Device Name", "Device Address", "Device Type");
727  for (; j< discoveredDevices.m_numOfDevices; j++)
728  {
729  printf ("\t%02d %-17llu %-30s %17s %s\n", j,
730  discoveredDevices.m_deviceProperty[j].m_deviceHandle,
731  discoveredDevices.m_deviceProperty[j].m_name,
732  discoveredDevices.m_deviceProperty[j].m_deviceAddress,
733  BTRMGR_GetDeviceTypeAsString(discoveredDevices.m_deviceProperty[j].m_deviceType));
734  }
735  printf ("\n\n");
736  }
737  }
738  break;
739  case 11:
740  {
741  handle = 0;
742  printf ("Please Enter the device Handle number of the device that you want to pair \t: ");
743  handle = getDeviceSelection();
744 
745  rc = BTRMGR_PairDevice(0, handle);
746  if (BTRMGR_RESULT_SUCCESS != rc)
747  printf ("failed\n");
748  else
749  printf ("\nSuccess....\n");
750  }
751  break;
752  case 12:
753  {
754  handle = 0;
755  printf ("Please Enter the device Handle number of the device that you want to Unpair \t: ");
756  handle = getDeviceSelection();
757 
758  rc = BTRMGR_UnpairDevice(0, handle);
759  if (BTRMGR_RESULT_SUCCESS != rc)
760  printf ("failed\n");
761  else
762  printf ("\nSuccess....\n");
763  }
764  break;
765  case 13:
766  {
767  BTRMGR_PairedDevicesList_t pairedDevices;
768 
769  memset (&pairedDevices, 0, sizeof(pairedDevices));
770  rc = BTRMGR_GetPairedDevices(0, &pairedDevices);
771  if (BTRMGR_RESULT_SUCCESS != rc)
772  printf ("failed\n");
773  else
774  {
775  int j = 0;
776  printf ("\nSuccess.... Paired Devices (%d) are, \n", pairedDevices.m_numOfDevices);
777  printf ("\n\tSN %-17s %-30s %-17s %s\n\n", "Device Id", "Device Name", "Device Address", "Device Type");
778  for (; j< pairedDevices.m_numOfDevices; j++)
779  {
780  printf ("\t%02d %-17llu %-30s %17s %s\n", j,
781  pairedDevices.m_deviceProperty[j].m_deviceHandle,
782  pairedDevices.m_deviceProperty[j].m_name,
783  pairedDevices.m_deviceProperty[j].m_deviceAddress,
784  BTRMGR_GetDeviceTypeAsString(pairedDevices.m_deviceProperty[j].m_deviceType));
785  }
786  printf ("\n\n");
787  }
788  }
789  break;
790  case 14:
791  {
792  handle = 0;
793  int ch = 0;
794  printf ("Please Enter the device Handle number of the device that you want to Connect \t: ");
795  handle = getDeviceSelection();
796  printf ("Enter Device ConnectAs Type : [0 - AUDIO_OUTPUT | 1 - AUDIO_INPUT | 2 - LE | 3 - HID | 4 - UNKNOWN]\n");
797  ch = getDeviceSelection();
798 
799  rc = BTRMGR_ConnectToDevice(0, handle, (1 << ch));
800  if (BTRMGR_RESULT_SUCCESS != rc)
801  printf ("failed\n");
802  else
803  printf ("\nSuccess....\n");
804  }
805  break;
806  case 15:
807  {
808  handle = 0;
809  printf ("Please Enter the device Handle number of the device that you want to DisConnect \t: ");
810  handle = getDeviceSelection();
811 
812  rc = BTRMGR_DisconnectFromDevice(0, handle);
813  if (BTRMGR_RESULT_SUCCESS != rc)
814  printf ("failed\n");
815  else
816  printf ("\nSuccess....\n");
817  }
818  break;
819  case 16:
820  {
821  BTRMGR_DevicesProperty_t deviceProperty;
822  int i = 0;
823 
824  handle = 0;
825  memset (array, '\0', sizeof(array));
826  memset (&deviceProperty, 0, sizeof(deviceProperty));
827 
828  printf ("Please Enter the device Handle number of the device that you want to query \t: ");
829  handle = getDeviceSelection();
830 
831  rc = BTRMGR_GetDeviceProperties(0, handle, &deviceProperty);
832  if (BTRMGR_RESULT_SUCCESS != rc)
833  printf ("failed\n");
834  else
835  {
836  printf ("\nSuccess.... Properties are, \n");
837  printf ("Handle : %llu\n", deviceProperty.m_deviceHandle);
838  printf ("Name : %s\n", deviceProperty.m_name);
839  printf ("Address : %s\n", deviceProperty.m_deviceAddress);
840  printf ("RSSI : %d\n", deviceProperty.m_rssi);
841  printf ("Paired : %d\n", deviceProperty.m_isPaired);
842  printf ("Connected : %d\n", deviceProperty.m_isConnected);
843  printf ("Vendor ID : %u\n", deviceProperty.m_vendorID);
844  for (i = 0; i < deviceProperty.m_serviceInfo.m_numOfService; i++)
845  {
846  printf ("Profile ID : 0x%.4x\n", deviceProperty.m_serviceInfo.m_profileInfo[i].m_uuid);
847  printf ("Profile Name : %s\n", deviceProperty.m_serviceInfo.m_profileInfo[i].m_profile);
848  }
849  printf ("######################\n\n\n");
850  }
851  }
852  break;
853  case 17:
854  {
855  BTRMGR_DeviceOperationType_t stream_pref;
856 
857  handle = 0;
858  printf ("Please Enter the device Handle number of the device that you want to start play\t: ");
859  handle = getDeviceSelection();
860 
861  printf ("Please set the Streaming Pref\t[0 - AUDIO_OUTPUT | 1 - AUDIO_INPUT | 2 - LE ]\n");
862  stream_pref = (BTRMGR_DeviceOperationType_t) getUserSelection();
863 
864 
865  rc = BTRMGR_StartAudioStreamingOut(0, handle, (1 << stream_pref));
866  if (BTRMGR_RESULT_SUCCESS != rc)
867  printf ("failed\n");
868  else
869  printf ("\nSuccess.... \n");
870  }
871  break;
872  case 18:
873  {
874  handle = 0;
875  printf ("Please Enter the device Handle number of the device that you want to stop play\t: ");
876  handle = getDeviceSelection();
877 
878  rc = BTRMGR_StopAudioStreamingOut(0, handle);
879  if (BTRMGR_RESULT_SUCCESS != rc)
880  printf ("failed\n");
881  else
882  printf ("\nSuccess.... \n");
883  }
884  break;
885  case 19:
886  {
887  unsigned char index = 0;
888  rc = BTRMGR_IsAudioStreamingOut(0, &index);
889  if (BTRMGR_RESULT_SUCCESS != rc)
890  printf ("failed\n");
891  else
892  printf ("\nSuccess....; Streaming status = %u\n", index);
893  }
894  break;
895  case 20:
896  {
897  uselection=20;
898  printf ("\nNow you can power Off and power On to check the auto connection..\n");
899  while(wait) { usleep(1000000); }
900  uselection=0; wait=1;
901  }
902  break;
903  case 21:
904  {
905  BTRMGR_EventResponse_t lstBtrMgrEvtRsp;
906  memset(&lstBtrMgrEvtRsp, 0, sizeof(lstBtrMgrEvtRsp));
907 
908  lstBtrMgrEvtRsp.m_deviceHandle = gDeviceHandle;
909  lstBtrMgrEvtRsp.m_eventType = BTRMGR_EVENT_RECEIVED_EXTERNAL_PAIR_REQUEST;
910  lstBtrMgrEvtRsp.m_eventResp = 1;
911 
912  if (BTRMGR_RESULT_SUCCESS != BTRMGR_SetEventResponse(0, &lstBtrMgrEvtRsp)) {
913  printf ("Failed to send event response");
914  }
915  gDeviceHandle = 0;
916  }
917  break;
918  case 22:
919  {
920  BTRMGR_EventResponse_t lstBtrMgrEvtRsp;
921  memset(&lstBtrMgrEvtRsp, 0, sizeof(lstBtrMgrEvtRsp));
922 
923  lstBtrMgrEvtRsp.m_deviceHandle = gDeviceHandle;
924  lstBtrMgrEvtRsp.m_eventType = BTRMGR_EVENT_RECEIVED_EXTERNAL_PAIR_REQUEST;
925  lstBtrMgrEvtRsp.m_eventResp = 0;
926 
927  if (BTRMGR_RESULT_SUCCESS != BTRMGR_SetEventResponse(0, &lstBtrMgrEvtRsp)) {
928  printf ("Failed to send event response");
929  }
930  gDeviceHandle = 0;
931  }
932  break;
933  case 23:
934  {
935  BTRMGR_EventResponse_t lstBtrMgrEvtRsp;
936  memset(&lstBtrMgrEvtRsp, 0, sizeof(lstBtrMgrEvtRsp));
937 
938  lstBtrMgrEvtRsp.m_deviceHandle = gDeviceHandle;
939  lstBtrMgrEvtRsp.m_eventType = BTRMGR_EVENT_RECEIVED_EXTERNAL_CONNECT_REQUEST;
940  lstBtrMgrEvtRsp.m_eventResp = 1;
941 
942  if (BTRMGR_RESULT_SUCCESS != BTRMGR_SetEventResponse(0, &lstBtrMgrEvtRsp)) {
943  printf ("Failed to send event response");
944  }
945  gDeviceHandle = 0;
946  }
947  break;
948  case 24:
949  {
950  BTRMGR_EventResponse_t lstBtrMgrEvtRsp;
951  memset(&lstBtrMgrEvtRsp, 0, sizeof(lstBtrMgrEvtRsp));
952 
953  lstBtrMgrEvtRsp.m_deviceHandle = gDeviceHandle;
954  lstBtrMgrEvtRsp.m_eventType = BTRMGR_EVENT_RECEIVED_EXTERNAL_CONNECT_REQUEST;
955  lstBtrMgrEvtRsp.m_eventResp = 0;
956 
957  if (BTRMGR_RESULT_SUCCESS != BTRMGR_SetEventResponse(0, &lstBtrMgrEvtRsp)) {
958  printf ("Failed to send event response");
959  }
960  gDeviceHandle = 0;
961  }
962  break;
963  case 25:
964  {
965  BTRMGR_EventResponse_t lstBtrMgrEvtRsp;
966  memset(&lstBtrMgrEvtRsp, 0, sizeof(lstBtrMgrEvtRsp));
967 
968  lstBtrMgrEvtRsp.m_deviceHandle = gDeviceHandle;
969  lstBtrMgrEvtRsp.m_eventType = BTRMGR_EVENT_RECEIVED_EXTERNAL_PLAYBACK_REQUEST;
970  lstBtrMgrEvtRsp.m_eventResp = 1;
971 
972  if (BTRMGR_RESULT_SUCCESS != BTRMGR_SetEventResponse(0, &lstBtrMgrEvtRsp)) {
973  printf ("Failed to send event response");
974  }
975  gDeviceHandle = 0;
976  }
977  break;
978  case 26:
979  {
980  BTRMGR_EventResponse_t lstBtrMgrEvtRsp;
981  memset(&lstBtrMgrEvtRsp, 0, sizeof(lstBtrMgrEvtRsp));
982 
983  lstBtrMgrEvtRsp.m_deviceHandle = gDeviceHandle;
984  lstBtrMgrEvtRsp.m_eventType = BTRMGR_EVENT_RECEIVED_EXTERNAL_PLAYBACK_REQUEST;
985  lstBtrMgrEvtRsp.m_eventResp = 0;
986 
987  if (BTRMGR_RESULT_SUCCESS != BTRMGR_SetEventResponse(0, &lstBtrMgrEvtRsp)) {
988  printf ("Failed to send event response");
989  }
990  gDeviceHandle = 0;
991  }
992  break;
993  case 27:
994  {
995  BTRMGR_DeviceOperationType_t stream_pref;
996 
997  handle = 0;
998  printf ("Please Enter the device Handle number of the device that you want to start play from\t: ");
999  handle = getDeviceSelection();
1000 
1001  printf ("Please set the Streaming Pref \t");
1002  stream_pref = (BTRMGR_DeviceOperationType_t) getUserSelection();
1003 
1004 
1005  rc = BTRMGR_StartAudioStreamingIn(0, handle, stream_pref);
1006  if (BTRMGR_RESULT_SUCCESS != rc)
1007  printf ("failed\n");
1008  else
1009  printf ("\nSuccess.... \n");
1010  }
1011  break;
1012  case 28:
1013  {
1014  handle = 0;
1015  printf ("Please Enter the device Handle number of the device that you want to stop play from\t: ");
1016  handle = getDeviceSelection();
1017 
1018  rc = BTRMGR_StopAudioStreamingIn(0, handle);
1019  if (BTRMGR_RESULT_SUCCESS != rc)
1020  printf ("failed\n");
1021  else
1022  printf ("\nSuccess.... \n");
1023  }
1024  break;
1025  case 29:
1026  {
1027  int opt=0;
1028  handle = 0;
1029  printf ("Please Enter the device Handle number of the device\t: ");
1030  handle = getDeviceSelection();
1031  printf ("Please Enter the Media Control Options\n"
1032  "[0 - Play | 1 - Pause | 2 - Stop | 3 - Next | 4 - Previous | 5 - FF | 6 - Rewind]\n"
1033  "[7 - VolUp | 8 - VolDown | 9 - EQZ Off | 10 - EQZ On | 11 - Shuffle Off | 12 - shuffle AllTracks]\n"
1034  "[13 - shuffle Group | 14 - Repeat Off | 15 - Repeat SingleTrack | 16 - Repeat AllTracks]\n"
1035  "[17 - Repeat Group | 21 - MuteON | 22 - MuteOFF ]\n");
1036  opt = getDeviceSelection();
1037 
1038  rc = BTRMGR_MediaControl(0, handle, opt);
1039  if (BTRMGR_RESULT_SUCCESS != rc)
1040  printf ("failed\n");
1041  else
1042  printf ("\nSuccess.... \n");
1043  }
1044  break;
1045  case 30:
1046  {
1047  BTRMGR_MediaTrackInfo_t mediaTrackInfo;
1048  handle = 0;
1049  printf ("Please Enter the device Handle number of the device\t: ");
1050  handle = getDeviceSelection();
1051 
1052  rc = BTRMGR_GetMediaTrackInfo(0, handle, &mediaTrackInfo);
1053  if (BTRMGR_RESULT_SUCCESS != rc)
1054  printf ("failed\n");
1055  else
1056  printf ("\n---Media Track Info--- \n"
1057  "Album : %s\n"
1058  "Artist : %s\n"
1059  "Title : %s\n"
1060  "Genre : %s\n"
1061  "NumberOfTracks : %d\n"
1062  "TrackNumber : %d\n"
1063  "Duration : %d\n\n"
1064  , mediaTrackInfo.pcAlbum
1065  , mediaTrackInfo.pcArtist
1066  , mediaTrackInfo.pcTitle
1067  , mediaTrackInfo.pcGenre
1068  , mediaTrackInfo.ui32NumberOfTracks
1069  , mediaTrackInfo.ui32TrackNumber
1070  , mediaTrackInfo.ui32Duration);
1071 
1072  }
1073  break;
1074  case 31:
1075  {
1076  BTRMGR_MediaPositionInfo_t m_mediaPositionInfo;
1077  handle = 0;
1078  printf ("Please Enter the device Handle number of the device\t: ");
1079  handle = getDeviceSelection();
1080 
1081  rc = BTRMGR_GetMediaCurrentPosition (0, handle, &m_mediaPositionInfo);
1082  if (BTRMGR_RESULT_SUCCESS != rc)
1083  printf ("failed\n");
1084  else
1085  printf ("\nPosition : %d | Duration : %d\n", m_mediaPositionInfo.m_mediaPosition
1086  , m_mediaPositionInfo.m_mediaDuration);
1087  }
1088  break;
1089  case 32:
1090  {
1091  unsigned char index = 0;
1092  rc = BTRMGR_IsAudioStreamingIn(0, &index);
1093  if (BTRMGR_RESULT_SUCCESS != rc)
1094  printf ("failed\n");
1095  else
1096  printf ("\nSuccess....; Streaming status = %u\n", index);
1097  }
1098  break;
1099  case 33:
1100  {
1101  char luuid[BTRMGR_MAX_STR_LEN] = "\0";
1102  unsigned char opt = 0;
1103  handle = 0;
1104  printf ("Please Enter the device Handle number of the device\t: ");
1105  handle = getDeviceSelection();
1106  printf ("Enter the UUID : ");
1107  getString (luuid);
1108  printf ("Select the property to query...\n");
1109  printf ("[0 - Uuid | 1 - Primary | 2 - Device | 3 - Service | 4 - Value |"
1110  " 5 - Notifying | 6 - Flags | 7 -Character]\n");
1111  opt = getDeviceSelection();
1112 
1113  if (!opt) {
1114  BTRMGR_DeviceServiceList_t deviceServiceList;
1115  int i=0;
1116  if ((rc = BTRMGR_GetLeProperty (0, handle, luuid, opt, (void*)&deviceServiceList)) == BTRMGR_RESULT_SUCCESS) {
1117  if (deviceServiceList.m_numOfService) {
1118  printf("\n\nObtained 'Flag' indices are based on the below mapping..\n"
1119  "0 - read\n"
1120  "1 - write\n"
1121  "2 - encrypt-read\n"
1122  "3 - encrypt-write\n"
1123  "4 - encrypt-authenticated-read\n"
1124  "5 - encrypt-authenticated-write\n"
1125  "6 - secure-read (Server only)\n"
1126  "7 - secure-write (Server only)\n"
1127  "8 - notify\n"
1128  "9 - indicate\n"
1129  "10 - broadcast\n"
1130  "11 - write-without-response\n"
1131  "12 - authenticated-signed-writes\n"
1132  "13 - reliable-write\n"
1133  "14 - writable-auxiliaries\n");
1134 
1135  printf("\n\t%-40s Flag\n", "UUID");
1136  for (; i<deviceServiceList.m_numOfService; i++) {
1137  printf("\n\t%-40s ", deviceServiceList.m_uuidInfo[i].m_uuid);
1138  getBitsToString(deviceServiceList.m_uuidInfo[i].flags);
1139  }
1140  } else {
1141  printf("\n\n\tNo UUIDs found...\n\n");
1142  }
1143  }
1144  } else
1145  if (opt == 1 || opt == 5 ){
1146  unsigned char val;
1147  if ((rc = BTRMGR_GetLeProperty (0, handle, luuid, opt, (void*)&val)) == BTRMGR_RESULT_SUCCESS) {
1148  printf("\nResult : \n\t%d", val);
1149  }
1150  } else
1151  if (opt == 2 || opt == 3 || opt == 4 || opt == 7) {
1152  char val[BTRMGR_MAX_STR_LEN] = "\0";
1153  if ((rc = BTRMGR_GetLeProperty (0, handle, luuid, opt, (void*)&val)) == BTRMGR_RESULT_SUCCESS) {
1154  printf("\nResult : \n\t%s", val);
1155  }
1156  } else
1157  if (opt == 6) {
1158  char val[5][BTRMGR_NAME_LEN_MAX]; int i=0;
1159  memset (val, 0, sizeof(val));
1160  if ((rc = BTRMGR_GetLeProperty (0, handle, luuid, opt, (void*)&val)) == BTRMGR_RESULT_SUCCESS) {
1161  printf("\n Result :");
1162  for(; i<5 && val[i][0]; i++) {
1163  printf("\n\t- %s", val[i]);
1164  }
1165  }
1166  }
1167  if (BTRMGR_RESULT_SUCCESS != rc)
1168  printf ("failed\n");
1169  else
1170  printf ("\nSuccess.... \n");
1171  }
1172  break;
1173  case 34:
1174  {
1175  char luuid[BTRMGR_MAX_STR_LEN] = "\0";
1176  char res[BTRMGR_MAX_STR_LEN] = "\0";
1177  char arg[BTRMGR_MAX_STR_LEN] = "\0";
1178  unsigned char opt = 0;
1179  handle = 0;
1180  printf ("Please Enter the device Handle number of the device\t: ");
1181  handle = getDeviceSelection();
1182  printf ("Enter the Char UUID : ");
1183  getString (luuid);
1184  printf ("Enter Option : [ReadValue - 1 | WriteValue - 2 | StartNotify - 3 | StopNotify - 4]\n");
1185  opt = getDeviceSelection();
1186 
1187  if (opt == 2) {
1188  printf ("Enter the Value to be Written : ");
1189  getString (arg);
1190  }
1191 
1192  rc = BTRMGR_PerformLeOp (0, handle, luuid, opt, arg, res);
1193  if (BTRMGR_RESULT_SUCCESS != rc)
1194  printf ("failed\n");
1195  else {
1196  if (opt == 0) {
1197  printf ("\n\tObtained Value : %s\n", res);
1198  }
1199  printf ("\nSuccess.... \n" );
1200  }
1201  }
1202  break;
1203  case 35:
1204  {
1205  unsigned char index = 0;
1206  rc = BTRMGR_ResetAdapter(index);
1207  if (BTRMGR_RESULT_SUCCESS != rc)
1208  printf ("failed\n");
1209  else
1210  printf ("\nSuccess....; Reset status = %u\n", index);
1211  }
1212  break;
1213  case 36:
1214  {
1215  BTRMGR_DiscoveryStatus_t aeDiscoveryStatus;
1216  BTRMGR_DeviceOperationType_t aenBTRMgrDevOpType;
1217 
1218  rc = BTRMGR_GetDiscoveryStatus (0, &aeDiscoveryStatus, &aenBTRMgrDevOpType);
1219 
1220  if (BTRMGR_RESULT_SUCCESS != rc)
1221  printf ("failed\n");
1222  else
1223  printf ("\nSuccess....; Device Discovery Status = %u and Device Type = %u \n", aeDiscoveryStatus, aenBTRMgrDevOpType);
1224 
1225  }
1226  break;
1227  case 37:
1228  {
1229  BTRMGR_StreamOut_Type_t type = BTRMGR_STREAM_AUXILIARY;
1230 
1231  int ch = 0;
1232  printf ("Enter StreamOut Type : [0 - Primary | 1 - Auxiliary]\n");
1233  ch = getDeviceSelection();
1234  if (0 == ch)
1235  type = BTRMGR_STREAM_PRIMARY;
1236  else if (1 == ch)
1237  type = BTRMGR_STREAM_AUXILIARY;
1238  else
1239  type = BTRMGR_STREAM_AUXILIARY;
1240 
1241  rc = BTRMGR_SetAudioStreamingOutType(0, type);
1242  if (BTRMGR_RESULT_SUCCESS != rc)
1243  printf ("failed\n");
1244  else
1245  printf ("\nSuccess....; Set StreamOut Type = %d \n", type);
1246  }
1247  break;
1248  case 40:
1249  {
1250  /*Connect to Device */
1251  /*Notify to Tile Device in char: 9d410019-35d6-f4dd-ba60-e7bd8dc491c0 */
1252  /*Wrire to Tile Device in char: 9d410018-35d6-f4dd-ba60-e7bd8dc491c0 */
1253  handle = 0;
1254  printf ("Please Enter the Tile device Handle number of the device that you want to Connect \t: ");
1255  handle = getDeviceSelection();
1256 
1257  rc = BTRMGR_ConnectToDevice(0, handle, BTRMGR_DEVICE_OP_TYPE_LE);
1258  if (BTRMGR_RESULT_SUCCESS != rc)
1259  printf ("failed\n");
1260  else
1261  {
1262  sleep(3);
1263  printf ("\nSuccessfully connected to Tile device.\n");
1264  /*Notify to Tile Device in char: 9d410019-35d6-f4dd-ba60-e7bd8dc491c0 */
1265  {
1266  char res[BTRMGR_MAX_STR_LEN] = "\0";
1267  char notifyUuid[] = "9d410019-35d6-f4dd-ba60-e7bd8dc491c0";
1268  char arg[BTRMGR_MAX_STR_LEN] = "\0";
1269  rc = BTRMGR_PerformLeOp (0, handle, notifyUuid, BTRMGR_LE_OP_START_NOTIFY, arg, res);
1270  if (BTRMGR_RESULT_SUCCESS != rc)
1271  printf ("[%d]Failed to set notify.\n", __LINE__);
1272  else
1273  {
1274  printf ("\nSuccessfully set notification. \n" );
1275  sleep(3);
1276  /*Wrire to Tile Device in char: 9d410018-35d6-f4dd-ba60-e7bd8dc491c0 */
1277  char writeCharUuid[] = "9d410018-35d6-f4dd-ba60-e7bd8dc491c0";
1278  char wValue_TOA_CMD_OPEN_CHANNEL[] = "0000000000100000000000000000000000000000";
1279  char wValue_TOA_CMD_READY[] = "0212000000000000000000000000000000000000";
1280  char wValue_TOA_CMD_SONG[] = "020502010300000000";
1281 
1282  rc = BTRMGR_PerformLeOp (0, handle, writeCharUuid, BTRMGR_LE_OP_WRITE_VALUE, wValue_TOA_CMD_OPEN_CHANNEL, res);
1283  if (BTRMGR_RESULT_SUCCESS != rc) {
1284  printf ("[%d]Failed to set TOA_CMD_OPEN_CHANNEL.\n", __LINE__);
1285  }
1286  else {
1287  printf ("\nSuccessfully set TOA_CMD_OPEN_CHANNEL. \n" );
1288  sleep(3);
1289  /* @TODO: On write, need to listen notify response and parse the message to get CID */
1290  rc = BTRMGR_PerformLeOp (0, handle, writeCharUuid, BTRMGR_LE_OP_WRITE_VALUE, wValue_TOA_CMD_READY, res);
1291  if (BTRMGR_RESULT_SUCCESS != rc) {
1292  printf ("[%d]Failed to set TOA_CMD_READY.\n", __LINE__);
1293  }
1294  else
1295  {
1296  printf ("\nSuccessfully set TOA_CMD_OPEN_READY. \n" );
1297  sleep(3);
1298  /* @TODO: On write, need to listen notify response and parse the message to get CID */
1299  rc = BTRMGR_PerformLeOp (0, handle, writeCharUuid, BTRMGR_LE_OP_WRITE_VALUE, wValue_TOA_CMD_SONG, res);
1300  if (BTRMGR_RESULT_SUCCESS != rc) {
1301  printf ("[%d]Failed to set TOA_CMD_SONG.\n", __LINE__);
1302  }
1303  else
1304  {
1305  printf ("\nSuccessfully set TOA_CMD_SONG. \n" );
1306  }
1307  }
1308  }
1309  }
1310  }
1311  }
1312  BTRMGR_DisconnectFromDevice(0, handle);
1313  }
1314  break;
1315  case 41:
1316  {
1317  int choice = 0;
1318 
1319  printf ("\n\nATTENTION! Disconnect all existing AudioIn connection before flipping the AudioIn Service state.\n\n");
1320  printf ("Press 1 to Enable and 0 to Disable AudioIn Service.\n");
1321  if (scanf("%d", &choice)) {
1322  }
1323 
1324 #ifndef BUILD_FOR_PI
1325  WDMP_STATUS status = WDMP_FAILURE;
1326  status = setRFCParameter("btrMgrTest", "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.BTR.AudioIn.Enable",
1327  (choice)? "true" : "false", WDMP_BOOLEAN);
1328 
1329  if (status != WDMP_SUCCESS) {
1330  printf("\nsetRFCParameter Failed : %s\n", getRFCErrorString(status));
1331  }
1332  else
1333 #endif
1334  {
1335  if (choice) {
1336  printf("\nSuccessfully Enabled AudioIn.\n");
1337  }
1338  else {
1339  printf("\nSuccessfully Disabled AudioIn.\n");
1340  }
1341  }
1342  }
1343  break;
1344  case 42:
1345  {
1346  int choice = 0;
1347 
1348  printf ("\n\nATTENTION! Disconnect all existing AudioIn connection before flipping the AudioIn Service state.\n\n");
1349  printf ("Press 1 to Enable and 0 to Disable AudioIn Service.\n");
1350  if (scanf("%d", &choice)) {
1351  }
1352 
1353  rc = BTRMGR_SetAudioInServiceState (0, choice);
1354 
1355  if (BTRMGR_RESULT_SUCCESS == rc) {
1356  if (choice) {
1357  printf("\nSuccessfully Enabled AudioIn.\n");
1358  }
1359  else {
1360  printf("\nSuccessfully Disabled AudioIn.\n");
1361  }
1362  }
1363  else {
1364  printf("\nCall Failed : %d\n", rc);
1365  }
1366  }
1367  break;
1368  case 43:
1369  {
1370  BTRMgrMediaElementHandle mediaElementHdl = 0;
1371  int mediaElementType = 0;
1372  handle = 0;
1373  printf ("\nPlease Enter the device Handle number of the device\t: ");
1374  handle = getDeviceSelection();
1375  printf("\nEnter the Media Browser Element Handle\t: ");
1376  if (scanf("%llu", &mediaElementHdl)) {
1377  }
1378  printf("\n0. Unknown | 1. Album | 2. Artist | 3. Genre | 4. Compilation | 5. PlayList | 6. TrackList | 7.Track"
1379  "\nEnter the Media Element type\t: ");
1380  if (scanf("%d", &mediaElementType)) {
1381  }
1382 
1383  rc = BTRMGR_SetMediaElementActive(0, handle, mediaElementHdl, mediaElementType);
1384 
1385  if (BTRMGR_RESULT_SUCCESS == rc) {
1386  printf ("\nSuccess...\n");
1387  }
1388  else {
1389  printf("\nFailed...\n");
1390  }
1391  }
1392  break;
1393  case 44:
1394  {
1395  BTRMgrMediaElementHandle mediaElementHdl = 0;
1396  unsigned short startIdx = 0;
1397  unsigned short endIdx = 0;
1398  int mediaElementType = 0;
1399  BTRMGR_MediaElementListInfo_t mediaEementListInfo;
1400  handle = 0;
1401  printf ("\nPlease Enter the device Handle number of the device\t: ");
1402  handle = getDeviceSelection();
1403  printf("\nEnter the Media Browser Element Handle\t: ");
1404  if (scanf("%llu", &mediaElementHdl)) {
1405  }
1406  printf("\nEnter the Start index of List\t: ");
1407  if (scanf("%hu", &startIdx)) {
1408  }
1409  printf("\nEnter the End index of List\t: ");
1410  if (scanf("%hu", &endIdx)) {
1411  }
1412  printf("\n0. Unknown | 1. Album | 2. Artist | 3. Genre | 4. Compilation | 5. PlayList | 6. TrackList | 7. Track"
1413  "\nEnter the Media Element type\t: ");
1414  if (scanf("%d", &mediaElementType)) {
1415  }
1416 
1417  memset (&mediaEementListInfo, 0, sizeof(BTRMGR_MediaElementListInfo_t));
1418 
1419  rc = BTRMGR_GetMediaElementList(0, handle, mediaElementHdl, startIdx, endIdx, 0, mediaElementType, &mediaEementListInfo);
1420 
1421  if (BTRMGR_RESULT_SUCCESS == rc) {
1422  unsigned short ui16LoopIdx = 0;
1423  printf ("\nSuccess...\n");
1424 
1425  printf ("\n%4s\t%-20s\t\t%-60sPlayable\n", "SN", "MediaElementId", "MediaElementName");
1426  while (ui16LoopIdx < mediaEementListInfo.m_numberOfElements) {
1427  if (strlen(mediaEementListInfo.m_mediaElementInfo[ui16LoopIdx].m_mediaElementName) > 50) {
1428  strcpy (&mediaEementListInfo.m_mediaElementInfo[ui16LoopIdx].m_mediaElementName[50],"...");
1429  }
1430  printf("\n%4u\t%020llu\t\t%-60s%d", ui16LoopIdx
1431  , mediaEementListInfo.m_mediaElementInfo[ui16LoopIdx].m_mediaElementHdl
1432  , mediaEementListInfo.m_mediaElementInfo[ui16LoopIdx].m_mediaElementName
1433  , mediaEementListInfo.m_mediaElementInfo[ui16LoopIdx].m_IsPlayable);
1434  ui16LoopIdx++;
1435  }
1436  printf ("\n\nRetrived %u Media Elements.\n", mediaEementListInfo.m_numberOfElements);
1437  }
1438  else {
1439  printf("\nFailed...\n");
1440  }
1441  }
1442  break;
1443  case 45:
1444  {
1445  BTRMgrMediaElementHandle mediaElementHdl = 0;
1446  int mediaElementType = 0;
1447  handle = 0;
1448  printf ("\nPlease Enter the device Handle number of the device\t: ");
1449  handle = getDeviceSelection();
1450  printf("\nEnter the Media Element Handle to select\t: ");
1451  if (scanf("%llu", &mediaElementHdl)) {
1452  }
1453  printf("\n0. Unknown | 1. Album | 2. Artist | 3. Genre | 4. Compilation | 5. PlayList | 6. TrackList | 7. Track"
1454  "\nEnter the Media Element type\t: ");
1455  if (scanf("%d", &mediaElementType)) {
1456  }
1457 
1458  rc = BTRMGR_SelectMediaElement (0, handle, mediaElementHdl, mediaElementType);
1459 
1460  if (BTRMGR_RESULT_SUCCESS == rc) {
1461  printf ("\nSuccess...\n");
1462  }
1463  else {
1464  printf("\nFailed...\n");
1465  }
1466  }
1467  break;
1468  case 46:
1469  {
1470  BTRMGR_MediaTrackInfo_t mediaTrackInfo;
1471  BTRMgrMediaElementHandle mediaElementHdl = 0;
1472  handle = 0;
1473  printf ("Please Enter the device Handle number of the device\t: ");
1474  handle = getDeviceSelection();
1475 
1476  printf("\nEnter the Media Browser Element Handle\t: ");
1477  if (scanf("%llu", &mediaElementHdl)) {
1478  }
1479 
1480  rc = BTRMGR_GetMediaElementTrackInfo(0, handle, mediaElementHdl, &mediaTrackInfo);
1481 
1482  if (BTRMGR_RESULT_SUCCESS != rc)
1483  printf ("failed\n");
1484  else
1485  printf ("\n---Media Track Info--- \n"
1486  "Album : %s\n"
1487  "Artist : %s\n"
1488  "Title : %s\n"
1489  "Genre : %s\n"
1490  "NumberOfTracks : %d\n"
1491  "TrackNumber : %d\n"
1492  "Duration : %d\n\n"
1493  , mediaTrackInfo.pcAlbum
1494  , mediaTrackInfo.pcArtist
1495  , mediaTrackInfo.pcTitle
1496  , mediaTrackInfo.pcGenre
1497  , mediaTrackInfo.ui32NumberOfTracks
1498  , mediaTrackInfo.ui32TrackNumber
1499  , mediaTrackInfo.ui32Duration);
1500 
1501  }
1502  break;
1503  case 47:
1504  {
1505  unsigned char ui8volume = 0;
1506  unsigned char mute = 0;
1507  int ch = 0;
1508  int vol = 0;
1509  int mu = 0;
1510  BTRMGR_DeviceOperationType_t Type = BTRMGR_DEVICE_OP_TYPE_AUDIO_OUTPUT;
1511  handle = 0;
1512  printf ("Please Enter the device Handle number of the device\t: ");
1513  handle = getDeviceSelection();
1514  printf ("Enter Device ConnectAs Type : [0 - AUDIO_OUTPUT | 1 - AUDIO_INPUT | 2 - LE | 3 - HID | 4 - UNKNOWN]\n");
1515  ch = getDeviceSelection();
1516  if (0 == ch)
1517  Type = BTRMGR_DEVICE_OP_TYPE_AUDIO_OUTPUT;
1518  else if (1 == ch)
1519  Type = BTRMGR_DEVICE_OP_TYPE_AUDIO_INPUT;
1520  else if (2 == ch)
1521  Type = BTRMGR_DEVICE_OP_TYPE_LE;
1522  else if (3 == ch)
1523  Type = BTRMGR_DEVICE_OP_TYPE_HID;
1524 
1525  printf("\nEnter the Volume value [0 - 255] \t: ");
1526  vol = getDeviceSelection();
1527  printf("\nEnter the Mute [ON - 1 | OFF - 0] \t: ");
1528  mu = getDeviceSelection();
1529  ui8volume = (char) vol;
1530  mute = (char) mu;
1531  rc = BTRMGR_SetDeviceVolumeMute (0, handle, Type, ui8volume, mute);
1532 
1533  if (BTRMGR_RESULT_SUCCESS != rc)
1534  printf ("failed\n");
1535  else
1536  printf ("\n---volume and mute set success--- \n");
1537  }
1538  break;
1539  case 48:
1540  {
1541  unsigned char ui8volume = 0;
1542  unsigned char mute = 0;
1543  int ch = 0;
1544  BTRMGR_DeviceOperationType_t Type = BTRMGR_DEVICE_OP_TYPE_AUDIO_OUTPUT;
1545  handle = 0;
1546  printf ("Please Enter the device Handle number of the device\t: ");
1547  handle = getDeviceSelection();
1548  printf ("Enter Device ConnectAs Type : [0 - AUDIO_OUTPUT | 1 - AUDIO_INPUT | 2 - LE | 3 - HID | 4 - UNKNOWN]\n");
1549  ch = getDeviceSelection();
1550  if (0 == ch)
1551  Type = BTRMGR_DEVICE_OP_TYPE_AUDIO_OUTPUT;
1552  else if (1 == ch)
1553  Type = BTRMGR_DEVICE_OP_TYPE_AUDIO_INPUT;
1554  else if (2 == ch)
1555  Type = BTRMGR_DEVICE_OP_TYPE_LE;
1556  else if (3 == ch)
1557  Type = BTRMGR_DEVICE_OP_TYPE_HID;
1558 
1559  rc = BTRMGR_GetDeviceVolumeMute (0, handle, Type, &ui8volume, &mute);
1560 
1561  if (BTRMGR_RESULT_SUCCESS != rc)
1562  printf ("failed\n");
1563  else
1564  printf ("\n---Device volume Info--- \n"
1565  "\n volume: %d \n"
1566  "\n mute : %s \n\n", ui8volume , mute ? "TRUE" :"FALSE");
1567  }
1568  break;
1569  case 50:
1570  {
1571  char lPropertyValue[BTRMGR_MAX_STR_LEN] = "";
1572 
1573  BTRMGR_SysDiagInfo(0, BTRMGR_DEVICE_MAC, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1574  strncpy((char*)stCustomAdv.device_mac, lPropertyValue, strlen(lPropertyValue));
1575 
1576  printf("Adding default local services : DEVICE_INFORMATION_UUID - 0x180a, RDKDIAGNOSTICS_UUID - 0xFDB9\n");
1577  BTRMGR_LE_SetServiceInfo(0, BTRMGR_DEVICE_INFORMATION_UUID, 1);
1578  BTRMGR_LE_SetServiceInfo(0, BTRMGR_RDKDIAGNOSTICS_UUID, 1);
1579 
1580  /* Get model number */
1581  BTRMGR_SysDiagInfo(0, BTRMGR_SYSTEM_ID_UUID, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1582  printf("Adding char for the default local services : 0x180a, 0xFDB9\n");
1583  BTRMGR_LE_SetGattInfo(0, BTRMGR_DEVICE_INFORMATION_UUID, BTRMGR_SYSTEM_ID_UUID, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR); /* system ID */
1584  BTRMGR_LE_SetGattInfo(0, BTRMGR_DEVICE_INFORMATION_UUID, BTRMGR_MODEL_NUMBER_UUID, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR); /* model number */
1585  /*Get HW revision*/
1586  BTRMGR_LE_SetGattInfo(0, BTRMGR_DEVICE_INFORMATION_UUID, BTRMGR_HARDWARE_REVISION_UUID, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR); /* Hardware revision */
1587  /* Get serial number */
1588  BTRMGR_SysDiagInfo(0, BTRMGR_SERIAL_NUMBER_UUID, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1589  BTRMGR_LE_SetGattInfo(0, BTRMGR_DEVICE_INFORMATION_UUID, BTRMGR_SERIAL_NUMBER_UUID, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR); /* serial number */
1590  /* Get firmware revision */
1591  BTRMGR_SysDiagInfo(0, BTRMGR_FIRMWARE_REVISION_UUID, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1592  BTRMGR_LE_SetGattInfo(0, BTRMGR_DEVICE_INFORMATION_UUID, BTRMGR_FIRMWARE_REVISION_UUID, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR); /* Firmware revision */
1593  BTRMGR_LE_SetGattInfo(0, BTRMGR_DEVICE_INFORMATION_UUID, BTRMGR_SOFTWARE_REVISION_UUID, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR); /* Software revision */
1594  /* Get manufacturer name */
1595  BTRMGR_SysDiagInfo(0, BTRMGR_MANUFACTURER_NAME_UUID, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1596  BTRMGR_LE_SetGattInfo(0, BTRMGR_DEVICE_INFORMATION_UUID, BTRMGR_MANUFACTURER_NAME_UUID, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR); /* Manufacturer name */
1597 
1598  /* 0xFDB9 */
1599  BTRMGR_LE_SetGattInfo(0, BTRMGR_RDKDIAGNOSTICS_UUID, BTRMGR_DEVICE_STATUS_UUID, 0x1, "READY", BTRMGR_LE_PROP_CHAR); /* DeviceStatus */
1600  BTRMGR_SysDiagInfo(0, BTRMGR_FWDOWNLOAD_STATUS_UUID, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1601  BTRMGR_LE_SetGattInfo(0, BTRMGR_RDKDIAGNOSTICS_UUID, BTRMGR_FWDOWNLOAD_STATUS_UUID, 0x103, lPropertyValue, BTRMGR_LE_PROP_CHAR); /* FWDownloadStatus */
1602  BTRMGR_SysDiagInfo(0, BTRMGR_WEBPA_STATUS_UUID, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1603  BTRMGR_LE_SetGattInfo(0, BTRMGR_RDKDIAGNOSTICS_UUID, BTRMGR_WEBPA_STATUS_UUID, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR); /* WebPAStatus */
1604  BTRMGR_SysDiagInfo(0, BTRMGR_WIFIRADIO1_STATUS_UUID, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1605  BTRMGR_LE_SetGattInfo(0, BTRMGR_RDKDIAGNOSTICS_UUID, BTRMGR_WIFIRADIO1_STATUS_UUID, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR); /* WiFiRadio1Status */
1606  BTRMGR_LE_SetGattInfo(0, BTRMGR_RDKDIAGNOSTICS_UUID, BTRMGR_WIFIRADIO2_STATUS_UUID, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR); /* WiFiRadio2Status */
1607  BTRMGR_SysDiagInfo(0, BTRMGR_RF_STATUS_UUID, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1608  BTRMGR_LE_SetGattInfo(0, BTRMGR_RDKDIAGNOSTICS_UUID, BTRMGR_RF_STATUS_UUID, 0x1, "NOT CONNECTED", BTRMGR_LE_PROP_CHAR); /* RFStatus */
1609 
1610  /* Begin advertisement */
1611  BTRMGR_LE_StartAdvertisement(0, &stCustomAdv);
1612  }
1613  break;
1614  case 51:
1615  {
1616  int lChoice = 1;
1617  char lUUID[BTRMGR_MAX_STR_LEN] = "";
1618  unsigned char lServiceType = 1;
1619  char lParentUUID[BTRMGR_MAX_STR_LEN] = "";
1620  int lFlag = 0;
1621  unsigned short lFlagMask = 0x0;
1622  char lValue[BTRMGR_MAX_STR_LEN] = "";
1623 
1624  do
1625  {
1626  printf("\nAdd test Gatt info\n");
1627  printf("0 - No | 1 - Service | 2 - Characteristic | 3 - Descriptor\n");
1628  if (scanf("%d", &lChoice)) {
1629  }
1630  switch (lChoice)
1631  {
1632  case 1:
1633  {
1634  printf("Enter UUID of Service\n");
1635  if (scanf("%s", lUUID)) {
1636  }
1637  printf("Enter Service Type\n");
1638  printf("1 - Primary | 0 - Secondary\n");
1639  if (scanf("%d", (int*)&lServiceType)) {
1640  }
1641  BTRMGR_LE_SetServiceInfo(0, lUUID, (lServiceType != 0 ? 1 : 0));
1642  }
1643  break;
1644  case 2:
1645  case 3:
1646  {
1647  printf("Enter UUID\n");
1648  if (scanf("%s", lUUID)) {
1649  }
1650  printf("Enter UUID of parent\n");
1651  if (scanf("%s", lParentUUID)) {
1652  }
1653  do {
1654  printf("Enter the characteristic flags \n");
1655  printf("\n"
1656  "0 - read\n"
1657  "1 - write\n"
1658  "2 - encrypt-read\n"
1659  "3 - encrypt-write\n"
1660  "4 - encrypt-authenticated-read\n"
1661  "5 - encrypt-authenticated-write\n"
1662  "6 - secure-read (Server only)\n"
1663  "7 - secure-write (Server only)\n"
1664  "8 - notify\n"
1665  "9 - indicate\n"
1666  "10 - broadcast\n"
1667  "11 - write-without-response\n"
1668  "12 - authenticated-signed-writes\n"
1669  "13 - reliable-write\n"
1670  "14 - writable-auxiliaries\n"
1671  "15 - Done");
1672  printf("\nPress enter when done");
1673  if (scanf("%d", &lFlag)) {
1674  }
1675  if ((lFlag >= 0) || (lFlag <= 14))
1676  {
1677  lFlagMask |= (1 << lFlag);
1678  }
1679  } while (lFlag != 15);
1680  if (0x1 == (lFlagMask & 0x1))
1681  {
1682  printf("Enter value of the characteristic\n");
1683  if (scanf("%s", lValue)) {
1684  }
1685  }
1686  BTRMGR_LE_SetGattInfo(0, lParentUUID, lUUID, lFlagMask, lValue, (lChoice == 2?BTRMGR_LE_PROP_CHAR: BTRMGR_LE_PROP_DESC));
1687  }
1688  break;
1689  default:
1690  break;
1691  }
1692  } while (lChoice);
1693  BTRMGR_LE_StopAdvertisement(0);
1694  BTRMGR_LE_StartAdvertisement(0, &stCustomAdv);
1695  }
1696  break;
1697  case 52:
1698  {
1699  BTRMGR_LE_StopAdvertisement(0);
1700  }
1701  break;
1702  case 53:
1703  {
1704  char lPropertyValue[BTRMGR_MAX_STR_LEN] = "";
1705 
1706  printf("Adding char for the default local services \n");
1707  BTRMGR_LE_SetServiceInfo(0, BTRMGR_DEVICE_INFORMATION_UUID, 1);
1708  BTRMGR_LE_SetServiceInfo(0, BTRMGR_LEONBRDG_SERVICE_UUID_SETUP, 1);
1709 
1710  /* Get system ID - device MAC */
1711  BTRMGR_SysDiagInfo(0, BTRMGR_SYSTEM_ID_UUID, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1712  BTRMGR_LE_SetGattInfo(0, BTRMGR_DEVICE_INFORMATION_UUID, BTRMGR_SYSTEM_ID_UUID, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR); /* system ID */
1713  /* Get model number */
1714  BTRMGR_SysDiagInfo(0, BTRMGR_MODEL_NUMBER_UUID, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1715  BTRMGR_LE_SetGattInfo(0, BTRMGR_DEVICE_INFORMATION_UUID, BTRMGR_MODEL_NUMBER_UUID, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR); /* model number */
1716  /*Get HW revision*/
1717  BTRMGR_LE_SetGattInfo(0, BTRMGR_DEVICE_INFORMATION_UUID, BTRMGR_HARDWARE_REVISION_UUID, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR); /* Hardware revision */
1718  /* Get serial number */
1719  BTRMGR_SysDiagInfo(0, BTRMGR_SERIAL_NUMBER_UUID, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1720  BTRMGR_LE_SetGattInfo(0, BTRMGR_DEVICE_INFORMATION_UUID, BTRMGR_SERIAL_NUMBER_UUID, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR); /* serial number */
1721  /* Get firmware revision */
1722  BTRMGR_SysDiagInfo(0, BTRMGR_FIRMWARE_REVISION_UUID, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1723  BTRMGR_LE_SetGattInfo(0, BTRMGR_DEVICE_INFORMATION_UUID, BTRMGR_FIRMWARE_REVISION_UUID, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR); /* Firmware revision */
1724  BTRMGR_LE_SetGattInfo(0, BTRMGR_DEVICE_INFORMATION_UUID, BTRMGR_SOFTWARE_REVISION_UUID, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR); /* Software revision */
1725  /* Get manufacturer name */
1726  BTRMGR_SysDiagInfo(0, BTRMGR_MANUFACTURER_NAME_UUID, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1727  BTRMGR_LE_SetGattInfo(0, BTRMGR_DEVICE_INFORMATION_UUID, BTRMGR_MANUFACTURER_NAME_UUID, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR); /* Manufacturer name */
1728 
1729  BTRMGR_SysDiagInfo(0, BTRMGR_LEONBRDG_UUID_QR_CODE, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1730  BTRMGR_LE_SetGattInfo(0, BTRMGR_LEONBRDG_SERVICE_UUID_SETUP, BTRMGR_LEONBRDG_UUID_QR_CODE, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR);
1731  BTRMGR_SysDiagInfo(0, BTRMGR_LEONBRDG_UUID_PROVISION_STATUS, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1732  BTRMGR_LE_SetGattInfo(0, BTRMGR_LEONBRDG_SERVICE_UUID_SETUP, BTRMGR_LEONBRDG_UUID_PROVISION_STATUS, 0x101, lPropertyValue, BTRMGR_LE_PROP_CHAR);
1733  BTRMGR_SysDiagInfo(0, BTRMGR_LEONBRDG_UUID_PUBLIC_KEY, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1734  BTRMGR_LE_SetGattInfo(0, BTRMGR_LEONBRDG_SERVICE_UUID_SETUP, BTRMGR_LEONBRDG_UUID_PUBLIC_KEY, 0x1, lPropertyValue, BTRMGR_LE_PROP_CHAR);
1735  //BTRMGR_SysDiagInfo(0, BTRMGR_LEONBRDG_UUID_WIFI_CONFIG, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1736  BTRMGR_LE_SetGattInfo(0, BTRMGR_LEONBRDG_SERVICE_UUID_SETUP, BTRMGR_LEONBRDG_UUID_WIFI_CONFIG, 0x2, lPropertyValue, BTRMGR_LE_PROP_CHAR);
1737  BTRMGR_LE_SetGattInfo(0, BTRMGR_LEONBRDG_SERVICE_UUID_SETUP, BTRMGR_LEONBRDG_UUID_SSID_LIST, 0x1, " ", BTRMGR_LE_PROP_CHAR);
1738  //BTRMGR_LE_SetGattInfo(0, BTRMGR_LEONBRDG_UUID_PROVISION_STATUS, "0x2902", 0x1, "0x0100", BTRMGR_LE_PROP_DESC);
1739  printf("Starting the ad\n");
1740  BTRMGR_LE_StartAdvertisement(0, &stCustomAdv);
1741 
1742  usleep(40000000);
1743  //BTRMGR_LE_SetGattPropertyValue(0, "0x2902", "0x01", BTRMGR_LE_PROP_DESC);
1744 #if 1
1745 
1746  //char lPropertyValue[BTRMGR_MAX_STR_LEN] = "";
1747  //usleep(10000000);
1748 
1749  do {
1750  printf("Getting the provision status\n");
1751  BTRMGR_SysDiagInfo(0, BTRMGR_LEONBRDG_UUID_PROVISION_STATUS, lPropertyValue, BTRMGR_LE_OP_READ_VALUE);
1752 
1753  printf("BTRMGR_LEONBRDG_UUID_PROVISION_STATUS is %s\n", lPropertyValue);
1754  /* Add condition to notify only if different from the last */
1755  {
1756  BTRMGR_LE_SetGattPropertyValue(0, BTRMGR_LEONBRDG_UUID_PROVISION_STATUS, lPropertyValue, BTRMGR_LE_PROP_CHAR);
1757  }
1758  if (!strncmp("0x102", lPropertyValue, 4))
1759  {
1760  printf("Waiting for wifi config\n");
1761  break;
1762  }
1763 
1764  usleep(1000000);
1765 
1766  } while (1);
1767 
1768 #endif
1769  }
1770  break;
1771  case 54:
1772  {
1773  int choice = 0;
1774 
1775  printf ("\n\nATTENTION! Disconnect all existing GamePad connection before flipping the GamePad Service state.\n\n");
1776  printf ("Press 1 to Enable and 0 to Disable GamePad Service.\n");
1777  if (scanf("%d", &choice)) {
1778  }
1779 
1780 #ifndef BUILD_FOR_PI
1781  WDMP_STATUS status = WDMP_FAILURE;
1782  status = setRFCParameter("btrMgrTest", "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.BTR.GamePad.Enable",
1783  (choice)? "true" : "false", WDMP_BOOLEAN);
1784 
1785  if (status != WDMP_SUCCESS) {
1786  printf("\nsetRFCParameter Failed : %s\n", getRFCErrorString(status));
1787  }
1788  else
1789 #endif
1790  {
1791  if (choice) {
1792  printf("\nSuccessfully Enabled GamePad.\n");
1793  }
1794  else {
1795  printf("\nSuccessfully Disabled GamePad.\n");
1796  }
1797  }
1798  }
1799  break;
1800  case 55:
1801  {
1802  int choice = 0;
1803 
1804  printf ("\n\nATTENTION! Disconnect all existing GamePad connection before flipping the GamePad Service state.\n\n");
1805  printf ("Press 1 to Enable and 0 to Disable GamePad Service.\n");
1806  if (scanf("%d", &choice)) {
1807  }
1808 
1809  rc = BTRMGR_SetHidGamePadServiceState (0, choice);
1810 
1811  if (BTRMGR_RESULT_SUCCESS == rc) {
1812  if (choice) {
1813  printf("\nSuccessfully Enabled GamePad.\n");
1814  }
1815  else {
1816  printf("\nSuccessfully Disabled GamePad.\n");
1817  }
1818  }
1819  else {
1820  printf("\nCall Failed : %d\n", rc);
1821  }
1822  }
1823  break;
1824  case 56:
1825  loop = 0;
1826  break;
1827  default:
1828  printf ("Invalid Selection.....\n");
1829  break;
1830  }
1831  }while(loop && cliDisabled);
1832 
1833  if (cliDisabled ==0)
1834  {
1835  for(counter = 0; counter < argc; ++counter) free(gArgv[counter]);
1836  free(gArgv);
1837  }
1838  BTRMGR_DeInit();
1839  return 0;
1840 }
BTRMGR_GetMediaCurrentPosition
BTRMGR_Result_t BTRMGR_GetMediaCurrentPosition(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl, BTRMGR_MediaPositionInfo_t *mediaPositionInfo)
This API fetches the current position and total duration of the media.
Definition: btrMgr.c:5251
_BTRMGR_DeviceServiceList_t
Represents device services list.
Definition: btmgr.h:380
BTRMGR_DeInit
BTRMGR_Result_t BTRMGR_DeInit(void)
This API invokes the deinit function of bluetooth core and persistant interface module.
Definition: btrMgr.c:2455
BTRMGR_SetAdapterName
BTRMGR_Result_t BTRMGR_SetAdapterName(unsigned char aui8AdapterIdx, const char *pNameOfAdapter)
This API is used to set the new name to the bluetooth adapter.
Definition: btrMgr.c:2645
BTRMGR_UnpairDevice
BTRMGR_Result_t BTRMGR_UnpairDevice(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl)
This API is used to remove the pairing information of the device selected.
Definition: btrMgr.c:3440
BTRMGR_SetAdapterDiscoverable
BTRMGR_Result_t BTRMGR_SetAdapterDiscoverable(unsigned char aui8AdapterIdx, unsigned char discoverable, int timeout)
This API is to make the adapter discoverable until the given timeout.
Definition: btrMgr.c:2830
BTRMGR_GetMediaTrackInfo
BTRMGR_Result_t BTRMGR_GetMediaTrackInfo(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl, BTRMGR_MediaTrackInfo_t *mediaTrackInfo)
This API fetches the media track info like title, genre, duration, number of tracks,...
Definition: btrMgr.c:5172
BTRMGR_IsAdapterDiscoverable
BTRMGR_Result_t BTRMGR_IsAdapterDiscoverable(unsigned char aui8AdapterIdx, unsigned char *pDiscoverable)
This API checks the adapter is discoverable or not.
Definition: btrMgr.c:2894
BTRMGR_PairDevice
BTRMGR_Result_t BTRMGR_PairDevice(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl)
This API is used to pair the device that you wish to pair.
Definition: btrMgr.c:3313
BTRMGR_Result_t
enum _BTRMGR_Result_t BTRMGR_Result_t
Represents the status of the operation.
_BTRMGR_MediaElementListInfo_t
Represents Media Element List.
Definition: btmgr.h:517
BTRMGR_PerformLeOp
BTRMGR_Result_t BTRMGR_PerformLeOp(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl, const char *aBtrLeUuid, BTRMGR_LeOp_t aLeOpType, char *aLeOpArg, char *rOpResult)
This API performs LE operations on the specified bluetooth adapter.
Definition: btrMgr.c:5801
BTRMGR_Events_t
enum _BTRMGR_Events_t BTRMGR_Events_t
Represents the event status.
_BTRMGR_LeCustomAdvertisement_t
Structure for the custom advertisement payload.
Definition: btmgr.h:616
btmgr.h
BTRMGR_DeviceOperationType_t
enum _BTRMGR_DeviceOperationType_t BTRMGR_DeviceOperationType_t
Represents the operation type for bluetooth device.
BTRMGR_GetAdapterPowerStatus
BTRMGR_Result_t BTRMGR_GetAdapterPowerStatus(unsigned char aui8AdapterIdx, unsigned char *pPowerStatus)
This API fetches the power status, either 0 or 1.
Definition: btrMgr.c:2790
BTRMGR_MediaControl
BTRMGR_Result_t BTRMGR_MediaControl(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl, BTRMGR_MediaControlCommand_t mediaCtrlCmd)
This API is used to perform the media control operations.
Definition: btrMgr.c:4680
BTRMGR_StartAudioStreamingOut
BTRMGR_Result_t BTRMGR_StartAudioStreamingOut(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl, BTRMGR_DeviceOperationType_t connectAs)
This API initates the streaming from the device with the selected operation type.
Definition: btrMgr.c:4179
BTRMGR_StartDeviceDiscovery
BTRMGR_Result_t BTRMGR_StartDeviceDiscovery(unsigned char aui8AdapterIdx, BTRMGR_DeviceOperationType_t aenBTRMgrDevOpT)
This API initiates the scanning process.
Definition: btrMgr.c:3141
_BTRMGR_PairedDevicesList_t
Represents the list of paired devices.
Definition: btmgr.h:476
BTRMGR_GetNumberOfAdapters
BTRMGR_Result_t BTRMGR_GetNumberOfAdapters(unsigned char *pNumOfAdapters)
This API returns the number of bluetooth adapters available.
Definition: btrMgr.c:2550
BTRMGR_DisconnectFromDevice
BTRMGR_Result_t BTRMGR_DisconnectFromDevice(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl)
This API terminates the current connection.
Definition: btrMgr.c:3674
BTRMGR_SelectMediaElement
BTRMGR_Result_t BTRMGR_SelectMediaElement(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl, BTRMgrMediaElementHandle ahBTRMgrMedElementHdl, BTRMGR_MediaElementType_t aMediaElementType)
This API performs operation based on the element type selected.
Definition: btrMgr.c:5444
BTRMGR_SetMediaElementActive
BTRMGR_Result_t BTRMGR_SetMediaElementActive(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl, BTRMgrMediaElementHandle ahBTRMgrMedElementHdl, BTRMGR_MediaElementType_t aMediaElementType)
This API sets the mentioned media element list active/in_scope for further operations on it.
Definition: btrMgr.c:5290
BTRMGR_GetAdapterName
BTRMGR_Result_t BTRMGR_GetAdapterName(unsigned char aui8AdapterIdx, char *pNameOfAdapter)
This API fetches the bluetooth adapter name.
Definition: btrMgr.c:2685
BTRMGR_GetDiscoveryStatus
BTRMGR_Result_t BTRMGR_GetDiscoveryStatus(unsigned char aui8AdapterIdx, BTRMGR_DiscoveryStatus_t *aeDiscoveryStatus, BTRMGR_DeviceOperationType_t *aenBTRMgrDevOpT)
This API gives the discovery status.
Definition: btrMgr.c:3195
BTRMGR_StopAudioStreamingIn
BTRMGR_Result_t BTRMGR_StopAudioStreamingIn(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl)
This API termines the audio streaming.
Definition: btrMgr.c:4530
BTRMGR_StopAudioStreamingOut
BTRMGR_Result_t BTRMGR_StopAudioStreamingOut(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl)
This API terminates the streaming from the device.
Definition: btrMgr.c:4205
BTRMGR_SetDeviceVolumeMute
BTRMGR_Result_t BTRMGR_SetDeviceVolumeMute(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl, BTRMGR_DeviceOperationType_t deviceOpType, unsigned char ui8Volume, unsigned char ui8Mute)
This API is used to set the media volume and mute data.
Definition: btrMgr.c:5051
_BTRMGR_EventMessage_t
Represents the event message info.
Definition: btmgr.h:576
_BTRMGR_DiscoveredDevicesList_t
Represents the list of scanned devices.
Definition: btmgr.h:484
BTRMGR_GetDeviceProperties
BTRMGR_Result_t BTRMGR_GetDeviceProperties(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl, BTRMGR_DevicesProperty_t *pDeviceProperty)
This API returns the device information that includes the device name, mac address,...
Definition: btrMgr.c:3961
BTRMGR_SetAdapterPowerStatus
BTRMGR_Result_t BTRMGR_SetAdapterPowerStatus(unsigned char aui8AdapterIdx, unsigned char power_status)
This API sets the bluetooth adapter power to ON/OFF.
Definition: btrMgr.c:2728
BTRMGR_SetAudioInServiceState
BTRMGR_Result_t BTRMGR_SetAudioInServiceState(unsigned char aui8AdapterIdx, unsigned char aui8State)
This API Enable/Disables Audio-In on the specified bluetooth adapter.
Definition: btrMgr.c:5562
BTRMGR_ConnectToDevice
BTRMGR_Result_t BTRMGR_ConnectToDevice(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl, BTRMGR_DeviceOperationType_t connectAs)
This API connects the device as audio sink/headset/audio src based on the device type specified.
Definition: btrMgr.c:3635
BTRMGR_StartAudioStreamingIn
BTRMGR_Result_t BTRMGR_StartAudioStreamingIn(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl, BTRMGR_DeviceOperationType_t connectAs)
This API starts the audio streaming.
Definition: btrMgr.c:4339
BTRMGR_ResetAdapter
BTRMGR_Result_t BTRMGR_ResetAdapter(unsigned char aui8AdapterIdx)
This API is designed to reset the bluetooth adapter.
Definition: btrMgr.c:2589
BTRMGR_GetDiscoveredDevices
BTRMGR_Result_t BTRMGR_GetDiscoveredDevices(unsigned char aui8AdapterIdx, BTRMGR_DiscoveredDevicesList_t *pDiscoveredDevices)
This API fetches the list of devices scanned.
Definition: btrMgr.c:3226
_BTRMGR_DevicesProperty_t
Represents the property of the device.
Definition: btmgr.h:400
BTRMGR_GetPairedDevices
BTRMGR_Result_t BTRMGR_GetPairedDevices(unsigned char aui8AdapterIdx, BTRMGR_PairedDevicesList_t *pPairedDevices)
This API returns the list of devices paired.
Definition: btrMgr.c:3556
BTRMGR_GetDeviceVolumeMute
BTRMGR_Result_t BTRMGR_GetDeviceVolumeMute(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl, BTRMGR_DeviceOperationType_t deviceOpType, unsigned char *pui8Volume, unsigned char *pui8Mute)
This API is used to fetch the media volume and mute data.
Definition: btrMgr.c:4966
BTRMGR_GetMediaElementList
BTRMGR_Result_t BTRMGR_GetMediaElementList(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl, BTRMgrMediaElementHandle ahBTRMgrMedElementHdl, unsigned short aui16MediaElementStartIdx, unsigned short aui16MediaElementEndIdx, unsigned char abMediaElementListDepth, BTRMGR_MediaElementType_t aMediaElementType, BTRMGR_MediaElementListInfo_t *aMediaElementListInfo)
This API gets the media element list.
Definition: btrMgr.c:5362
BTRMGR_StopDeviceDiscovery
BTRMGR_Result_t BTRMGR_StopDeviceDiscovery(unsigned char aui8AdapterIdx, BTRMGR_DeviceOperationType_t aenBTRMgrDevOpT)
This API terminates the scanning process.
Definition: btrMgr.c:3169
BTRMGR_GetMediaElementTrackInfo
BTRMGR_Result_t BTRMGR_GetMediaElementTrackInfo(unsigned char aui8AdapterIdx, BTRMgrDeviceHandle ahBTRMgrDevHdl, BTRMgrMediaElementHandle ahBTRMgrMedElementHdl, BTRMGR_MediaTrackInfo_t *mediaTrackInfo)
This API fetches the media track info like title, genre, duration, number of tracks,...
Definition: btrMgr.c:5210
BTRMGR_IsAudioStreamingIn
BTRMGR_Result_t BTRMGR_IsAudioStreamingIn(unsigned char aui8AdapterIdx, unsigned char *pStreamingStatus)
This API returns the audio streaming status.
Definition: btrMgr.c:4574
BTRMGR_StreamOut_Type_t
enum _BTRMGR_StreamOut_Type_t BTRMGR_StreamOut_Type_t
Represents the stream output types.
BTRMGR_GetDeviceTypeAsString
const char * BTRMGR_GetDeviceTypeAsString(BTRMGR_DeviceType_t type)
This API fetches the Device name of the media.
Definition: btrMgr.c:5515
_BTRMGR_EventResponse_t
Represents the event response.
Definition: btmgr.h:591
BTRMGR_SetEventResponse
BTRMGR_Result_t BTRMGR_SetEventResponse(unsigned char aui8AdapterIdx, BTRMGR_EventResponse_t *apstBTRMgrEvtRsp)
This API handles the events received.
Definition: btrMgr.c:4602
_BTRMGR_MediaPositionInfo_t
Represents the media position info.
Definition: btmgr.h:359
BTRMGR_SetAudioStreamingOutType
BTRMGR_Result_t BTRMGR_SetAudioStreamingOutType(unsigned char aui8AdapterIdx, BTRMGR_StreamOut_Type_t type)
This API is to set the audio type as primary or secondary.
Definition: btrMgr.c:4287
_BTRMGR_MediaTrackInfo_t
Represents the media track info.
Definition: btmgr.h:346
BTRMGR_SetHidGamePadServiceState
BTRMGR_Result_t BTRMGR_SetHidGamePadServiceState(unsigned char aui8AdapterIdx, unsigned char aui8State)
This API Enable/Disables Hid GamePad on the specified bluetooth adapter.
Definition: btrMgr.c:5576
BTRMGR_Init
BTRMGR_Result_t BTRMGR_Init(void)
This API initializes the bluetooth manager.
Definition: btrMgr.c:2295
BTRMGR_DiscoveryStatus_t
enum _BTRMGR_DiscoveryStatus_t BTRMGR_DiscoveryStatus_t
Represents the bluetooth Discovery Status.
BTRMGR_IsAudioStreamingOut
BTRMGR_Result_t BTRMGR_IsAudioStreamingOut(unsigned char aui8AdapterIdx, unsigned char *pStreamingStatus)
This API returns the stream out status.
Definition: btrMgr.c:4252