• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "hci/hci.h"
17 
18 #include "btstack.h"
19 
20 #include "hci_cmd.h"
21 
22 // BLUETOOTH SPECIFICATION Version 5.0 | Vol 2, Part E
23 // 7.2.2 Sniff Mode Command
HCI_SniffMode(const HciSniffModeParam * param)24 int HCI_SniffMode(const HciSniffModeParam *param)
25 {
26     if (param == NULL) {
27         return BT_BAD_PARAM;
28     }
29 
30     HciCmd *cmd = HciAllocCmd(HCI_SNIFF_MODE, (void *)param, sizeof(HciSniffModeParam));
31     return HciSendCmd(cmd);
32 }
33 
34 // BLUETOOTH SPECIFICATION Version 5.0 | Vol 2, Part E
35 // 7.2.3 Exit Sniff Mode Command
HCI_ExitSniffMode(const HciExitSniffModeParam * param)36 int HCI_ExitSniffMode(const HciExitSniffModeParam *param)
37 {
38     if (param == NULL) {
39         return BT_BAD_PARAM;
40     }
41 
42     HciCmd *cmd = HciAllocCmd(HCI_EXIT_SNIFF_MODE, (void *)param, sizeof(HciExitSniffModeParam));
43     return HciSendCmd(cmd);
44 }
45 
46 // BLUETOOTH SPECIFICATION Version 5.0 | Vol 2, Part E
47 // 7.2.8 Switch Role Command
HCI_SwitchRole(const HciSwitchRoleParam * param)48 int HCI_SwitchRole(const HciSwitchRoleParam *param)
49 {
50     if (param == NULL) {
51         return BT_BAD_PARAM;
52     }
53 
54     HciCmd *cmd = HciAllocCmd(HCI_SWITCH_ROLE, (void *)param, sizeof(HciSwitchRoleParam));
55     return HciSendCmd(cmd);
56 }
57 
58 // BLUETOOTH SPECIFICATION Version 5.0 | Vol 2, Part E
59 // 7.2.10 Write Link Policy Settings Command
HCI_WriteLinkPolicySettings(const HciWriteLinkPolicySettingsParam * param)60 int HCI_WriteLinkPolicySettings(const HciWriteLinkPolicySettingsParam *param)
61 {
62     if (param == NULL) {
63         return BT_BAD_PARAM;
64     }
65 
66     HciCmd *cmd = HciAllocCmd(HCI_WRITE_LINK_POLICY_SETTINGS, (void *)param, sizeof(HciWriteLinkPolicySettingsParam));
67     return HciSendCmd(cmd);
68 }
69 
70 // BLUETOOTH SPECIFICATION Version 5.0 | Vol 2, Part E
71 // 7.2.12 Write Default Link Policy Settings Command
HCI_WriteDefaultLinkPolicySettings(const HciWriteDefaultLinkPolicySettingsParam * param)72 int HCI_WriteDefaultLinkPolicySettings(const HciWriteDefaultLinkPolicySettingsParam *param)
73 {
74     if (param == NULL) {
75         return BT_BAD_PARAM;
76     }
77 
78     HciCmd *cmd = HciAllocCmd(
79         HCI_WRITE_DEFAULT_LINK_POLICY_SETTINGS, (void *)param, sizeof(HciWriteDefaultLinkPolicySettingsParam));
80     return HciSendCmd(cmd);
81 }
82 
83 // BLUETOOTH SPECIFICATION Version 5.0 | Vol 2, Part E
84 // 7.2.14 Sniff Subrating Command
HCI_SniffSubrating(const HciSniffSubratingParam * param)85 int HCI_SniffSubrating(const HciSniffSubratingParam *param)
86 {
87     if (param == NULL) {
88         return BT_BAD_PARAM;
89     }
90 
91     HciCmd *cmd = HciAllocCmd(HCI_SNIFF_SUBRATING, (void *)param, sizeof(HciSniffSubratingParam));
92     return HciSendCmd(cmd);
93 }