OpenLogi
功能(Features)

0x1814 · changeHost

查询多主机设备的槽位数量并切换当前连接,同时支持每槽 cookie 管理以实现增强型连接失败回退。

多主机设备通过此功能查询支持的主机槽位 / RF 频道数量并在它们之间切换。get_host_info 返回一个 ChangeHostInfo 结构体,包含主机数量当前主机索引以及 ChangeHostCapabilities 标志位字段;set_current_host 发送一个"发送即忘"的切换请求——设备在主机切换时通常会重置连接,因此不等待响应。

另有两个函数管理每个主机槽位的cookie 字节——设备非易失性存储中的一个小数值。get_cookies 返回每个槽位对应的一字节 cookie;set_cookie 写入单个条目。固件在新主机配对到该槽位时会清除其 cookie。增强型主机切换(ENHANCED_HOST_SWITCH 能力标志)利用非零 cookie 在连接失败时选择备用主机,之后再返回原始槽位。

  • ChangeHostInfo —— host_countcurrent_hostcapabilities
  • ChangeHostCapabilities::ENHANCED_HOST_SWITCH —— 连接失败时先回退到 cookie 非零的主机,再返回原始主机。

规格: Logitech HID++ 2.0 —— changeHost用于: openlogi-hidpp 中的类型化封装。

Function reference

The ChangeHostFeature wrapper (0x1814) exposes methods for querying and changing the active host slot on multi-host devices, plus per-slot cookie management.

Methods

FunctionHID++ fnSignatureReturns
get_host_info0()ChangeHostInfo
set_current_host1(host: u8)()
get_cookies2(host_count: u8)Vec<u8>
set_cookie3(host: u8, cookie: u8)()

All methods are async and return Result<…, Hidpp20Error>.

Types

ChangeHostInfo

Host configuration returned by get_host_info.

FieldTypeDescription
host_countu8Number of hosts / RF channels.
current_hostu8Current host index, in 0..host_count.
capabilitiesChangeHostCapabilitiesHost-switching capabilities.

ChangeHostCapabilities

Host-switching capabilities bitflags reported by get_host_info.

FlagBit/ValueDescription
ENHANCED_HOST_SWITCH1 << 0Enhanced host switching is enabled: on a failed connection the device falls back to another host with a non-zero cookie before returning to the original host.

Wire format

Short 3-byte request payloads are used for all functions; responses are read from the 16-byte long payload via extend_payload().

get_host_info (fn 0)

Request: [0x00, 0x00, 0x00] (no parameters)

Response (byte → field):

ByteFieldNotes
0host_countTotal number of host slots / RF channels
1current_hostActive host index, zero-based
2capabilitiesChangeHostCapabilities bitflags; bit 0 = ENHANCED_HOST_SWITCH

set_current_host (fn 1)

Sent as a notify (fire-and-forget); no response is read.

Request: [host, 0x00, 0x00]

ByteFieldNotes
0hostTarget host index to activate
1–2Padding, always 0x00

get_cookies (fn 2)

Request: [0x00, 0x00, 0x00] (no parameters)

Response: bytes payload[0..host_count] — one cookie byte per host slot in order. The caller supplies host_count (from get_host_info) to slice the response; bytes beyond host_count are ignored.

ByteFieldNotes
0cookie for host 0
1cookie for host 1
cookie for host N-1Up to host_count bytes

Request: [host, cookie, 0x00]

ByteFieldNotes
0hostHost slot index whose cookie is being written
1cookieArbitrary byte value to store in NVM
2Padding, always 0x00

The device ACK response is awaited but its payload is discarded.

Usage (Rust)

use hidpp::feature::change_host::ChangeHostFeature;

// device: &mut Device, already created via Device::new(channel, index)
device.enumerate_features().await?;
if let Some(feat) = device.get_feature::<ChangeHostFeature>() {
    // Query host count, current host, and capabilities
    let info = feat.get_host_info().await?;
    println!("hosts: {}, current: {}", info.host_count, info.current_host);

    // Read the per-host cookies (one byte per slot)
    let cookies = feat.get_cookies(info.host_count).await?;
    println!("cookies: {:?}", cookies);

    // Switch to host 1 (fire-and-forget; device will reset its connection)
    feat.set_current_host(1).await?;
}

本页目录