use hidpp::channel::HidppChannel;
use tracing::warn;
use super::{PairingError, RECEIVER_INDEX};
pub(super) const NOTIFICATIONS: u8 = 0x00;
pub(super) const UNIFYING_PAIRING: u8 = 0xb2;
pub(super) const BOLT_DISCOVERY: u8 = 0xc0;
pub(super) const BOLT_PAIRING: u8 = 0xc1;
pub(super) const NOTIFICATION_FLAGS: [u8; 3] = [0x00, 0x09, 0x00];
pub(super) async fn write_register(
channel: &HidppChannel,
address: u8,
payload: [u8; 3],
) -> Result<(), PairingError> {
channel
.write_register(RECEIVER_INDEX, address, payload)
.await
.map_err(|e| {
warn!(
register = format_args!("{address:#04x}"),
?e,
"register write failed"
);
PairingError::Register(format!("{e}"))
})
}
pub(super) async fn write_long_register(
channel: &HidppChannel,
address: u8,
payload: [u8; 16],
) -> Result<(), PairingError> {
channel
.write_long_register(RECEIVER_INDEX, address, payload)
.await
.map_err(|e| {
warn!(
register = format_args!("{address:#04x}"),
?e,
"long register write failed"
);
PairingError::Register(format!("{e}"))
})
}