def get_bd_addr(packet):
  """Helper function to get bd_addr filed from HCI CMD/EVT packet.

  Args:
    packet: packet object from pyshark.
  Returns:
    bd_addr value (MAC string). If the packet doesn't have bd_addr or not is not
    HCI CMD/EVT, will return None.
  """
  bd_addr = None
  if 'bthci_evt' in packet:
    bd_addr = packet['bthci_evt'].get('bd_addr')
  elif 'bthci_cmd' in packet:
    bd_addr = packet['bthci_cmd'].get('bd_addr')
  return bd_addr