1.在app.c中修改广播包数据
const u8 tbl_advData[] = {
0x05, 0x09, 'V', 'H', 'I', 'D',
0x02, 0x01, 0x05, // BLE limited discoverable mode and BR/EDR not supported
0x03, 0x19, 0xC5, 0x03, // 384, Generic Remote Control, Generic category
0x05, 0x02, 0x12, 0x18, 0x0F, 0x18, // incomplete list of service class UUIDs (0x1812, 0x180F)
};
2.修改报告描述符
static const u8 reportMap[] =
{
0x05, 0x0D , // Usage Page (Digitizer)
0x09, 0x04 , // Usage (Touch Screen)
0xA1, 0x01 , // Collection (Application)
0x85, 0x04 , // Report ID (4)
0x09, 0x22 , // Usage (Finger)
0xA1, 0x02 , // Collection (Logical)
0x05, 0x0D , // Usage Page (Digitizer)
0x95, 0x01 , // Report Count (1)
0x75, 0x06 , // Report Size (6)
0x09, 0x51 , // Usage (Contact Identifier)
0x15, 0x00 , // Logical Minimum (0)
0x25, 0x3F , // Logical Maximum (63)
0x81, 0x02 , // Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x09, 0x42 , // Usage (Tip Switch)
0x25, 0x01 , // Logical Maximum (1)
0x75, 0x01 , // Report Size (1)
0x95, 0x01 , // Report Count (1)
0x81, 0x02 , // Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x75, 0x01 , // Report Size (1)
0x95, 0x01 , // Report Count (1)
0x81, 0x03 , // Input (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x05, 0x01 , // Usage Page (Generic Desktop)
0x75, 0x10 , // Report Size (16)
0x55, 0x0E , // Unit Exponent (-2)
0x65, 0x11 , // Unit (SI Lin: Length (cm))
0x09, 0x30 , // Usage (X)
0x26, 0x00,0x40, // Logical Maximum (16384)
0x35, 0x00, // Physical Minimum (0)
0x46, 0xC6,0x11, // Physical Maximum (4550)
0x81, 0x42, // Input (Data,Var,Abs,NWrp,Lin,Pref,Null,Bit)
0x09, 0x31, // Usage (Y)
0x26, 0x00,0x40, // Logical Maximum (16384)
0x46, 0x00,0x0A, // Physical Maximum (2560)
0x81, 0x42 , // Input (Data,Var,Abs,NWrp,Lin,Pref,Null,Bit)
0xC0, // End Collection
0xc0
};
3.报告描述符的report id这两个位置要一致
这里实现的是单点,多点目前还在研究
int key_event(void)
{
#if 1
u8 arr[] = {0x41,0x0a,0x0a,0x0a,0x0a};
#else
u8 arr[] = {
0x40, 0x10, 0x24, 0x10, 0x24,
0x41, 0x0a, 0x0a, 0x0a, 0x0a,
//0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
2
};
#endif
if(key(KEY2) == 2)
{
static u8 count = 0;
count++;
if(count < 5)return 0;
count = 0;
LOG_INFO("key2 press\r\n");
LOG_INFO("ble state = %d\r\n",bls_att_pushNotifyData (HID_MOUSE_REPORT_INPUT_DP_H, arr, sizeof(arr)));
}
if(key(KEY3) == 1)
{
u8 arr1[] = {0x41,0x3a,0x0a,0x3a,0x0a};
LOG_INFO("key3 press\r\n");
u8 arr[] = {0x41,0x0a,0x0a,0x0a,0x2a};
LOG_INFO("ble state = %d\r\n",bls_att_pushNotifyData (HID_MOUSE_REPORT_INPUT_DP_H, arr1, sizeof(arr)));
}
if(key(KEY4) == 1)
{
u8 arr2[] = {0x41,0x2a,0x0a,0x2a,0x1a};
LOG_INFO("key4 press\r\n");
LOG_INFO("ble state = %d\r\n",bls_att_pushNotifyData (HID_MOUSE_REPORT_INPUT_DP_H, arr2, sizeof(arr)));
}
#if 1
if(key(KEY5) == 1)
{
u8 arr3[] = {0x41,0x1a,0x1a,0x1a,0x0a};
LOG_INFO("key5 press\r\n");
LOG_INFO("ble state = %d\r\n",bls_att_pushNotifyData (HID_MOUSE_REPORT_INPUT_DP_H, arr3, sizeof(arr)));
}
#endif
return 0;
}