1# Copyright 2015 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5 6"""This module provides the information of Chameleon board.""" 7 8 9import collections 10import logging 11 12 13# Mapping from Chameleon MAC address to other information including 14# bluetooth MAC address on audio board. 15ChameleonInfo = collections.namedtuple( 16 'ChameleonInfo', ['bluetooth_mac_address']) 17 18_CHAMELEON_BOARD_INFO = { 19 '94:eb:2c:00:00:fb': ChameleonInfo('00:1F:84:01:03:68'), 20 '94:eb:2c:00:00:f9': ChameleonInfo('00:1F:84:01:03:73'), 21 '94:eb:2c:00:01:25': ChameleonInfo('00:1F:84:01:03:4F'), 22 '94:eb:2c:00:01:27': ChameleonInfo('00:1F:84:01:03:5B'), 23 '94:eb:2c:00:01:28': ChameleonInfo('00:1F:84:01:03:46'), 24 '94:eb:2c:00:01:29': ChameleonInfo('00:1F:84:01:03:26'), 25 '94:eb:2c:00:01:2b': ChameleonInfo('00:1F:84:01:03:5E'), 26 '94:eb:2c:00:01:2d': ChameleonInfo('00:1F:84:01:03:B6'), 27 '94:eb:2c:00:01:30': ChameleonInfo('00:1F:84:01:03:2F'), 28 '94:eb:2c:00:01:3a': ChameleonInfo('00:1F:84:01:03:42'), 29 '94:eb:2c:00:01:3b': ChameleonInfo('00:1F:84:01:03:44'), 30 '94:eb:2c:00:01:3d': ChameleonInfo('00:1F:84:01:03:59'), 31 '94:eb:2c:00:01:3e': ChameleonInfo('00:1F:84:01:03:74'), 32 '94:eb:2c:00:01:3f': ChameleonInfo('00:1F:84:01:03:8C'), 33 '94:eb:2c:00:01:41': ChameleonInfo('00:1F:84:01:03:B3'), 34 '94:eb:2c:10:06:65': ChameleonInfo('00:1F:84:01:03:6A'), 35 '94:eb:2c:10:06:66': ChameleonInfo('00:1F:84:01:03:21'), 36 '94:eb:2c:10:06:67': ChameleonInfo('00:1F:84:01:03:38'), 37 '94:eb:2c:10:06:68': ChameleonInfo('00:1F:84:01:03:52'), 38 '94:eb:2c:10:06:6c': ChameleonInfo('00:1F:84:01:03:2E'), 39 '94:eb:2c:10:06:6d': ChameleonInfo('00:1F:84:01:03:84'), 40 '94:eb:2c:10:06:6e': ChameleonInfo('00:1F:84:01:03:98'), 41 '94:eb:2c:10:06:72': ChameleonInfo('00:1F:84:01:03:61'), 42 '94:eb:2c:10:06:73': ChameleonInfo('00:1F:84:01:03:2C'), 43 '94:eb:2c:10:06:76': ChameleonInfo('00:1F:84:01:03:83'), 44 '94:eb:2c:10:06:7a': ChameleonInfo('00:1F:84:01:03:1C'), 45 '94:eb:2c:10:06:7b': ChameleonInfo('00:1F:84:01:03:A7'), 46 '94:eb:2c:10:06:7c': ChameleonInfo('00:1F:84:01:03:4B'), 47 '94:eb:2c:10:06:7d': ChameleonInfo('00:1F:81:88:88:9D'), 48 '94:eb:2c:10:06:7e': ChameleonInfo('00:1F:81:88:88:91'), 49 '94:eb:2c:10:06:7f': ChameleonInfo('00:1F:84:01:03:36'), 50 '94:eb:2c:00:01:26': ChameleonInfo('00:1F:84:01:03:56'), 51 '94:eb:2c:00:01:17': ChameleonInfo('00:1F:84:01:03:76'), 52 '94:eb:2c:00:01:31': ChameleonInfo('00:1F:84:01:03:20'), 53 '94:eb:2c:00:01:18': ChameleonInfo('00:1F:84:01:03:A1'), 54 '94:eb:2c:10:06:84': ChameleonInfo('00:1F:84:01:03:32'), 55 56 # TODO (rjahagir@): Verify the addresses listed above as 57 # as many were reworked/relocated. Some are duplicates. 58 # Listed below are added as of 4/13/17. 59 '94:eb:2c:10:06:74': ChameleonInfo('00:1F:84:01:03:88'), 60 '94:eb:2c:10:06:a9': ChameleonInfo('00:1F:84:01:03:6C'), 61 '94:eb:2c:10:06:89': ChameleonInfo('00:1F:84:01:03:40'), 62 '94:eb:2c:10:06:a3': ChameleonInfo('00:1F:84:01:03:24'), 63 '94:eb:2c:10:06:99': ChameleonInfo('00:1F:84:01:03:93'), 64 '94:eb:2c:10:06:9a': ChameleonInfo('00:1F:84:01:03:B1'), 65 '94:eb:2c:10:06:90': ChameleonInfo('00:1F:84:01:03:6E'), 66 '94:eb:2c:00:01:00': ChameleonInfo('00:1F:84:01:03:54'), 67 '94:eb:2c:00:01:01': ChameleonInfo('00:1F:84:01:03:3E'), 68 '94:eb:2c:10:06:9e': ChameleonInfo('00:1F:84:01:03:97'), 69 '94:eb:2c:10:06:9f': ChameleonInfo('00:1F:84:01:03:49'), 70 71 # Listed below added as of 5/12/17. 72 '94:eb:2c:10:06:98': ChameleonInfo('00:1F:84:01:03:65'), 73 '94:eb:2c:00:01:19': ChameleonInfo('00:1F:84:01:03:91'), 74 '94:eb:2c:10:06:8a': ChameleonInfo('00:1F:84:01:03:AB'), 75 '94:eb:2c:00:01:1d': ChameleonInfo('00:1F:84:01:03:A6'), 76 '94:eb:2c:10:06:95': ChameleonInfo('00:1F:84:01:03:66'), 77 78 # Lars device changed as of 10/17/17. 79 '94:eb:2c:00:01:1a': ChameleonInfo('00:1F:84:01:03:20') 80} 81 82class ChameleonInfoError(Exception): 83 """Error in chameleon_info.""" 84 pass 85 86 87def get_bluetooth_mac_address(chameleon_board): 88 """Gets bluetooth MAC address of a ChameleonBoard. 89 90 @param chameleon_board: A ChameleonBoard object. 91 92 @returns: A string for bluetooth MAC address of bluetooth module on the 93 audio board. 94 95 @raises: ChameleonInfoError if bluetooth MAC address of this Chameleon 96 board can not be found. 97 98 """ 99 chameleon_mac_address = chameleon_board.get_mac_address().lower() 100 if chameleon_mac_address not in _CHAMELEON_BOARD_INFO: 101 raise ChameleonInfoError( 102 'Chameleon info not found for %s' % chameleon_mac_address) 103 board_info = _CHAMELEON_BOARD_INFO[chameleon_mac_address] 104 logging.debug('Chameleon board info: %r', board_info) 105 return board_info.bluetooth_mac_address 106