BtcmSrvProt.h 56.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719
/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2005
*
*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
*
*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
 *
 * Filename:
 * ---------
 * BtcmSrvProt.h
 *
 * Project:
 * --------
 *   Maui
 *
 * Description:
 * ------------
 *   This file is the internal header file for BT CM
 *
 * Author:
 * -------
 * -------
 *
 *============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *------------------------------------------------------------------------------
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/
#ifndef BT_CM_SRV_PROT_H
#define BT_CM_SRV_PROT_H
// RHR: add
#include "MMI_features.h"
#include "MMIDataType.h"
#include "MMI_conn_app_trc.h"
#include "DebugInitDef_Int.h"
#include "wgui_categories_list.h"
//#include "TimerEvents.h"
#include "nvram_common_defs.h"
#include "kal_general_types.h"
#include "mmi_res_range_def.h"
#include "DmSrvGprot.h"
// RHR: add

//#include "bluetooth_bm_struct.h"
#include "BtcmSrvGprot.h"
/***************************************************************************** 
* Macro
*****************************************************************************/
#ifdef __MMI_BT_SUPPORT__

//#ifndef __SRV_BT_CM_DEBUG_INTENAL__
#define __SRV_BT_CM_DEBUG_INTENAL__

#ifdef __MMI_BT_SLIM__
#ifndef _MMI_BT_ULTRA_SLIM_
#define _MMI_BT_ULTRA_SLIM_
#endif 
#endif
//#endif

MMI_BOOL SRV_BT_CM_GET_FLAG(U32 flag);

void SRV_BT_CM_SET_FLAG(U32 flag);

void SRV_BT_CM_RESET_FLAG(U32 flag);

MMI_BOOL SRV_BT_CM_GET_RAMFLAG(U32 ram_flag);

void SRV_BT_CM_SET_RAMFLAG(U32 ram_flag);

void SRV_BT_CM_RESET_RAMFLAG(U32 ram_flag);

void SRV_BT_CM_STATE_TRANS(U32 state);

void SRV_BT_CM_TMP_STATE_TRANS(U32 state);


/***************************************************************************** 
* Definations
*****************************************************************************/
#define SRV_BT_CM_PASSKEY_MAX_LEN            16
#define SRV_BT_CM_POWER_ON_TIMER_DUR         30000
#define SRV_BT_CM_RELEASE_ALL_CONN_TIMER_DUR 45000  /* 45  sec */
#define SRV_BT_CM_POWER_OFF_TIMER_DUR        25000  /* 25  sec */
#define SRV_BT_CM_CMD_TIMER_DUR              210000 /* 210 sec */

/* <GROUP MMI BT flag bit-wise ram flag defination(Not stored in NVRAM)>
   swap 2 BT */
#define SRV_BT_CM_RAMMASK_IS_SWAP2BT               0x00000001
// remove to MMI
/* <GROUP MMI BT flag bit-wise ram flag defination(Not stored in NVRAM)>
   auto power switch */
//#define SRV_BT_CM_RAMMASK_IS_AUTO_PWR_SWITCH       0x00000002
/* <GROUP MMI BT flag bit-wise ram flag defination(Not stored in NVRAM)>
   is ready or not */
#define SRV_BT_CM_RAMMASK_IS_READY                 0x00000004
/* <GROUP MMI BT flag bit-wise ram flag defination(Not stored in NVRAM)>
   icon blinking status */
// remote to MMI
//#define SRV_BT_CM_RAMMASK_IS_ICON_BLINKING         0x00000008
/* <GROUP MMI BT flag bit-wise ram flag defination(Not stored in NVRAM)>
   first pair request */
#define SRV_BT_CM_RAMMASK_FIRST_PAIR_REQ           0x00000010
/* <GROUP MMI BT flag bit-wise ram flag defination(Not stored in NVRAM)>
   reject the pair request */
#define SRV_BT_CM_RAMMASK_REJECT_PAIR_REQ          0x00000020
/* <GROUP MMI BT flag bit-wise ram flag defination(Not stored in NVRAM)>
   reach max acl link */
//#define SRV_BT_CM_RAMMASK_REACH_MAX_ACL_LINK       0x00000040
/* <GROUP MMI BT flag bit-wise ram flag defination(Not stored in NVRAM)>
   force to set visibility as off */
//#define SRV_BT_CM_RAMMASK_FORCE_TO_SET_VIS_BE_OFF  0x00000080
/* <GROUP MMI BT flag bit-wise ram flag defination(Not stored in NVRAM)>
   SAP activate */
//#define SRV_BT_CM_RAMMASK_IS_SIMAP_ACTIVATE        0x00000100
/* <GROUP MMI BT flag bit-wise ram flag defination(Not stored in NVRAM)>
   auto power off */
//#define SRV_BT_CM_RAMMASK_IS_AUTO_PWR_OFF          0x00000200

/* <GROUP MMI BT flag bit-wise ram flag defination(Not stored in NVRAM)>
   temp visibility */
#define SRV_BT_CM_RAMMASK_IS_TEMP_VIS              0x00000400
/* <GROUP MMI BT flag bit-wise ram flag defination(Not stored in NVRAM)>
   16 digit passkey */
//#define SRV_BT_CM_RAMMASK_IS_16_DIGIT_PASSKEY      0x00000800


/* <GROUP MMI BT flag bit-wise ram flag defination(Not stored in NVRAM)>
   auto power switch only */
//#define SRV_BT_CM_RAMMASK_IS_AUTO_PWR_SWITCH_ONLY  0x00001000
/* <GROUP MMI BT flag bit-wise ram flag defination(Not stored in NVRAM)>
   limit visibility */
#define SRV_BT_CM_RAMMASK_LIMIT_VIS                0x00002000

#define SRV_BT_CM_RAMMASK_PRE_DEACTIVATING         0x00004000

#define SRV_BT_CM_RAMMASK_POST_DEACTIVATING        0x00008000


/* <GROUP MMI BT flag bit-wise flag defination(stored in NVRAM)>
   to check the nvram sanity */
//#define SRV_BT_CM_MASK_GUARD              0x00000001

/* <GROUP MMI BT flag bit-wise flag defination(stored in NVRAM)>
   BT is power on or not */
#define SRV_BT_CM_MASK_ACTIVATED          0x00000002
/* <GROUP MMI BT flag bit-wise flag defination(stored in NVRAM)>
   need to restore BT status or not */
#define SRV_BT_CM_MASK_RESTORE_BT         0x00000004
/* <GROUP MMI BT flag bit-wise flag defination(stored in NVRAM)>
   DM reset */
//#define SRV_BT_CM_MASK_DM_RESET           0x00000008
/* <GROUP MMI BT flag bit-wise flag defination(stored in NVRAM)>
   SRV_BT_CM_MASK_GUARD | SRV_BT_CM_MASK_ACTIVATED | SRV_BT_CM_MASK_RESTORE_BT */
#define SRV_BT_CM_MASK_NON_SYS_SETTING    0x0000000F
/* <GROUP MMI BT flag bit-wise flag defination(stored in NVRAM)>
   to check the nvram sanity */
//#define SRV_BT_CM_MASK_SYS_GUARD          0x00000010

/* <GROUP MMI BT flag bit-wise flag defination(stored in NVRAM)>
   visibility setting */
#define SRV_BT_CM_MASK_VIS                0x00000020
/* <GROUP MMI BT flag bit-wise flag defination(stored in NVRAM)>
   authentication setting */
#define SRV_BT_CM_MASK_AUTH               0x00000040

/* <GROUP MMI BT flag bit-wise flag defination(stored in NVRAM)>
   0: Leave in Phone, 1: To Earphone */
//#define SRV_BT_CM_MASK_AUDPATH            0x00000080

/* <GROUP MMI BT flag bit-wise flag defination(stored in NVRAM)>
   SRV_BT_CM_MASK_SYS_GUARD|SRV_BT_CM_MASK_VIS|SRV_BT_CM_MASK_AUTH|SRV_BT_CM_MASK_AUDPATH */
/* <GROUP MMI BT flag bit-wise flag defination(stored in NVRAM)>
   0: normal power off, 1: timeout power off */
#define SRV_BT_CM_MASK_POWER_ON_TIME_OUT  0x00000100
#define SRV_BT_CM_MASK_POWER_OFF_TIME_OUT 0x00000200
#define SRV_BT_CM_MASK_SYS_SETTING        0x000000F0


/* <GROUP MMI BT flag bit-wise ram flag defination(Not stored in NVRAM)>
   auto power switch */
//#define SRV_BT_CM_RAMMASK_IS_AUTO_PWR_SWITCH       0x00000002

/* <GROUP MMI BT flag bit-wise ram flag defination(Not stored in NVRAM)>
   icon blinking status */
//#define SRV_BT_CM_RAMMASK_IS_ICON_BLINKING         0x00000008



/* <GROUP MMI BT bit-wise flag defination of device attribute>
   authorize */
#define SRV_BT_CM_DEVICE_ATTRIBUTE_AUTHORIZE       0x00000001
/* <GROUP MMI BT bit-wise flag defination of device attribute>
   user defined name */
#define SRV_BT_CM_DEVICE_ATTRIBUTE_USER_DEFINED_NAME 0x00000002
/* <GROUP MMI BT bit-wise flag defination of device attribute>
   blocked */
#define SRV_BT_CM_DEVICE_ATTRIBUTE_BLOCK           0x00000004

#define SRV_BT_CM_DEVICE_ATTRIBUTE_HIDD           0x00000008
/* <GROUP MMI BT flag bit-wise flag for service deactivated or not>
   HFP */
#define SRV_BT_CM_HFP_DEACTIVATED               0x00000001
/* <GROUP MMI BT flag bit-wise flag for service deactivated or not>
   HSP */
#define SRV_BT_CM_HSP_DEACTIVATED               0x00000002
/* <GROUP MMI BT flag bit-wise flag for service deactivated or not>
   OPS */
#define SRV_BT_CM_OPS_DEACTIVATED               0x00000004
/* <GROUP MMI BT flag bit-wise flag for service deactivated or not>
   FTS */
#define SRV_BT_CM_FTS_DEACTIVATED               0x00000008
/* <GROUP MMI BT flag bit-wise flag for service deactivated or not>
   SPP */
#define SRV_BT_CM_SPP_DEACTIVATED               0x00000010
/* <GROUP MMI BT flag bit-wise flag for service deactivated or not>
   DUN */
#define SRV_BT_CM_DUN_DEACTIVATED               0x00000020
/* <GROUP MMI BT flag bit-wise flag for service deactivated or not>
   A2DP */
#define SRV_BT_CM_A2DP_DEACTIVATED              0x00000040
/* <GROUP MMI BT flag bit-wise flag for service deactivated or not>
   AVRCP */
#define SRV_BT_CM_AVRCP_DEACTIVATED             0x00000080
/* <GROUP MMI BT flag bit-wise flag for service deactivated or not>
   AVRCP_CT */
#define SRV_BT_CM_AVRCP_CT_DEACTIVATED          0x00000100
/* <GROUP MMI BT flag bit-wise flag for service deactivated or not>
   FTC */
#define SRV_BT_CM_FTC_DEACTIVATED               0x00000200
/* <GROUP MMI BT flag bit-wise flag for service deactivated or not>
   BPP */
#define SRV_BT_CM_BPP_DEACTIVATED               0x00000400
/* <GROUP MMI BT flag bit-wise flag for service deactivated or not>
   SIMAP */
#define SRV_BT_CM_SIMAP_DEACTIVATED             0x00000800
/* <GROUP MMI BT flag bit-wise flag for service deactivated or not>
   FAX */
#define SRV_BT_CM_FAX_DEACTIVATED               0x00001000
/* <GROUP MMI BT flag bit-wise flag for service deactivated or not>
   HID */
#define SRV_BT_CM_HIDD_DEACTIVATED              0x00002000
/* <GROUP MMI BT flag bit-wise flag for service deactivated or not>
   BIP */
#define SRV_BT_CM_BIP_DEACTIVATED               0x00004000
/* <GROUP MMI BT flag bit-wise flag for service deactivated or not>
   PBAP */
#define SRV_BT_CM_PBAP_DEACTIVATED              0x00008000
/* <GROUP MMI BT flag bit-wise flag for service deactivated or not>
   OPC */
#define SRV_BT_CM_OPC_DEACTIVATED               0x00010000
/* <GROUP MMI BT flag bit-wise flag for service deactivated or not>
   SYNCML_DEV */
#define SRV_BT_CM_SYNCML_DEV_DEACTIVATED        0x00020000

#define SRV_BT_CM_TEMP_VISIBLE_TIMER_DUR        60000    /* 60 sec */


/***************************************************************************** 
* typedef 
*****************************************************************************/
// typedef enum
// {
//     SRV_BT_CM_HS_CONNECTING_STATE_IDLE = 0,
//     SRV_BT_CM_HS_CONNECTING_STATE_HFP_CONNECTING,
//     SRV_BT_CM_HS_CONNECTING_STATE_HSP_CONNECTING,
//     SRV_BT_CM_HS_CONNECTING_STATE_LAST
// } srv_bt_cm_hs_conn_state_enum;

// typedef enum
// {
//     SRV_BT_CM_HS_NOT_SHOW_CONNECT_SCR = 0,
//     SRV_BT_CM_HS_SHOW_CONNECT_SCR,
//     SRV_BT_CM_HS_CONNECT_SCR_SHOW_last
// } srv_bt_cm_hs_connect_scr_show_enum;


/***************************************************************************** 
* Structure
*****************************************************************************/
//sizeof(srv_bt_cm_nvram_struct) = 3568
//sizeof(srv_bt_cm_dev_struct_int) = 168
//sizeof(srv_bt_cm_dev_struct) = 164

/* Bluetooth device struct */
typedef struct
{
    srv_bt_cm_dev_struct dev_info;
    U32 ref_cnt;
} srv_bt_cm_dev_struct_int;

/* BT CM user data NVRAM structure */
typedef struct
{
    U32 flag;                                                               /* bt flag */
    U32 idx_of_last_hid_dev;                                                /* Last HID Dev Info */
    srv_bt_cm_dev_struct host_dev;                                          /* Host Dev Info */
    U8 pad_list[8];                                                         /* 4 byte pad size */
} srv_bt_cm_nvram_struct;

typedef struct
{
    srv_bt_cm_dev_struct_int dev_list[SRV_BT_CM_MAX_DEVICE_LIST];           /* device list: 168 * SRV_BT_CM_MAX_DEVICE_LIST(20) */
} srv_bt_cm_nvram_dev_list_struct;

typedef struct
{
    U16 paired_dev_num;                                                     /* paired device number*/
    U16 recent_dev_num;                                                     /* recent used device number*/
    U8 paired_idx_list[SRV_BT_CM_MAX_PAIRED_DEVICE_LIST];
    U8 recent_idx_list[SRV_BT_CM_MAX_USED_DEVICE_LIST];
    U8 pad_list[20];            // 20 bytes pad size
#if defined(__PLUTO_MMI_PACKAGE__) && defined(__LOW_COST_SUPPORT_COMMON__) // SLIM:memory reduction
    U8 pad[9];
#endif                                         // SLIM:memory reduction
} srv_bt_cm_nvram_dev_list_index_struct;
    
    
/* BT CM system data NVRAM structure */
typedef struct
{
    U32 sys_flag;                               /* bt flag */
    U8 host_dev_name[SRV_BT_CM_BD_FNAME_LEN];   /* host device name */
} srv_bt_cm_sys_nvram_struct;


typedef struct
{
    U32 profile_id;
    U32 conn_id;
} srv_bt_cm_conn_cnf_struct;

typedef void (*srv_bt_cm_func_ptr_void_ptr)(void*);

/* operation callback structure */
typedef struct
{
    U32 operation_type;                      /* operation table */
    srv_bt_cm_func_ptr_void_ptr cb_func_ptr; /* callback function pointer */
} srv_bt_cm_operation_cb_struct;


typedef MMI_BOOL (*srv_bt_cm_func_ptr_addr)(srv_bt_cm_bt_addr);
/* for registering pairing function call */
typedef struct
{
    U32 profile_uuid;                 /* profile UUID */
    srv_bt_cm_func_ptr_addr func_ptr; /* callback function pointer */
} srv_bt_cm_pairing_permission_struct;

typedef struct
{
    /* remember the visibility before set it success */
    U8 tmp_visibility_type;

    /* pairing Dev Info */
    U8 action_index;

    /* bth a2dp prohibit visibility flag */
    U8 a2dp_prohibit_vis;

    U8 host_security_level;

    U8 discovered_dev_num;

    /* to store the number of service before refreshing service list */
    U8 stored_ser_list_num;
#ifdef __BT_DIALER_SUPPORT__
	MMI_BOOL bt_dialor_mode;
#endif 
#ifdef __MMI_BT_DIALER_SUPPORT__
	MMI_BOOL bt_dialor_app_mode;
#endif

#ifdef __BT_AUTO_DETECT_SUPPORT__
    U8 chip_avail;
#endif

    srv_bt_cm_state_enum state;
    srv_bt_cm_state_enum tmp_state;

    /* bth flag(shall be stored in NVRAM) */
    U32 flag;

    /* bth ram flag(shall not be sotored in NVRAM) */
    U32 ram_flag;

    /* bth service deactivate flag */
    U32 deactivate_flag;

    U16 paired_dev_num;
    U16 recent_dev_num;
    srv_bt_cm_dev_struct_int dev_list[SRV_BT_CM_MAX_DEVICE_LIST];
    U8 paired_idx_list[SRV_BT_CM_MAX_PAIRED_DEVICE_LIST];
    U8 recent_idx_list[SRV_BT_CM_MAX_USED_DEVICE_LIST];
    srv_bt_cm_dev_struct temp_dev;

    srv_bt_cm_connect_struct existed_conn[SRV_BT_CM_MAX_CONNECTION];

    /* discovery List */
    srv_bt_cm_dev_struct discovered_list[SRV_BT_CM_MAX_DISCOVERY_RESULTS_IN_LIST];

    /* host Dev Info */
    srv_bt_cm_dev_struct host_dev;

    /* last HID Dev Info */
	#if defined(__MMI_HIDD_SUPPORT__)
    U32 idx_of_last_hid_dev;
	#endif
    U8* host_name_setting;

    /* to keep disconnecting conneciton id */
    U32 disconnect_con_id;

    /* connection id of connected 2nd hfg */
    /* profile id of connect accept confirm */
    srv_bt_cm_conn_cnf_struct conn_cnf[SRV_BT_CM_MAX_CONNECTION];

    /* For JSR82 */
    /* BCC */
    /* Register operation callback function */
	#ifdef __SUPPORT_JBT__
    srv_bt_cm_operation_cb_struct operation_cb_tbl[SRV_BT_CM_OPER_TYPE_TOTAL];
	#endif
    /* for registering pairing function call */
    /* Register callback */
    /* to check if doing the pairing process or not,
     * if one profile app is doing abort or disconnect, pairing process is not required. */
    /* then BT CM shall reject the pairing directly */
    srv_bt_cm_pairing_permission_struct pair_permission_cb;

#ifdef __DM_LAWMO_SUPPORT__
    srv_dm_lawmo_lock_report_cb_func_type lawmo_lock_cb;
#endif
    
} srv_bt_cm_cntx_struct;


/***************************************************************************** 
* Extern Global Variable
*****************************************************************************/
/* Context access */
extern srv_bt_cm_cntx_struct g_srv_bt_cm_cntx;
//extern srv_bt_cm_supported_profile_struct support_profile_tbl[];

/* supported profile callback table structure */
typedef struct
{
    U32 profile_id;                  /* profile UUID */
    profile_activate activater;      /* activate */
    profile_deactivate deactivater;  /* deactivate */
    //profile_connect connector;       /* connect */
    profile_disconnect disconnector; /* disconnect */
    U32 deactivate_flag;             /* indicate whether deactivate */
} srv_bt_cm_profile_struct_int;

extern srv_bt_cm_profile_struct_int g_srv_bt_cm_profile_tbl[SRV_BT_CM_MAX_HOST_SUPPORTED_PROFILE];


/***************************************************************************** 
 * Functions
 *****************************************************************************/
#define Main
/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_init_event_handler
 * DESCRIPTION
 *  This function is to init event handler
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_init_event_handler(void);
    
    
/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_is_name_duplicated
 * DESCRIPTION
 *  This function is to check if name is duplicated with other paired device, if yes, will add a prefix.
 * PARAMETERS
 *  name_p                  [OUT]       name pointer
 *  skip_paired_index       [IN]          the index of paired device to skip
 * RETURNS
 *  MMI_BOOL        TRUE : the name is duplicated
 *                  FALSE : the name is not duplicated
 *****************************************************************************/
//MMI_BOOL srv_bt_cm_is_name_duplicated(kal_uint8* name_p, U8 skip_paired_index);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_activate_profiles
 * DESCRIPTION
 *  This function is to process activat profile request and invoke activate functions of profiles
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_activate_profiles_int(MMI_BOOL flight_mode);

/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_copy_addr
 * DESCRIPTION
 *  This function is to copy address
 * PARAMETERS
 *  dest       [IN]           destination address
 *  src           [IN]        source address
 * RETURNS
 *****************************************************************************/

extern void srv_bt_cm_copy_addr(void *dest,void *src);
/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_background_disconnect
 * DESCRIPTION
 *  This function is to process disconnect request
 * PARAMETERS
 *  conn_id       [IN]            connection id
 *  conn_type           [IN]             connection type
 * RETURNS
 *  MMI_BOOL        TRUE : the profile is supported
                    FALSE : the profile is not supported
 *****************************************************************************/
//MMI_BOOL srv_bt_cm_background_disconnect(U32 conn_id, srv_bt_cm_connection_type conn_type);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_is_all_supported_profiles_activated
 * DESCRIPTION
 *  This function is to check if all supported profiles are activated
 * PARAMETERS
 *  void
 * RETURNS
 *  MMI_BOOL        TRUE : all supported profiles are activated
                    FALSE : not all supported profiles are activated
 *****************************************************************************/
MMI_BOOL srv_bt_cm_is_all_supported_profiles_activated(MMI_BOOL flight_mode);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_is_all_supported_profiles_deactivated
 * DESCRIPTION
 *  This function is to check if all supported profiles are deactivated
 * PARAMETERS
 *  void
 * RETURNS
 *  MMI_BOOL        TRUE : all supported profiles are deactivated
                    FALSE : not all supported profiles are deactivated
 *****************************************************************************/
MMI_BOOL srv_bt_cm_is_all_supported_profiles_deactivated(void);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_set_deactivate_flag
 * DESCRIPTION
 *  This function is to set deactivate flag
 * PARAMETERS
 *  prof_flag       [IN]            profile flag
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_set_deactivate_flag(U32 prof_flag);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_reset_deactivate_flag
 * DESCRIPTION
 *  This function is to reset deactivate flag
 * PARAMETERS
 *  prof_flag       [IN]            profile flag
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_reset_deactivate_flag(U32 prof_flag);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_is_pairing_permitted
 * DESCRIPTION
 *  This function is to check if pairing is permitted
 * PARAMETERS
 *  srv_bt_cm_bt_addr dev_addr, specify the device address
 * RETURNS
 *  MMI_BOOL    MMI_TRUE    permitted
 *              MMI_FALSE   not permitted
 *****************************************************************************/
MMI_BOOL srv_bt_cm_is_pairing_permitted(srv_bt_cm_bt_addr dev_addr);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_set_a2dp_prohibit_vis
 * DESCRIPTION
 *  This function is to set A2DP prohibit visibility
 * PARAMETERS
 *  setting     
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_set_a2dp_prohibit_vis(MMI_BOOL setting);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_increase_paired_dev_num
 * DESCRIPTION
 *  This function is to increase g_srv_bt_cm_cntx.paired_dev_num
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_increase_paired_dev_num(void);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_decrease_paired_dev_num
 * DESCRIPTION
 *  This function is decrease g_srv_bt_cm_cntx.paired_dev_num
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_decrease_paired_dev_num(void);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_set_action_index
 * DESCRIPTION
 *  This function is to set g_srv_bt_cm_cntx.action_index
 * PARAMETERS
 *  index
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_set_action_index(U32 index);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_echo_conn_cnf_stack
 * DESCRIPTION
 *  This function is echo the conn_cnf stack info
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_echo_conn_cnf_stack(void);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_push_conn_cnf_stack
 * DESCRIPTION
 *  This function is push conn cnf structure into stack
 * PARAMETERS
 *  profile_id :     connection confirm profile id
 *  conn_id    :     connection confirm index of device
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_push_conn_cnf_stack(U32 profile_id, U32 conn_id);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_pop_conn_cnf_stack
 * DESCRIPTION
 *  This function is to popup conn cnf structure out of stack
 * PARAMETERS
 *  void
 * RETURNS
 *  srv_bt_cm_conn_cnf_struct
 *****************************************************************************/
srv_bt_cm_conn_cnf_struct* srv_bt_cm_pop_conn_cnf_stack(void);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_clear_top_conn_cnf_stack
 * DESCRIPTION
 *  This function is to set top of conn cnf structure stack as zero
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
//void srv_bt_cm_clear_top_conn_cnf_stack(void);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_clear_specific_conn_cnf_stack
 * DESCRIPTION
 *  This function is to set specific conn cnf structure stack as zero
 * PARAMETERS
 *  conn_id : profile ID
 * RETURNS
 *  MMI_BOOL
 *****************************************************************************/
MMI_BOOL srv_bt_cm_clear_specific_conn_cnf_stack(U32 conn_id);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_connect_paired_headset_with_index
 * DESCRIPTION
 *  This function is to process connect headset, with paired index as parameter
 * PARAMETERS
 *  paired_index : the paired device index 
 *  show_prgs_scr : to show progressing screen or not
 * RETURNS
 *  MMI_BOOL        TRUE : success to connect
 *                  FALSE : otherwise
 *****************************************************************************/
//MMI_BOOL srv_bt_cm_connect_paired_headset_with_index(U32 paired_index, srv_bt_cm_hs_connect_scr_show_enum prgs_scr);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_connect_headset
 * DESCRIPTION
 *  This function is to process connect headset
 * PARAMETERS
 *  dev_addr : bd_addr of headset
 *  conn_cb : connection callback function
 * RETURNS
 *  MMI_BOOL        TRUE : success to connect
 *                  FALSE : otherwise
 *****************************************************************************/
//MMI_BOOL srv_bt_cm_connect_headset(srv_bt_cm_bt_addr* dev_addr, srv_bt_cm_headset_connect_callback conn_cb);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_disconnect_headset
 * DESCRIPTION
 *  This function is to process disconnect headset
 * PARAMETERS
 *  void
 * RETURNS
 *  MMI_BOOL        TRUE : success to disconnect
 *                  FALSE : otherwise
 *****************************************************************************/
//MMI_BOOL srv_bt_cm_disconnect_headset(void);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_cancel_connect_headset
 * DESCRIPTION
 *  This function is to process cancel connect headset
 * PARAMETERS
 *  void
 * RETURNS
 *  MMI_BOOL        TRUE : success to cancel connect
 *                  FALSE : otherwise
 *****************************************************************************/
//MMI_BOOL srv_bt_cm_cancel_connect_headset(void);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_get_active_hfp_connect_id
 * DESCRIPTION
 *  This function is to get current active hfp/hsp connection id
 * PARAMETERS
 *  void
 * RETURNS
 *  U8          active HFP connection id
 *****************************************************************************/
U8 srv_bt_cm_get_active_hfp_connect_id(void);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_set_connectable
 * DESCRIPTION
 *  This function is to set connectable request
 * PARAMETERS
 *  connectable     [IN]            the connectable mode value
 * RETURNS
 *  MMI_BOOL        return TRUE
 *****************************************************************************/
//MMI_BOOL srv_bt_cm_set_connectable(MMI_BOOL connectable);


// #ifdef __DM_LAWMO_SUPPORT__
// /*****************************************************************************
//  * FUNCTION
//  *  srv_bt_cm_lawmo_cb_hdlr
//  * DESCRIPTION
//  *  This function is to LAWMO callback handler 
//  * PARAMETERS
//  *  app_id : application id
//  *  cmd : command code
//  * RETURNS
//  *  void
//  *****************************************************************************/
// void srv_bt_cm_lawmo_cb_hdlr(U8 app_id, U8 cmd);
// #endif /*__DM_LAWMO_SUPPORT__*/


#define Prmt 
/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_antenna_on_req_hdler
 * DESCRIPTION
 *  This function is to handle antenna on req, it sends MSG_ID_BT_POWERON_REQ
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_antenna_on_req_hdler(void);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_antenna_on_rsp_hdler
 * DESCRIPTION
 *  This function is to handle antenna on cnf, it just reset SRV_BT_CM_RAMMASK_IS_READY
 * PARAMETERS
 *  msg         [IN]        inter layer message             
 * RETURNS
 *  void
 *****************************************************************************/
U8 srv_bt_cm_antenna_on_rsp_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_antenna_off_req_hdler
 * DESCRIPTION
 *  This function is to handle antenna off request, it sends MSG_ID_BT_POWEROFF_REQ
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_antenna_off_req_hdler(void);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_antenna_off_rsp_hdler
 * DESCRIPTION
 *  This function is to handler antenna off response
 *      1. reset SRV_BT_CM_RAMMASK_IS_READY
 *      2. invoke mmi_bt_scr_cb_deactivate callback function
 * PARAMETERS
 *  msg         [IN]        inter layer message             
 * RETURNS
 *  void
 *****************************************************************************/
U8 srv_bt_cm_antenna_off_rsp_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_ready_ind_hdler
 * DESCRIPTION
 *  This function is to handler ready indication
 *      1. state transistion
 *      2. send MSG_ID_BT_BM_LINK_CONNECT_ACCEPT_NOT_AUTO_REQ
 * PARAMETERS
 *  msg         [IN]        inter layer message                          
 * RETURNS
 *  void
 *****************************************************************************/
U8 srv_bt_cm_ready_ind_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_restart_req_ind_hdler
 * DESCRIPTION
 *  This function is to handle restart request indication, it invokes mmi_bt_scr_cb_panic_ind callback
 * PARAMETERS
 *  msg         [IN]        inter layer message                          
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_restart_req_ind_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_restart_rsp_hdler
 * DESCRIPTION
 *  This function is to handle restart response, send antenna on req to BTH
 * PARAMETERS
 *  msg         [IN]        inter layer message                          
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_restart_rsp_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_discovery_req_hdler
 * DESCRIPTION
 *  This function is to handle CM discovery request, it sends MSG_ID_BT_BM_DISCOVERY_REQ
 * PARAMETERS
 *  max_response        [IN]            max discovery result in response
 *  timeout             [IN]                the discovery timeout timer
 *  cod                 [IN]                  class of device
 *  name_discovery      [IN]            whether to do name discovery or not
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_discovery_req_hdler(U8 max_response, U16 timeout, U32 cod, MMI_BOOL name_discovery);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_discovery_result_ind_hdler
 * DESCRIPTION
 *  This function is to handle discovery result indication and to process found device
 * PARAMETERS
 *  msg         [IN]        inter layer message                          
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_discovery_result_ind_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_discovery_cnf_hdler
 * DESCRIPTION
 *  This function is to handler discovery confirm and invoke mmi_bt_scr_cb_inquiry_cfm callback
 * PARAMETERS
 *  msg         [IN]        inter layer message                          
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_discovery_cnf_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_cancel_discovery_req_hdler
 * DESCRIPTION
 *  This function is to handle cancel discovery request, it sends MSG_ID_BT_BM_DISCOVERY_CANCEL_REQ
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_cancel_discovery_req_hdler(void);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_cancel_discovery_cnf_hdler
 * DESCRIPTION
 *  This function is to handle cancel discovery confirm and invoke mmi_bt_scr_cb_inquiry_cancel callback
 * PARAMETERS
 *  msg         [IN]        inter layer message              
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_cancel_discovery_cnf_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_set_local_name_req_hdler
 * DESCRIPTION
 *  This function is to handle set locak name request and send MSG_ID_BT_BM_WRITE_LOCAL_NAME_REQ
 * PARAMETERS
 *  name_len        [IN]            name length
 *  name            [IN]             name
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_set_local_name_req_hdler(U8 name_len, U8* name);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_set_local_name_cnf_hdler
 * DESCRIPTION
 *  This function is to handle set local name confirm
 * PARAMETERS
 *  msg         [IN]        inter layer message              
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_set_local_name_cnf_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_read_local_bd_addr_req_hdler
 * DESCRIPTION
 *  This function is to handle read local bd addr request and send MSG_ID_BT_BM_READ_LOCAL_ADDR_REQ
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_read_local_bd_addr_req_hdler(void);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_read_local_bd_addr_cnf_hdler
 * DESCRIPTION
 *  This function is to handle read local bd addr confirm and set local name
 * PARAMETERS
 *  msg         [IN]        inter layer message              
 * RETURNS
 *  void
 *****************************************************************************/
U8 srv_bt_cm_read_local_bd_addr_cnf_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_read_remote_name_req_hdler
 * DESCRIPTION
 *  This function is to handle read remote name request and send MSG_ID_BT_BM_READ_REMOTE_NAME_REQ
 * PARAMETERS
 *  bt_add      [IN]            
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_read_remote_name_req_hdler(srv_bt_cm_bt_addr* dev_addr);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_read_remote_name_cnf_hdler
 * DESCRIPTION
 *  This function is to handle read remote name confirm
 * PARAMETERS
 *  msg         [IN]        inter layer message              
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_read_remote_name_cnf_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_sdc_search_req_hdler
 * DESCRIPTION
 *  This function is to handle SDC search request and send MSG_ID_BT_BM_SERVICE_SEARCH_REQ
 * PARAMETERS
 *  bt_add          [IN]            bd addr
 *  sdap_len        [IN]           SDAP length
 *  sdap_uuid       [IN]           SDAP UUID
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_sdc_search_req_hdler(srv_bt_cm_bt_addr bt_add, U8 sdap_len, U16* sdap_uuid);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_sdc_search_ind_hdler
 * DESCRIPTION
 *  This function is to handle SDC search indication 
 * PARAMETERS
 *  msg         [IN]        inter layer message              
 * RETURNS
 *  void
 *****************************************************************************/
U8 srv_bt_cm_sdc_search_ind_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_sdc_search_cnf_hdler
 * DESCRIPTION
 *  This function is to handle SDC search confirm
 * PARAMETERS
 *  msg         [IN]        inter layer message              
 * RETURNS
 *  void
 *****************************************************************************/
U8 srv_bt_cm_sdc_search_cnf_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_link_connect_accept_ind_hdler
 * DESCRIPTION
 *  This function is to handle if reaching max number of paired device 
 * PARAMETERS
 *  msg     [IN]    msg structure
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_link_connect_accept_ind_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_bond_req_hdler
 * DESCRIPTION
 *  This function is to handle bond request and send MSG_ID_BT_BM_BONDING_REQ
 * PARAMETERS
 *  bt_add          [IN]            bd addr
 *  sdap_len        [IN]           SDAP length
 *  sdap_uuid       [IN]          SDAP UUID
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_bond_req_hdler(srv_bt_cm_bt_addr bt_add, U8 sdap_len, U16* sdap_uuid);

MMI_BOOL srv_bt_cm_check_rejecting_state(void *bd_add);

/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_bond_ind_hdler
 * DESCRIPTION
 *  This function is to handle bond indication
 * PARAMETERS
 *  msg         [IN]        inter layer message              
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_bond_ind_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_bond_cnf_hdler
 * DESCRIPTION
 *  This function is to handle bond confirm
 * PARAMETERS
 *  msg         [IN]        inter layer message              
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_bond_cnf_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_debond_req_hdler
 * DESCRIPTION
 *  This function is to handle debond request and send MSG_ID_BT_BM_DELETE_TRUST_REQ
 * PARAMETERS
 *  dev_addr:    [IN]
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_debond_req_hdler(srv_bt_cm_bt_addr* dev_addr);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_debond_cnf_hdler
 * DESCRIPTION
 *  This function is to handle debond confirm
 * PARAMETERS
 *  msg         [IN]        inter layer message              
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_debond_cnf_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_passkey_ind_hdler
 * DESCRIPTION
 *  This function is to handle passkey indication
 * PARAMETERS
 *  msg         [IN]        inter layer message              
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_passkey_ind_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_passkey_ind_rsp_hdler
 * DESCRIPTION
 *  This function is to handle passkey indication and send MSG_ID_BT_BM_PIN_CODE_RSP
 * PARAMETERS
 *  bt_add          [IN]            bd addr
 *  pin_len         [IN]            pin code length
 *  pin_code        [IN]           pin code
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_passkey_ind_rsp_hdler(srv_bt_cm_bt_addr bt_add, U8 pin_len, U8* pin_code);


#ifdef __MMI_BT_SIMPLE_PAIR__
/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_security_user_confirm_ind_hdler
 * DESCRIPTION
 *  This function is to handle the numeric comparison indication of secure simple pairing
 * PARAMETERS
 *  msg         [IN]       ilm message from lower layer      
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_security_user_confirm_ind_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_security_user_confirm_rsp_hdler
 * DESCRIPTION
 *  This function is to respond the numeric comparison indication of secure simple pairing
 * PARAMETERS
 *  bt_add         [IN]        device address             
 *  accept         [IN]        end user response for the numeric comparison
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_security_user_confirm_rsp_hdler(srv_bt_cm_bt_addr bt_add, U8 accept);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_security_passkey_notify_ind_hdler
 * DESCRIPTION
 *  This function is to handle the passkey entry(notification) indication of secure simple pairing
 * PARAMETERS
 *  msg         [IN]       ilm message from lower layer      
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_security_passkey_notify_ind_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_security_keypress_notify_ind_hdler
 * DESCRIPTION
 *  This function is to handle the passkey entry(notification) keypress indication of secure simple pairing
 *  MMI can use indication to display how many digits inputted from remote device
 * PARAMETERS
 *  msg         [IN]       ilm message from lower layer      
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_security_keypress_notify_ind_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_security_keypress_notify_rsp_hdler
 * DESCRIPTION
 *  This function is to respond the passkey entry(notification) keypress indication of secure simple pairing
 *  to notify that MMI had updated the passkey entry(notification) screen
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
//void srv_bt_cm_security_keypress_notify_rsp_hdler(void);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_security_keypress_notify_cancel_req_hdler
 * DESCRIPTION
 *  This function is to respond the passkey entry(notification) keypress indication of secure simple pairing
 * PARAMETERS
 *  bt_add         [IN]        device address             
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_security_keypress_notify_cancel_req_hdler(srv_bt_cm_bt_addr bt_add);
#endif /* __MMI_BT_SIMPLE_PAIR__ */


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_block_active_link_req_hdler
 * DESCRIPTION
 *  This function is to release the existed active link after add this device to block list
 * PARAMETERS
 *  bt_add         [IN]        device address             
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_block_active_link_req_hdler(srv_bt_cm_bt_addr bt_add);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_block_active_link_cnf_hdler
 * DESCRIPTION
 *  This function is to handle the cnf of block active link request and invoke srv_bt_cm_block_list_update_req_hdler
 * PARAMETERS
 *  msg         [IN]       ilm message from lower layer      
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_block_active_link_cnf_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_block_list_update_req_hdler
 * DESCRIPTION
 *  This function is to update the block list to BM of btstack
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_block_list_update_req_hdler(void);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_block_list_update_cnf_hdler
 * DESCRIPTION
 *  This function is to handle the cnf of updating block list
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_block_list_update_cnf_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_security_level_req_hdler
 * DESCRIPTION
 *  This function is to handle security level request and send MSG_ID_BT_BM_WRITE_AUTHENTICATION_MODE_REQ
 * PARAMETERS
 *  auth_flag       [IN]            authentication flag
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_security_level_req_hdler(MMI_BOOL auth_flag);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_security_level_cnf_hdler
 * DESCRIPTION
 *  This function is to handle security level confirm
 * PARAMETERS
 *  msg         [IN]        inter layer message              
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_security_level_cnf_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_write_scanenable_mode_req_hdler
 * DESCRIPTION
 *  This function is to handle write scanenable mode request and send MSG_ID_BT_BM_WRITE_SCANENABLE_MODE_REQ
 * PARAMETERS
 *  connected_mode          [IN]            connected mode
 *  non_connected_mode      [IN]          non-connected mode
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_write_scanenable_mode_req_hdler(U8 connected_mode);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_write_scanenable_mode_cnf_hdler
 * DESCRIPTION
 *  This function is to handle write scanenable mode confirm
 * PARAMETERS
 *  msg         [IN]        inter layer message              
 * RETURNS
 *  void
 *****************************************************************************/
U8 srv_bt_cm_write_scanenable_mode_cnf_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_link_state_ind_hdler
 * DESCRIPTION
 *  This function is to handle link state indication
 * PARAMETERS
 *  msg         [IN]        inter layer message              
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_link_state_ind_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_allow_acl_link_establishment_req_hdler
 * DESCRIPTION
 *  This function is to handle allow ACL link establishment request and send MSG_ID_BT_BM_LINK_ALLOW_REQ
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_allow_acl_link_establishment_req_hdler(void);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_allow_acl_link_establishment_cnf_hdler
 * DESCRIPTION
 *  This function is to handle allow ACL link establishment confirm
 * PARAMETERS
 *  msg         [IN]        inter layer message              
 * RETURNS
 *  void
 *****************************************************************************/
U8 srv_bt_cm_allow_acl_link_establishment_cnf_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_disallow_acl_link_establishment_cnf_hdler
 * DESCRIPTION
 *  This function is to handle disallow ACL link establishment confirm
 * PARAMETERS
 *  msg         [IN]        inter layer message              
 * RETURNS
 *  void
 *****************************************************************************/
U8 srv_bt_cm_disallow_acl_link_establishment_cnf_hdler(void* msg);


/*****************************************************************************
 * FUNCTION
 *  srv_bt_cm_copy_n_utf8_chars
 * DESCRIPTION
 *  to copy n chars to dest string
 * PARAMETERS
 *  dest                 [IN]        dest buffer 
 *  size_of_dest     [IN]        max size of dest buffer
 *  src                   [IN]        src buffer 
 *  charNum          [IN]        number of char to be copied
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_copy_n_utf8_chars(U8* dest, U16 size_of_dest, U8* src, U8 char_num);


/*****************************************************************************
 * <GROUP Ext_other>
 * FUNCTION
 *  srv_bt_cm_deactivate_profiles_req
 * DESCRIPTION
 *  This function is to process deactivate profiles request and invoke the deactivate function of profiles
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_bt_cm_deactivate_profiles(void);


/*********************************************************************************/
typedef struct
{
    S32                srv_hd;
    srv_bt_cm_notifier notifier;
    U32                event_mask;
    void*              user_data;
} srv_bt_cm_hdlr_struct;


typedef enum
{
    EVENT_ID_BT_CM_START = SRV_BTCM_BASE + 1,
    EVENT_ID_BT_CM_POWER_ON,
    EVENT_ID_BT_CM_SET_AUTHORIZE,
    //EVENT_ID_BT_CM_NOTIFY_CONNECTOR,
    EVENT_ID_BT_CM_END_OF_ENUM
} srv_bt_cm_post_event_enum;

typedef struct
{
    MMI_EVT_PARAM_HEADER
    U32 event;
    void* data_p;
} srv_bt_cm_post_event_struct;

mmi_ret srv_bt_cm_post_event_proc(mmi_event_struct* para);

void srv_bt_cm_notify(U32 event, void* para);
void srv_bt_cm_post_notify(U32 event, void *para);

//U32 srv_bt_cm_get_paired_dev_index(const srv_bt_cm_bt_addr* dev_addr);

U8 srv_bt_cm_get_action_item_index(void);

void srv_bt_cm_nvram_write_info(U16 LID, void* para);

U32 srv_bt_cm_get_dev_index(const srv_bt_cm_bt_addr* dev_addr, srv_bt_cm_dev_type_enum dev_type);


const srv_bt_cm_dev_struct* srv_bt_cm_get_dev_info_by_addr(
    const srv_bt_cm_bt_addr* dev_addr,
    srv_bt_cm_dev_type_enum dev_type);


/****************************************************************************** 
 * FUNCTION
 *  srv_bt_cm_dev_add_int
 * DESCRIPTION
 *  this function is to add a device into corresponding device list
 *  according to device type
 * PARAMETERS
 *  dev     :    [IN]    device
 *  dev_type:    [IN]    device type
 *  
 * RETURNS
 *  
 ******************************************************************************/
S32 srv_bt_cm_dev_add_int(const srv_bt_cm_dev_struct* dev, srv_bt_cm_dev_type_enum dev_type);


/****************************************************************************** 
 * FUNCTION
 *  srv_bt_cm_dev_delete_int
 * DESCRIPTION
 *  this function is to delete a device according to device type
 * PARAMETERS
 *  dev_addr:    [IN]    device address
 *  dev_type:    [IN]    device type
 *  
 * RETURNS
 *  S32 return the delete device result
 ******************************************************************************/
S32 srv_bt_cm_dev_delete_int(const srv_bt_cm_bt_addr* dev_addr, srv_bt_cm_dev_type_enum dev_type);


#ifdef __BT_BOND_CANCEL__
void srv_bt_cm_bond_cancel_req_hdler(srv_bt_cm_bt_addr* dev_addr);


void srv_bt_cm_bond_cancel_cnf_hdler(void* msg);
#endif

mmi_ret srv_bt_cm_uart_hdlr(mmi_event_struct *evt);

#endif /* __MMI_BT_SUPPORT__ */

#endif /* BT_CM_SRV_PROT_H */