TI CC2540 Bluetooth low energy Sample Applications Guide v1.4.1 SWRU297 Version 1.4.1
Page 23 of 36
Copyright © 2011-2015 Texas Instruments, Inc
The project contains one configuration, CC2540DK-MINI Keyfob Slave, using the keyfob
hardware platform.
10.1.1 User Interface
When not connected and not already advertising, pressing either button will initiate advertising.
When in a connection, the keyfob's left button sends a “left arrow” key and the right button sends
a “right arrow” key.
Note that a secure connection must be established before key presses will be sent to the peer
device.
10.1.2 Basic Operation
Power up the device and press either button to enable advertising. From a HID Host peer device,
initiate a device discovery and connection procedure to discover and connect to the HID device.
The peer device should discover the HID service and recognize the device as a keyboard. The
peer device may also discover and configure the battery service for battery level-state
notifications.
By default the HID device requires security and uses “just works” pairing. After a secure
connection is established and the HID host configures the HID service to enable notifications, the
HID device can send HID key presses to the HID host. A notification is sent when a button is
pressed and when a button is released.
The HID host can send keyboard LED information to the device to illuminate the keyfob LEDs.
The “caps lock” setting controls the green LED and the “num lock” setting controls the red LED.
If there is no HID activity for a period of time (20 seconds by default) the HID device will
disconnect. When the connection is closed the HID device will not advertise. Press either button
to enable advertising and connect again.
10.2 Software Description
The project uses the following services and profiles:
Battery service (battservice.c and battservice.h).
Device Information service (devinfoservice.c and devinfoservice.h).
Scan Parameters service (scanparamservice.c and scanparamservice.h).
HID service for keyboard (hidkbdservice.c hidkbdservice.h).
HID device profile (hiddev.c and hiddev.h). This is a common profile for HID devices that
performs the following procedures:
o Advertising, connection procedures, and security procedures.
o Sending HID notifications.
o Handling read and write of HID service characteristics.
10.3 HidEmuKbd Application
The application is implemented in the file hidemukbd.c.
10.3.1 Initialization
The HidEmuKbd_Init function is called by the OSAL to perform task initialization procedures.
This function sets parameters for the peripheral profile, GAP bond manager, and Battery service.
The function also registers the HID keyboard service and HID device profile.
10.3.2 Event Processing
The application has two main event processing functions, HidEmuKbd_ProcessEvent and
HidEmuKbd_ProcessOSALMsg.
Function HidEmuKbd_ProcessEvent handles the SYS_EVENT_MSG event, which services the
OSAL queue and processes OSAL messages.