1 /* 2 * Copyright 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #define LOG_TAG "keyboard" 18 19 #include "keyboard.h" 20 21 using std::vector; 22 23 namespace test_vendor_lib { 24 Keyboard::Keyboard() { 25 advertising_type_ = BTM_BLE_CONNECT_EVT; 26 adv_data_ = {0x11, // Length 27 BTM_BLE_AD_TYPE_NAME_CMPL, 28 'g', 29 'D', 30 'e', 31 'v', 32 'i', 33 'c', 34 'e', 35 '-', 36 'k', 37 'e', 38 'y', 39 'b', 40 'o', 41 'a', 42 'r', 43 'd', 44 0x03, // Length 45 0x19, 46 0xC1, 47 0x03, 48 0x03, // Length 49 0x03, 50 0x12, 51 0x18, 52 0x02, // Length 53 BTM_BLE_AD_TYPE_FLAG, 54 BTM_BLE_BREDR_NOT_SPT | BTM_BLE_GEN_DISC_FLAG}; 55 56 scan_data_ = {0x04, // Length 57 BTM_BLE_AD_TYPE_NAME_SHORT, 'k', 'e', 'y'}; 58 } 59 60 std::string Keyboard::GetTypeString() const { return "keyboard"; } 61 62 void Keyboard::Initialize(const vector<std::string>& args) { 63 if (args.size() < 2) return; 64 65 BtAddress addr; 66 if (addr.FromString(args[1])) SetBtAddress(addr); 67 68 if (args.size() < 3) return; 69 70 SetAdvertisementInterval(std::chrono::milliseconds(std::stoi(args[2]))); 71 } 72 73 bool Keyboard::LeConnect() { return true; } 74 75 bool Keyboard::IsPageScanAvailable() const { return false; } 76 } // namespace test_vendor_lib 77