File: utils.py

package info (click to toggle)
python-aioshelly 13.17.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 732 kB
  • sloc: python: 6,867; makefile: 7; sh: 3
file content (17 lines) | stat: -rw-r--r-- 538 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""Utilities for RPC devices."""

from __future__ import annotations

# The Bluetooth MAC address is the primary MAC address plus 2.
# https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/misc_system_api.html#mac-address


def bluetooth_mac_from_primary_mac(primary_mac: str) -> str:
    """Get Bluetooth MAC from primary MAC.

    MAC address must be in format "[0-F]{16}"

    :param primary_mac: Primary MAC address
    :return: Bluetooth MAC address
    """
    return f"{(int(primary_mac, 16) + 2):012X}"