SimpleBLE icon indicating copy to clipboard operation
SimpleBLE copied to clipboard

[WIP] Fix inconsistent Bluetooth address case across platforms

Open alejorrojas opened this issue 1 month ago • 1 comments

Description

This PR resolves issue #280 by ensuring that Peripheral::address() always returns addresses in a consistent uppercase format across all operating systems.

Problem

Previously, Peripheral::address() returned a lowercase std::string on Windows and an uppercase std::string on Linux, causing inconsistent behavior across platforms. This inconsistency made it difficult for users to reliably compare or display Bluetooth addresses.

Solution

Given that each OS handles the MAC string internally in a different way, we've added a new bluetoothAddress class (kvn::bluetoothAddress) that provides a consistent interface for Bluetooth address handling. This class:

  • Preserves the original case internally (via raw() method) for compatibility with OS-specific implementations
  • Always exposes an uppercase version when converted to string (via to_string() method or implicit conversion to std::string)
  • Provides case-insensitive comparison operators (== and <)
  • Maintains backward compatibility through implicit conversion to std::string, ensuring existing code continues to work

The BluetoothAddress type alias has been updated from std::string to kvn::bluetoothAddress in simpleble/include/simpleble/Types.h, ensuring that all Peripheral::address() calls now return a consistent uppercase format regardless of the underlying OS implementation.

Changes

  • Added dependencies/external/kvn/kvn_bluetooth_address.h - New bluetoothAddress class implementation
  • Updated simpleble/include/simpleble/Types.h - Changed BluetoothAddress type alias from std::string to kvn::bluetoothAddress

Related Issue

Fixes #280

alejorrojas avatar Dec 18 '25 23:12 alejorrojas