cancel
Showing results for 
Search instead for 
Did you mean: 

BLUENRG-LP BLE HID KEYBOARD with WINDOWS 10 PC

WYuan.1
Associate II

DK version:BlueNRG-LP DK 1.1.0

chip:BlueNRG-345AC​

2 problems of the ble hid keyboard project.

1st, if BlueNRG-LP is not conneted to any device,it keeps going into RESET ,go on and go on.when it connected to one device,this situation stoped.

2nd,BlueNRG-LP can connected to the android device ,and it works well as a keyboard.But when it connected to the Windows (10) PC,connection is OK,but the PC cannot receive the KEY VALUE of the keyborad. And more,I think the PC did not take the BlueNRG-LP as a keyboard device.

Could somebody tell me why,and how do I modify the program?

Thank you very much!

4 REPLIES 4
Rmats.1
Associate II

Hi everyone,

> 2nd,BlueNRG-LP can connected to the android device ,and it works well as a keyboard.But when it connected to the Windows (10) PC,connection is OK,but the PC cannot receive the KEY VALUE of the keyborad. And more,I think the PC did not take the BlueNRG-LP as a keyboard device.

I have the same problem in my environment. It works fine on Android and IPhone.

BlueNRG-2 can be paired with a Windows 10 PC, but it is not recognized as a keyboard device and key values are ignored.

Does anyone have a solution?

SDK: STSW-BLUETILE-DK 1.3.0

Chip: BlueNRG-2

Project: BLE_HID_Peripheral

WGood.2
Associate

I have the same issue; device manager shows an error next to the enumerated Bluetooth Low Energy GATT compliant HID device:

This device cannot start. (Code 10)

An unknown item was found in the report descriptor.

From going through and checking the reportDesc values in HID Descriptor Tool, I am suspicious of the 'Usage (Vendor Defined)' entry, but I'm not sure. Can we get any help from ST?

Update: I got this working!

It looks like later versions of Windows are very picky about inclusion of report IDs, so the keyboard/mouse files must be modified to include them, here's what I did:

// Keyboard report descriptor
uint8_t reportDesc[] = {
	0x05, 0x01,                 // Usage Page (Generic Desktop)
	0x09, 0x06,                 // Usage (Keyboard)
	0xA1, 0x01,                 // Collection (Application)
 
	0x85, REPORT_ID,			//	   Report ID					//WG added
	0x05, 0x07,                 //     Usage Page (Key Codes)
	0x19, 0xe0,                 //     Usage Minimum (224)
	0x29, 0xe7,                 //     Usage Maximum (231)
	0x15, 0x00,                 //     Logical Minimum (0)
	0x25, 0x01,                 //     Logical Maximum (1)
	0x75, 0x01,                 //     Report Size (1)
	0x95, 0x08,                 //     Report Count (8)
	0x81, 0x02,                 //     Input (Data, Variable, Absolute)	modifier byte
 
	0x95, 0x01,                 //     Report Count (1)
	0x75, 0x08,                 //     Report Size (8)
	0x81, 0x01,                 //     Input (Constant) reserved byte(1)
 
	0x95, 0x06,                 //     Report Count (6)					//WG moved to be included in first report
	0x75, 0x08,                 //     Report Size (8)
	0x15, 0x00,                 //     Logical Minimum (0)
	0x25, 0x65,                 //     Logical Maximum (101)
	0x05, 0x07,                 //     Usage Page (Key codes)
	0x19, 0x00,                 //     Usage Minimum (0)
	0x29, 0x65,                 //     Usage Maximum (101)
	0x81, 0x00,                 //     Input (Data, Array) Key array(6 bytes)
 
	0x85, REPORT_ID + 1,			//	   Report ID					//WG added
	0x95, 0x05,                 //     Report Count (5)
	0x75, 0x01,                 //     Report Size (1)
	0x05, 0x08,                 //     Usage Page (Page# for LEDs)
	0x19, 0x01,                 //     Usage Minimum (1)
	0x29, 0x05,                 //     Usage Maximum (5)
	0x91, 0x02,                 //     Output (Data, Variable, Absolute), Led report
 
	0x95, 0x01,                 //     Report Count (1)
	0x75, 0x03,                 //     Report Size (3)
	0x91, 0x01,               	//     Output (Constant) Led report padding
 
	0x09, 0x05,                 //     Usage (Vendor Defined)
	0x15, 0x00,                 //     Logical Minimum (0)
	0x26, 0xFF, 0x00,           //     Logical Maximum (255)
	0x95, 0x02,                 //     Report Count (2)
	0x75, 0x08,                 //     Report Size (8 bit)
	0xB1, 0x02,                 //     Feature (Data, Variable, Absolute)
 
	0xC0                        // End Collection (Application)
};

Also replaced the hard-coded 0 in the report update with the REPORT_ID variable:

void processInputData(uint8_t* data_buffer, uint8_t Nb_bytes)
{
  uint8_t ret, i, upperCase, nmbTimes, keys[8]={0,0,0,0,0,0,0,0};
  
  if (hidDeviceStatus() & HID_DEVICE_READY_TO_NOTIFY)
  {
    BSP_LED_On(BSP_LED3);
    
    for (i = 0; i < Nb_bytes; i++)
    {
    	PRINTF("%c", data_buffer[i]);		//print typed key
 
    	keys[2] = hid_keyboard_map(data_buffer[i], &upperCase);
 
    	if (upperCase)
    		keys[0] = 0x02;
    	else
    		keys[0] = 0x00;
 
    	ret = hidSendReport(REPORT_ID, INPUT_REPORT, sizeof(keys), keys);				//send keypress
    	if (ret != BLE_STATUS_SUCCESS)
    		PRINTF("Error while sending the report 0x%02x\n", ret);
 
    	keys[0] = 0;
    	keys[2] = 0;
    	nmbTimes = 0;
 
    	do
    	{
    		ret = hidSendReport(REPORT_ID, INPUT_REPORT, sizeof(keys), keys);			//send keyrelease
    		nmbTimes++;
    	} while ((ret != BLE_STATUS_SUCCESS) && (nmbTimes < 200));
    }
 
    hidSetNotificationPending(TRUE);
  }
  else
  {
	  BSP_LED_Off(BSP_LED3);
  }
}

updated the hid_params initialisation:

void setDefaultHidParams(void)
{
  hid_param.bootSupport = FALSE;
  hid_param.reportSupport = TRUE;
  hid_param.num_reports = NUM_REPORTS;						
  hid_param.reportReferenceDesc = reportReferenceDesc;
  hid_param.reportReferenceDesc[0].ID = REPORT_ID;
  hid_param.reportReferenceDesc[0].type = INPUT_REPORT;
  hid_param.reportReferenceDesc[1].ID = REPORT_ID + 1;
  hid_param.reportReferenceDesc[1].type = OUTPUT_REPORT;
  hid_param.isBootDevKeyboard = FALSE;
  hid_param.isBootDevMouse = FALSE;
  hid_param.externalReportEnabled = 0;
  hid_param.includedServiceEnabled = FALSE;
  hid_param.informationCharac[0] = 0x01;
  hid_param.informationCharac[1] = 0x01;
  hid_param.informationCharac[2] = 0;
  hid_param.informationCharac[3] = 0x01;
}

and the get report callback:

void hidGetReport_CB(uint8_t ID, uint8_t type)
{
  uint8_t ret, len = 0;
  uint8_t data[8]={0,0,0,0,0,0,0,0};
 
  if ((ID == REPORT_ID) && (type == INPUT_REPORT))
    len = 8;
  if ((ID == REPORT_ID + 1) && (type == OUTPUT_REPORT))
    len = 2;
 
  PRINTF("Get Report Callback: ID = %d, type = %d, resp_len = %d\n", ID, type, len);
 
  //shouldn't we be reacting to these report requests?
  
  ret = hidUpdateReportValue(ID, type, len, data);
  if (ret != BLE_STATUS_SUCCESS)
    PRINTF("Update report value Error during a hidGetReport_CB() procedure: 0x%02x\n", ret);
  else
    PRINTF("hidGetReport_CB() procedure OK\n");
}

This should be enough to get anybody else going on Windows 10 (until ST updates the example project :beaming_face_with_smiling_eyes:)

I tested your way,it cannot work. can you send a proj to my email?