The HID Mouse Application is an example that implements the HID over GATT profile for mouse using the hardware delivered in the nRF51 Development Kit.
The application includes the three mandatory services needed for the HID over GATT profile:
- Note
- This application is not power optimized!
-
The application will stop advertising and go to system-off mode after 3 minutes and 30 seconds(if no advertising with whitelist was done) or after 4 minutes (if advertising with whitelist was done).
Push the button 1 to restart advertising.
Setup
The name of the example is ble_app_hids_mouse_s110_pca10028. If you are not using the Keil Pack Installer, you can find the source code and project file of the example in the following folder: <InstallFolder>\Nordic\nrf51\examples\ble_peripheral\ble_app_hids_mouse
Button assignments when in system-off:
- Button 1: Wake up and start advertising.
- Button 2: Wake up, erase all bonds, and restart advertising.
Button assignments when connected:
- Button 1: Move mouse pointer 5 pixels to the left
- Button 2: Move mouse pointer 5 pixels to the right
- Button 3: Move mouse pointer 5 pixels upward
- Button 4: Move mouse pointer 5 pixels downward
Testing
The HID Mouse Application should be connected to a Microsoft Windows 8 computer with a Bluetooth radio. When connected, the application will act as a mouse, enabling the user to move the computer's mouse pointer using four push buttons on the board:
- Compile and program the application. Observe that the BSP_INDICATE_ADVERTISING state is indicated.
- On the Windows 8 computer, search for Bluetooth devices, and connect to the device named 'Nordic_Mouse'. Observe that the BSP_INDICATE_CONNECTED state is indicated.
- Push Button 1 on the board. Observe that the mouse pointer on the Windows 8 computer moves to the left.
- Push Button 2. Observe that the mouse pointer on the Windows 8 computer moves to the right.
- Push Button 3. Observe that the mouse pointer on the Windows 8 computer moves up.
- Push Button 4. Observe that the mouse pointer on the Windows 8 computer moves down.
- Disconnect the computer from the device by removing the device from the computer's devices list. Observe that for the first period, the BSP_INDICATE_ADVERTISING_DIRECTED state is indicated, then it switches to BSP_INDICATE_ADVERTISING_WHITELIST, then to BSP_INDICATE_ADVERTISING, then to BSP_INDICATE_ADVERTISING_SLOW, and then all off.
- Reset the device while pressing Button 2 to erase bond info. Repeat step 2, and check if the device can control the mouse pointer on the computer.
- Disconnect the device from Windows 8, thereby removing the bond info from the computer. Start a search for Bluetooth devices and observe that while the device is advertising with Whitelist, Windows 8 is not able to discover the device.
- The device should be discoverable again after it switches to advertising mode.
You can also test the application with the Master Control Panel by performing the following steps:
- Compile and program the application. Observe that the BSP_INDICATE_ADVERTISING state is indicated.
- Connect to the device from Master Control Panel (the device will be advertising as 'Nordic_Mouse'), then bond and perform service discovery. Observe that the BSP_INDICATE_CONNECTED state is indicated.
- Click the 'Enable services' button on Master Control Panel, and observe that Battery Level notifications are being received every two seconds.
- Push Button 1 on the board. Observe that a notification on one of the HID Report characteristics is received, containing the value 'FB0F00'.
- Push Button 2. Observe that a notification on the same HID Report characteristic is received, containing the value '00B0FF'.
- Push Button 3. Observe that a notification on the same HID Report characteristic is received, containing the value '050000'.
- Push Button 4. Observe that a notification on the same HID Report characteristic is received, containing the value '005000'.
- Click on the Disconnect button in Master Control Panel. Observe that no new notifications are received, and the device is advertising with Whitelist.
- As bond info is preserved by Master Control Panel, it should be possible to immediately reconnect to the device by clicking on the Connect button again. Observe that Battery Level notifications are being received every two seconds.