// src/core/gatt-path-equality.ts import { attachmentRecordsEqual } from '../backend-contract/identity' import type { CharacteristicPath, ConnectionPath, DatabasePath, DescriptorPath } from '../backend-contract/gatt' export function connectionPathsEqual( left: ConnectionPath, right: ConnectionPath ): boolean { return ( left.attachmentId === right.attachmentId && attachmentRecordsEqual(left.attachment, right.attachment) && left.peerId === right.peerId && left.connectionId === right.connectionId && left.connectionGeneration === right.connectionGeneration && left.ownerLeaseId === right.ownerLeaseId ) } export function databasePathsEqual( left: DatabasePath, right: DatabasePath ): boolean { return ( connectionPathsEqual(left, right) && left.databaseId === right.databaseId && left.databaseGeneration === right.databaseGeneration ) } export function characteristicPathsEqual( left: CharacteristicPath, right: CharacteristicPath ): boolean { return ( databasePathsEqual(left, right) && left.serviceUuid === right.serviceUuid && left.serviceOccurrence === right.serviceOccurrence && left.characteristicUuid === right.characteristicUuid && left.characteristicOccurrence === right.characteristicOccurrence && left.validity === right.validity ) } export function descriptorPathsEqual( left: DescriptorPath, right: DescriptorPath ): boolean { return ( characteristicPathsEqual(left, right) && left.descriptorUuid === right.descriptorUuid && left.descriptorOccurrence === right.descriptorOccurrence ) } export function characteristicPathKey( path: CharacteristicPath ): string { return [ path.attachmentId, path.attachment.backendInstanceId, path.attachment.backendGeneration, path.attachment.adapter.adapterId, path.attachment.adapter.adapterGeneration, path.peerId, path.connectionId, path.connectionGeneration, path.ownerLeaseId, path.databaseId, path.databaseGeneration, path.serviceUuid, path.serviceOccurrence, path.characteristicUuid, path.characteristicOccurrence, path.validity ].join('|') }