Skip to content

Instantly share code, notes, and snippets.

@dongfg
Last active April 11, 2026 14:07
Show Gist options
  • Select an option

  • Save dongfg/0beca20cfd5e5f6bc1a8ede9d8efccc1 to your computer and use it in GitHub Desktop.

Select an option

Save dongfg/0beca20cfd5e5f6bc1a8ede9d8efccc1 to your computer and use it in GitHub Desktop.
Time Sync For LT84 Keyboard. Inspired By https://github.com/Danct12/LT84_TimeSync, But for windows
No. Time Source Destination Protocol Length Info
1 0.000000 host 3.5.0 USB 100 URB_CONTROL out
Frame 1: Packet, 100 bytes on wire (800 bits), 100 bytes captured (800 bits) on interface \\.\USBPcap3, id 0
Section number: 1
Interface id: 0 (\\.\USBPcap3)
Encapsulation type: USB packets with USBPcap header (152)
Arrival Time: Apr 11, 2026 21:29:40.143394000 中国标准时间
UTC Arrival Time: Apr 11, 2026 13:29:40.143394000 UTC
Epoch Arrival Time: 1775914180.143394000
[Time shift for this packet: 0.000000000 seconds]
[Time since reference or first frame: 0.000000000 seconds]
Frame Number: 1
Frame Length: 100 bytes (800 bits)
Capture Length: 100 bytes (800 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: usb]
Character encoding: ASCII (0)
USB URB
Setup Data
bmRequestType: 0x21
0... .... = Direction: Host-to-device
.01. .... = Type: Class (0x1)
...0 0001 = Recipient: Interface (0x01)
bRequest: 9
wValue: 0x0300
wIndex: 3 (0x0003)
wLength: 64
Data Fragment: 04180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
No. Time Source Destination Protocol Length Info
2 0.011125 host 3.5.0 USB 36 URB_CONTROL in
Frame 2: Packet, 36 bytes on wire (288 bits), 36 bytes captured (288 bits) on interface \\.\USBPcap3, id 0
Section number: 1
Interface id: 0 (\\.\USBPcap3)
Encapsulation type: USB packets with USBPcap header (152)
Arrival Time: Apr 11, 2026 21:29:40.154519000 中国标准时间
UTC Arrival Time: Apr 11, 2026 13:29:40.154519000 UTC
Epoch Arrival Time: 1775914180.154519000
[Time shift for this packet: 0.000000000 seconds]
[Time delta from previous captured frame: 11.125000 milliseconds]
[Time delta from previous displayed frame: 11.125000 milliseconds]
[Time since reference or first frame: 11.125000 milliseconds]
Frame Number: 2
Frame Length: 36 bytes (288 bits)
Capture Length: 36 bytes (288 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: usb]
Character encoding: ASCII (0)
USB URB
Setup Data
bmRequestType: 0xa1
1... .... = Direction: Device-to-host
.01. .... = Type: Class (0x1)
...0 0001 = Recipient: Interface (0x01)
bRequest: 1
wValue: 0x0300
wIndex: 3 (0x0003)
wLength: 64
No. Time Source Destination Protocol Length Info
3 0.022107 host 3.5.0 USB 100 URB_CONTROL out
Frame 3: Packet, 100 bytes on wire (800 bits), 100 bytes captured (800 bits) on interface \\.\USBPcap3, id 0
Section number: 1
Interface id: 0 (\\.\USBPcap3)
Encapsulation type: USB packets with USBPcap header (152)
Arrival Time: Apr 11, 2026 21:29:40.165501000 中国标准时间
UTC Arrival Time: Apr 11, 2026 13:29:40.165501000 UTC
Epoch Arrival Time: 1775914180.165501000
[Time shift for this packet: 0.000000000 seconds]
[Time delta from previous captured frame: 10.982000 milliseconds]
[Time delta from previous displayed frame: 10.982000 milliseconds]
[Time since reference or first frame: 22.107000 milliseconds]
Frame Number: 3
Frame Length: 100 bytes (800 bits)
Capture Length: 100 bytes (800 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: usb]
Character encoding: ASCII (0)
USB URB
Setup Data
bmRequestType: 0x21
0... .... = Direction: Host-to-device
.01. .... = Type: Class (0x1)
...0 0001 = Recipient: Interface (0x01)
bRequest: 9
wValue: 0x0300
wIndex: 3 (0x0003)
wLength: 64
Data Fragment: 04280000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
No. Time Source Destination Protocol Length Info
4 0.032771 host 3.5.0 USB 36 URB_CONTROL in
Frame 4: Packet, 36 bytes on wire (288 bits), 36 bytes captured (288 bits) on interface \\.\USBPcap3, id 0
Section number: 1
Interface id: 0 (\\.\USBPcap3)
Encapsulation type: USB packets with USBPcap header (152)
Arrival Time: Apr 11, 2026 21:29:40.176165000 中国标准时间
UTC Arrival Time: Apr 11, 2026 13:29:40.176165000 UTC
Epoch Arrival Time: 1775914180.176165000
[Time shift for this packet: 0.000000000 seconds]
[Time delta from previous captured frame: 10.664000 milliseconds]
[Time delta from previous displayed frame: 10.664000 milliseconds]
[Time since reference or first frame: 32.771000 milliseconds]
Frame Number: 4
Frame Length: 36 bytes (288 bits)
Capture Length: 36 bytes (288 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: usb]
Character encoding: ASCII (0)
USB URB
Setup Data
bmRequestType: 0xa1
1... .... = Direction: Device-to-host
.01. .... = Type: Class (0x1)
...0 0001 = Recipient: Interface (0x01)
bRequest: 1
wValue: 0x0300
wIndex: 3 (0x0003)
wLength: 64
No. Time Source Destination Protocol Length Info
5 0.043361 host 3.5.0 USB 100 URB_CONTROL out
Frame 5: Packet, 100 bytes on wire (800 bits), 100 bytes captured (800 bits) on interface \\.\USBPcap3, id 0
Section number: 1
Interface id: 0 (\\.\USBPcap3)
Encapsulation type: USB packets with USBPcap header (152)
Arrival Time: Apr 11, 2026 21:29:40.186755000 中国标准时间
UTC Arrival Time: Apr 11, 2026 13:29:40.186755000 UTC
Epoch Arrival Time: 1775914180.186755000
[Time shift for this packet: 0.000000000 seconds]
[Time delta from previous captured frame: 10.590000 milliseconds]
[Time delta from previous displayed frame: 10.590000 milliseconds]
[Time since reference or first frame: 43.361000 milliseconds]
Frame Number: 5
Frame Length: 100 bytes (800 bits)
Capture Length: 100 bytes (800 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: usb]
Character encoding: ASCII (0)
USB URB
Setup Data
bmRequestType: 0x21
0... .... = Direction: Host-to-device
.01. .... = Type: Class (0x1)
...0 0001 = Recipient: Interface (0x01)
bRequest: 9
wValue: 0x0300
wIndex: 3 (0x0003)
wLength: 64
Data Fragment: 00015a1a040b151d2800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002828
No. Time Source Destination Protocol Length Info
6 0.054978 host 3.5.0 USB 36 URB_CONTROL in
Frame 6: Packet, 36 bytes on wire (288 bits), 36 bytes captured (288 bits) on interface \\.\USBPcap3, id 0
Section number: 1
Interface id: 0 (\\.\USBPcap3)
Encapsulation type: USB packets with USBPcap header (152)
Arrival Time: Apr 11, 2026 21:29:40.198372000 中国标准时间
UTC Arrival Time: Apr 11, 2026 13:29:40.198372000 UTC
Epoch Arrival Time: 1775914180.198372000
[Time shift for this packet: 0.000000000 seconds]
[Time delta from previous captured frame: 11.617000 milliseconds]
[Time delta from previous displayed frame: 11.617000 milliseconds]
[Time since reference or first frame: 54.978000 milliseconds]
Frame Number: 6
Frame Length: 36 bytes (288 bits)
Capture Length: 36 bytes (288 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: usb]
Character encoding: ASCII (0)
USB URB
Setup Data
bmRequestType: 0xa1
1... .... = Direction: Device-to-host
.01. .... = Type: Class (0x1)
...0 0001 = Recipient: Interface (0x01)
bRequest: 1
wValue: 0x0300
wIndex: 3 (0x0003)
wLength: 64
No. Time Source Destination Protocol Length Info
7 0.065910 host 3.5.0 USB 100 URB_CONTROL out
Frame 7: Packet, 100 bytes on wire (800 bits), 100 bytes captured (800 bits) on interface \\.\USBPcap3, id 0
Section number: 1
Interface id: 0 (\\.\USBPcap3)
Encapsulation type: USB packets with USBPcap header (152)
Arrival Time: Apr 11, 2026 21:29:40.209304000 中国标准时间
UTC Arrival Time: Apr 11, 2026 13:29:40.209304000 UTC
Epoch Arrival Time: 1775914180.209304000
[Time shift for this packet: 0.000000000 seconds]
[Time delta from previous captured frame: 10.932000 milliseconds]
[Time delta from previous displayed frame: 10.932000 milliseconds]
[Time since reference or first frame: 65.910000 milliseconds]
Frame Number: 7
Frame Length: 100 bytes (800 bits)
Capture Length: 100 bytes (800 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: usb]
Character encoding: ASCII (0)
USB URB
Setup Data
bmRequestType: 0x21
0... .... = Direction: Host-to-device
.01. .... = Type: Class (0x1)
...0 0001 = Recipient: Interface (0x01)
bRequest: 9
wValue: 0x0300
wIndex: 3 (0x0003)
wLength: 64
Data Fragment: 04020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
No. Time Source Destination Protocol Length Info
8 0.076469 host 3.5.0 USB 36 URB_CONTROL in
Frame 8: Packet, 36 bytes on wire (288 bits), 36 bytes captured (288 bits) on interface \\.\USBPcap3, id 0
Section number: 1
Interface id: 0 (\\.\USBPcap3)
Encapsulation type: USB packets with USBPcap header (152)
Arrival Time: Apr 11, 2026 21:29:40.219863000 中国标准时间
UTC Arrival Time: Apr 11, 2026 13:29:40.219863000 UTC
Epoch Arrival Time: 1775914180.219863000
[Time shift for this packet: 0.000000000 seconds]
[Time delta from previous captured frame: 10.559000 milliseconds]
[Time delta from previous displayed frame: 10.559000 milliseconds]
[Time since reference or first frame: 76.469000 milliseconds]
Frame Number: 8
Frame Length: 36 bytes (288 bits)
Capture Length: 36 bytes (288 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: usb]
Character encoding: ASCII (0)
USB URB
Setup Data
bmRequestType: 0xa1
1... .... = Direction: Device-to-host
.01. .... = Type: Class (0x1)
...0 0001 = Recipient: Interface (0x01)
bRequest: 1
wValue: 0x0300
wIndex: 3 (0x0003)
wLength: 64
No. Time Source Destination Protocol Length Info
1 0.000000 host 3.5.0 USB 100 URB_CONTROL out
Frame 1: Packet, 100 bytes on wire (800 bits), 100 bytes captured (800 bits) on interface \\.\USBPcap3, id 0
Section number: 1
Interface id: 0 (\\.\USBPcap3)
Encapsulation type: USB packets with USBPcap header (152)
Arrival Time: Apr 11, 2026 21:30:41.533001000 中国标准时间
UTC Arrival Time: Apr 11, 2026 13:30:41.533001000 UTC
Epoch Arrival Time: 1775914241.533001000
[Time shift for this packet: 0.000000000 seconds]
[Time since reference or first frame: 0.000000000 seconds]
Frame Number: 1
Frame Length: 100 bytes (800 bits)
Capture Length: 100 bytes (800 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: usb]
Character encoding: ASCII (0)
USB URB
Setup Data
bmRequestType: 0x21
0... .... = Direction: Host-to-device
.01. .... = Type: Class (0x1)
...0 0001 = Recipient: Interface (0x01)
bRequest: 9
wValue: 0x0300
wIndex: 3 (0x0003)
wLength: 64
Data Fragment: 04180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
No. Time Source Destination Protocol Length Info
2 0.010512 host 3.5.0 USB 36 URB_CONTROL in
Frame 2: Packet, 36 bytes on wire (288 bits), 36 bytes captured (288 bits) on interface \\.\USBPcap3, id 0
Section number: 1
Interface id: 0 (\\.\USBPcap3)
Encapsulation type: USB packets with USBPcap header (152)
Arrival Time: Apr 11, 2026 21:30:41.543513000 中国标准时间
UTC Arrival Time: Apr 11, 2026 13:30:41.543513000 UTC
Epoch Arrival Time: 1775914241.543513000
[Time shift for this packet: 0.000000000 seconds]
[Time delta from previous captured frame: 10.512000 milliseconds]
[Time delta from previous displayed frame: 10.512000 milliseconds]
[Time since reference or first frame: 10.512000 milliseconds]
Frame Number: 2
Frame Length: 36 bytes (288 bits)
Capture Length: 36 bytes (288 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: usb]
Character encoding: ASCII (0)
USB URB
Setup Data
bmRequestType: 0xa1
1... .... = Direction: Device-to-host
.01. .... = Type: Class (0x1)
...0 0001 = Recipient: Interface (0x01)
bRequest: 1
wValue: 0x0300
wIndex: 3 (0x0003)
wLength: 64
No. Time Source Destination Protocol Length Info
3 0.021068 host 3.5.0 USB 100 URB_CONTROL out
Frame 3: Packet, 100 bytes on wire (800 bits), 100 bytes captured (800 bits) on interface \\.\USBPcap3, id 0
Section number: 1
Interface id: 0 (\\.\USBPcap3)
Encapsulation type: USB packets with USBPcap header (152)
Arrival Time: Apr 11, 2026 21:30:41.554069000 中国标准时间
UTC Arrival Time: Apr 11, 2026 13:30:41.554069000 UTC
Epoch Arrival Time: 1775914241.554069000
[Time shift for this packet: 0.000000000 seconds]
[Time delta from previous captured frame: 10.556000 milliseconds]
[Time delta from previous displayed frame: 10.556000 milliseconds]
[Time since reference or first frame: 21.068000 milliseconds]
Frame Number: 3
Frame Length: 100 bytes (800 bits)
Capture Length: 100 bytes (800 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: usb]
Character encoding: ASCII (0)
USB URB
Setup Data
bmRequestType: 0x21
0... .... = Direction: Host-to-device
.01. .... = Type: Class (0x1)
...0 0001 = Recipient: Interface (0x01)
bRequest: 9
wValue: 0x0300
wIndex: 3 (0x0003)
wLength: 64
Data Fragment: 04280000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
No. Time Source Destination Protocol Length Info
4 0.032082 host 3.5.0 USB 36 URB_CONTROL in
Frame 4: Packet, 36 bytes on wire (288 bits), 36 bytes captured (288 bits) on interface \\.\USBPcap3, id 0
Section number: 1
Interface id: 0 (\\.\USBPcap3)
Encapsulation type: USB packets with USBPcap header (152)
Arrival Time: Apr 11, 2026 21:30:41.565083000 中国标准时间
UTC Arrival Time: Apr 11, 2026 13:30:41.565083000 UTC
Epoch Arrival Time: 1775914241.565083000
[Time shift for this packet: 0.000000000 seconds]
[Time delta from previous captured frame: 11.014000 milliseconds]
[Time delta from previous displayed frame: 11.014000 milliseconds]
[Time since reference or first frame: 32.082000 milliseconds]
Frame Number: 4
Frame Length: 36 bytes (288 bits)
Capture Length: 36 bytes (288 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: usb]
Character encoding: ASCII (0)
USB URB
Setup Data
bmRequestType: 0xa1
1... .... = Direction: Device-to-host
.01. .... = Type: Class (0x1)
...0 0001 = Recipient: Interface (0x01)
bRequest: 1
wValue: 0x0300
wIndex: 3 (0x0003)
wLength: 64
No. Time Source Destination Protocol Length Info
5 0.043704 host 3.5.0 USB 100 URB_CONTROL out
Frame 5: Packet, 100 bytes on wire (800 bits), 100 bytes captured (800 bits) on interface \\.\USBPcap3, id 0
Section number: 1
Interface id: 0 (\\.\USBPcap3)
Encapsulation type: USB packets with USBPcap header (152)
Arrival Time: Apr 11, 2026 21:30:41.576705000 中国标准时间
UTC Arrival Time: Apr 11, 2026 13:30:41.576705000 UTC
Epoch Arrival Time: 1775914241.576705000
[Time shift for this packet: 0.000000000 seconds]
[Time delta from previous captured frame: 11.622000 milliseconds]
[Time delta from previous displayed frame: 11.622000 milliseconds]
[Time since reference or first frame: 43.704000 milliseconds]
Frame Number: 5
Frame Length: 100 bytes (800 bits)
Capture Length: 100 bytes (800 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: usb]
Character encoding: ASCII (0)
USB URB
Setup Data
bmRequestType: 0x21
0... .... = Direction: Host-to-device
.01. .... = Type: Class (0x1)
...0 0001 = Recipient: Interface (0x01)
bRequest: 9
wValue: 0x0300
wIndex: 3 (0x0003)
wLength: 64
Data Fragment: 00015a1a040b151e2900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002929
No. Time Source Destination Protocol Length Info
6 0.054213 host 3.5.0 USB 36 URB_CONTROL in
Frame 6: Packet, 36 bytes on wire (288 bits), 36 bytes captured (288 bits) on interface \\.\USBPcap3, id 0
Section number: 1
Interface id: 0 (\\.\USBPcap3)
Encapsulation type: USB packets with USBPcap header (152)
Arrival Time: Apr 11, 2026 21:30:41.587214000 中国标准时间
UTC Arrival Time: Apr 11, 2026 13:30:41.587214000 UTC
Epoch Arrival Time: 1775914241.587214000
[Time shift for this packet: 0.000000000 seconds]
[Time delta from previous captured frame: 10.509000 milliseconds]
[Time delta from previous displayed frame: 10.509000 milliseconds]
[Time since reference or first frame: 54.213000 milliseconds]
Frame Number: 6
Frame Length: 36 bytes (288 bits)
Capture Length: 36 bytes (288 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: usb]
Character encoding: ASCII (0)
USB URB
Setup Data
bmRequestType: 0xa1
1... .... = Direction: Device-to-host
.01. .... = Type: Class (0x1)
...0 0001 = Recipient: Interface (0x01)
bRequest: 1
wValue: 0x0300
wIndex: 3 (0x0003)
wLength: 64
No. Time Source Destination Protocol Length Info
7 0.065296 host 3.5.0 USB 100 URB_CONTROL out
Frame 7: Packet, 100 bytes on wire (800 bits), 100 bytes captured (800 bits) on interface \\.\USBPcap3, id 0
Section number: 1
Interface id: 0 (\\.\USBPcap3)
Encapsulation type: USB packets with USBPcap header (152)
Arrival Time: Apr 11, 2026 21:30:41.598297000 中国标准时间
UTC Arrival Time: Apr 11, 2026 13:30:41.598297000 UTC
Epoch Arrival Time: 1775914241.598297000
[Time shift for this packet: 0.000000000 seconds]
[Time delta from previous captured frame: 11.083000 milliseconds]
[Time delta from previous displayed frame: 11.083000 milliseconds]
[Time since reference or first frame: 65.296000 milliseconds]
Frame Number: 7
Frame Length: 100 bytes (800 bits)
Capture Length: 100 bytes (800 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: usb]
Character encoding: ASCII (0)
USB URB
Setup Data
bmRequestType: 0x21
0... .... = Direction: Host-to-device
.01. .... = Type: Class (0x1)
...0 0001 = Recipient: Interface (0x01)
bRequest: 9
wValue: 0x0300
wIndex: 3 (0x0003)
wLength: 64
Data Fragment: 04020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
No. Time Source Destination Protocol Length Info
8 0.075672 host 3.5.0 USB 36 URB_CONTROL in
Frame 8: Packet, 36 bytes on wire (288 bits), 36 bytes captured (288 bits) on interface \\.\USBPcap3, id 0
Section number: 1
Interface id: 0 (\\.\USBPcap3)
Encapsulation type: USB packets with USBPcap header (152)
Arrival Time: Apr 11, 2026 21:30:41.608673000 中国标准时间
UTC Arrival Time: Apr 11, 2026 13:30:41.608673000 UTC
Epoch Arrival Time: 1775914241.608673000
[Time shift for this packet: 0.000000000 seconds]
[Time delta from previous captured frame: 10.376000 milliseconds]
[Time delta from previous displayed frame: 10.376000 milliseconds]
[Time since reference or first frame: 75.672000 milliseconds]
Frame Number: 8
Frame Length: 36 bytes (288 bits)
Capture Length: 36 bytes (288 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: usb]
Character encoding: ASCII (0)
USB URB
Setup Data
bmRequestType: 0xa1
1... .... = Direction: Device-to-host
.01. .... = Type: Class (0x1)
...0 0001 = Recipient: Interface (0x01)
bRequest: 1
wValue: 0x0300
wIndex: 3 (0x0003)
wLength: 64
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <windows.h>
#include <hidapi.h>
#define MAX_STR 255
int main(int argc, char *argv[])
{
unsigned char buf_send[65], buf_get[65];
wchar_t wstr[MAX_STR];
hid_device *handle;
int ret;
int year, month, day, hour, minutes, seconds;
// 新增功能:判断是否传入了命令行参数
if (argc >= 2) {
int full_year;
// 尝试解析传入的时间字符串,格式应为 "YYYY-MM-DD HH:MM:SS"
if (sscanf(argv[1], "%d-%d-%d %d:%d:%d", &full_year, &month, &day, &hour, &minutes, &seconds) == 6) {
year = full_year % 100; // 提取年份后两位,例如 2026 -> 26
printf("Debug mode: Using provided time...\n");
} else {
printf("Error: Invalid time format.\n");
printf("Usage: %s \"YYYY-MM-DD HH:MM:SS\"\n", argv[0]);
printf("Example: %s \"2026-04-11 19:26:21\"\n", argv[0]);
return 1;
}
} else {
// 默认行为:获取系统当前时间
time_t epoch = time(NULL);
struct tm *timeinfo = localtime(&epoch);
year = timeinfo->tm_year - 100;
month = timeinfo->tm_mon + 1;
day = timeinfo->tm_mday;
hour = timeinfo->tm_hour;
minutes = timeinfo->tm_min;
seconds = timeinfo->tm_sec;
}
hid_init();
// ==========================================
// 核心修复:遍历设备,寻找 Interface 3
// ==========================================
struct hid_device_info *devs, *cur_dev;
devs = hid_enumerate(0x0c45, 0x8009);
cur_dev = devs;
while (cur_dev) {
printf("Found device | Interface: %d | Usage Page: 0x%04hx | Path: %s\n",
cur_dev->interface_number, cur_dev->usage_page, cur_dev->path);
// 匹配目标接口 3
if (cur_dev->interface_number == 3) {
handle = hid_open_path(cur_dev->path);
if (handle) {
printf("--> Successfully opened Interface 3!\n");
break;
}
}
cur_dev = cur_dev->next;
}
hid_free_enumeration(devs);
// 如果没找到接口3,或者打开失败,尝试退化机制
if (!handle) {
printf("Warning: Could not open Interface 3 directly. Trying default...\n");
handle = hid_open(0x0c45, 0x8009, NULL);
}
if (!handle) {
printf("Error: Unable to open device. Not plugged in or lack permissions (Try running as Admin).\n");
hid_exit();
return 1;
}
hid_get_manufacturer_string(handle, wstr, MAX_STR);
printf("Manufacturer: %ls\n", wstr);
hid_get_product_string(handle, wstr, MAX_STR);
printf("Product: %ls\n", wstr);
// ==========================================
// 严格按照抓包的4步流程执行
// ==========================================
// 第1步:发送初始化包1 (对应抓包Frame 1)
memset(buf_send, 0, sizeof(buf_send));
buf_send[0] = 0x00; // Report ID = 0
buf_send[1] = 0x04; // Data Fragment[0]
buf_send[2] = 0x18; // Data Fragment[1]
ret = hid_send_feature_report(handle, buf_send, 65);
ret = hid_get_feature_report(handle, buf_get, 65);
Sleep(5);
// 第2步:发送初始化包2 (对应抓包Frame 3)
memset(buf_send, 0, sizeof(buf_send));
buf_send[0] = 0x00; // Report ID = 0
buf_send[1] = 0x04; // Data Fragment[0]
buf_send[2] = 0x28; // Data Fragment[1]
buf_send[3] = 0x00; // Data Fragment[2]
buf_send[4] = 0x00; // Data Fragment[3]
buf_send[5] = 0x00; // Data Fragment[4]
buf_send[6] = 0x00; // Data Fragment[5]
buf_send[7] = 0x01; // Data Fragment[6]
ret = hid_send_feature_report(handle, buf_send, 65);
ret = hid_get_feature_report(handle, buf_get, 65);
Sleep(5);
// 第3步:发送时间同步包 (对应抓包Frame 5,字节级精确对齐)
memset(buf_send, 0, sizeof(buf_send));
buf_send[0] = 0x00; // Report ID = 0
buf_send[1] = 0x00; // Data Fragment[0]
buf_send[2] = 0x01; // Data Fragment[1]
buf_send[3] = 0x5a; // Data Fragment[2] (固定值)
buf_send[4] = year; // Data Fragment[3] (Year low 2 digits)
buf_send[5] = month; // Data Fragment[4] (Month)
buf_send[6] = day; // Data Fragment[5] (Day)
buf_send[7] = hour; // Data Fragment[6] (Hour)
buf_send[8] = minutes; // Data Fragment[7] (Minutes)
buf_send[9] = seconds; // Data Fragment[8] (Seconds)
buf_send[63] = seconds; // Data Fragment[62] (Seconds repeat check 1)
buf_send[64] = seconds; // Data Fragment[63] (Seconds repeat check 2)
ret = hid_send_feature_report(handle, buf_send, 65);
ret = hid_get_feature_report(handle, buf_get, 65);
Sleep(5);
// 第4步:发送结束包 (对应抓包Frame 7)
memset(buf_send, 0, sizeof(buf_send));
buf_send[0] = 0x00; // Report ID = 0
buf_send[1] = 0x04; // Data Fragment[0]
buf_send[2] = 0x02; // Data Fragment[1]
ret = hid_send_feature_report(handle, buf_send, 65);
ret = hid_get_feature_report(handle, buf_get, 65);
hid_close(handle);
hid_exit();
if (ret < 0) {
printf("Failed to set date and time.\n");
return 1;
}
printf("Date/Time successfully set to 20%02u-%02u-%02u %02u:%02u:%02u\n",
year, month, day, hour, minutes, seconds);
return 0;
}
@dongfg
Copy link
Copy Markdown
Author

dongfg commented Apr 11, 2026

Build

Download [hidapi-win.zip]https://github.com/libusb/hidapi/releases/download/hidapi-0.15.0/hidapi-win.zip put hidapi-win folder with lt84_timesync.c

x86_64-w64-mingw32-gcc lt84_timesync.c \
    -I./hidapi-win/include \
    -L./hidapi-win/x64 \
    -lhidapi \
    -o lt84_timesync.exe

Or download my build if you trust it

lt84_timesync.zip (lt84_timesync.exe + hidapi.dll)

Usage

cp hidapi.dll from hidapi-win.zip put with lt84_timesync.exe

.\lt84_timesync.exe
Found device | Interface: 0 | Usage Page: 0x0001 | Path: \\?\HID#VID_0C45&PID_8009&MI_00#7&1fbd15f4&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\KBD
Found device | Interface: 1 | Usage Page: 0x000c | Path: \\?\HID#VID_0C45&PID_8009&MI_01&Col01#7&3780a239&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
Found device | Interface: 1 | Usage Page: 0x0001 | Path: \\?\HID#VID_0C45&PID_8009&MI_01&Col02#7&3780a239&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
Found device | Interface: 1 | Usage Page: 0x0001 | Path: \\?\HID#VID_0C45&PID_8009&MI_01&Col04#7&3780a239&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
Found device | Interface: 3 | Usage Page: 0xff13 | Path: \\?\HID#VID_0C45&PID_8009&MI_03#7&102dd94b&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
--> Successfully opened Interface 3!
Manufacturer: SONiX
Product: LT84
Date/Time successfully set to 2026-04-11 21:59:38

# for debug, pass custom time
.\lt84_timesync.exe "2026-04-11 19:00:00"
Debug mode: Using provided time...
Found device | Interface: 0 | Usage Page: 0x0001 | Path: \\?\HID#VID_0C45&PID_8009&MI_00#7&1fbd15f4&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\KBD
Found device | Interface: 1 | Usage Page: 0x000c | Path: \\?\HID#VID_0C45&PID_8009&MI_01&Col01#7&3780a239&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
Found device | Interface: 1 | Usage Page: 0x0001 | Path: \\?\HID#VID_0C45&PID_8009&MI_01&Col02#7&3780a239&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
Found device | Interface: 1 | Usage Page: 0x0001 | Path: \\?\HID#VID_0C45&PID_8009&MI_01&Col04#7&3780a239&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
Found device | Interface: 3 | Usage Page: 0xff13 | Path: \\?\HID#VID_0C45&PID_8009&MI_03#7&102dd94b&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
--> Successfully opened Interface 3!
Manufacturer: SONiX
Product: LT84
Date/Time successfully set to 2026-04-11 19:00:00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment