Part Number:LAUNCHXL-CC2650
我想实现一个蓝牙鼠标例程,cc2650launchpad上的BTN1按下鼠标指针向左下移动10像素,BTN2按下鼠标指针向右下移动10像素。我使用的是sdk2_02_01_18的hid_emu_kbd例程进行更改,
原例程可以实现蓝牙键盘控制,虽然有鼠标函数但启用后无法看到效果,买的btool抓包工具在路上了,准备抓包看看。我只更改了hidemukbd.c文件,将按键处理的键盘函数换成鼠标函数,其他文件都没改,但我感觉是hidkbdservice.c中的static CONST uint8 hidReportMap[]报告符问题,好像例程中的报告符只有键盘的,但我不知道鼠标报告符是什么样的。
我的板卡:cc2650launchpad
我的sdk:ble_sdk2_02_01_18
我的运行环境:IAR7.80.4
.code-editor .code-editor-heading{border-top:1px solid #e9e9ea;border-left:1px solid #e9e9ea;border-right:1px solid #e9e9ea;background-color:#fbfbfb;border-radius:3px 3px 0 0;font-size:12.6px;display:flex;justify-content:space-between;align-items:center;overflow:hidden}.code-editor .code-editor-heading .icon{width:32px;height:32px;display:block;overflow:hidden;text-indent:-3000em;background-repeat:no-repeat;background-size:80%;background-position:center}.code-editor .code-editor-heading .fs{background-image:url(‘https://e2echina.ti.com/cfs-filesystemfile/__key/defaultwidgets/547b4cbb4efb4c3d83533f8f35fb4b7b-1a84591e31034fac832d29ed8584666c/fullscreen.svg?_=638842936957578030’)}.code-editor .code-editor-heading .dl{background-image:url(‘https://e2echina.ti.com/cfs-filesystemfile/__key/defaultwidgets/547b4cbb4efb4c3d83533f8f35fb4b7b-1a84591e31034fac832d29ed8584666c/download.svg?_=638842936957567810’)}.code-editor .code-editor-heading .filename{padding:10px;display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.code-editor .code-editor-heading a{color:#383b41}.code-editor .code-editor-heading a:hover{color:#007c8c}
/******************************************************************************@file hidemukbd.c@brief This file contains the HID emulated keyboard sample application for usewith the CC2650 Bluetooth Low EnergyProtocol Stack.Group: WCS, BTS
Target Device: CC2650, CC2640, CC1350******************************************************************************Copyright (c) 2011-2016, Texas Instruments Incorporated
All rights reserved.Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:* Redistributions of source code must retain the above copyrightnotice, this list of conditions and the following disclaimer.* Redistributions in binary form must reproduce the above copyrightnotice, this list of conditions and the following disclaimer in thedocumentation and/or other materials provided with the distribution.* Neither the name of Texas Instruments Incorporated nor the names ofits contributors may be used to endorse or promote products derivedfrom this software without specific prior written permission.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.******************************************************************************
Release Name: ble_sdk_2_02_01_18
Release Date: 2016-10-26 15:20:04
*****************************************************************************/
/*********************************************************************
* INCLUDES
*/
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/knl/Queue.h>
#include "gatt.h"
#include "gapgattserver.h"
#include "gattservapp.h"
#include "gatt_profile_uuid.h"
#include "devinfoservice.h"
#include "battservice.h"
#include "hidkbdservice.h"
#include "hiddev.h"
#include "peripheral.h"
#include "gapbondmgr.h"
#include "osal_snv.h"
#include "icall_apimsg.h"
#include "util.h"
#include <ti/mw/display/Display.h>
#include "iotboard_key.h"
#include "board.h"
#include "hidemukbd.h"
/*********************************************************************
* MACROS
*/
#define KEY_NONE0x00
// Selected HID LED bitmaps
#define LED_NUM_LOCK0x01
#define LED_CAPS_LOCK0x02
// Selected HID mouse button values
#define MOUSE_BUTTON_10x01
#define MOUSE_BUTTON_NONE0x00
// HID keyboard input report length
#define HID_KEYBOARD_IN_RPT_LEN8
// HID LED output report length
#define HID_LED_OUT_RPT_LEN1
// HID mouse input report length
#define HID_MOUSE_IN_RPT_LEN5
/*********************************************************************
* CONSTANTS
*/
// HID idle timeout in msec; set to zero to disable timeout
#define DEFAULT_HID_IDLE_TIMEOUT60000
// Minimum connection interval (units of 1.25ms) if automatic parameter update
// request is enabled.
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL8
// Maximum connection interval (units of 1.25ms) if automatic parameter update
// request is enabled.
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL8
// Slave latency to use if automatic parameter update request is enabled
#define DEFAULT_DESIRED_SLAVE_LATENCY50
// Supervision timeout value (units of 10ms) if automatic parameter update
// request is enabled.
#define DEFAULT_DESIRED_CONN_TIMEOUT500
// Whether to enable automatic parameter update request when a connection is
// formed.
#define DEFAULT_ENABLE_UPDATE_REQUESTGAPROLE_LINK_PARAM_UPDATE_INITIATE_BOTH_PARAMS
// Connection Pause Peripheral time value (in seconds)
#define DEFAULT_CONN_PAUSE_PERIPHERAL10
// Default passcode
#define DEFAULT_PASSCODE0
// Default GAP pairing mode
#define DEFAULT_PAIRING_MODEGAPBOND_PAIRING_MODE_INITIATE
// Default MITM mode (TRUE to require passcode or OOB when pairing)
#define DEFAULT_MITM_MODEFALSE
// Default bonding mode, TRUE to bond
#define DEFAULT_BONDING_MODETRUE
// Default GAP bonding I/O capabilities
#define DEFAULT_IO_CAPABILITIESGAPBOND_IO_CAP_NO_INPUT_NO_OUTPUT
// Battery level is critical when it is less than this %
#define DEFAULT_BATT_CRITICAL_LEVEL6
// Task configuration
#define HIDEMUKBD_TASK_PRIORITY1
#ifndef HIDEMUKBD_TASK_STACK_SIZE
#define HIDEMUKBD_TASK_STACK_SIZE644
#endif
// Task Events
#define HIDEMUKBD_KEY_CHANGE_EVT0x0001
/*********************************************************************
* TYPEDEFS
*/
// App event passed from profiles.
typedef struct
{appEvtHdr_t hdr; // Event header
} hidEmuKbdEvt_t;
/*********************************************************************
* GLOBAL VARIABLES
*/
// Display Interface
Display_Handle dispHandle = NULL;
/*********************************************************************
* EXTERNAL VARIABLES
*/
/*********************************************************************
* EXTERNAL FUNCTIONS
*/
/*********************************************************************
* LOCAL VARIABLES
*/
// Entity ID globally used to check for source and/or destination of messages
static ICall_EntityID selfEntity;
// Semaphore globally used to post events to the application thread
static ICall_Semaphore sem;
// Queue object used for app messages
static Queue_Struct appMsg;
static Queue_Handle appMsgQueue;
// Task configuration
Task_Struct hidEmuKbdTask;
Char hidEmuKbdTaskStack[HIDEMUKBD_TASK_STACK_SIZE];
// GAP Profile - Name attribute for SCAN RSP data
static uint8_t scanData[] =
{0x0D,// length of this dataGAP_ADTYPE_LOCAL_NAME_COMPLETE,// AD Type = Complete local name'H','I','D',' ','K','e','y','b','o','a','r','d'
};
// Advertising data
static uint8_t advData[] =
{// flags0x02,// length of this dataGAP_ADTYPE_FLAGS,GAP_ADTYPE_FLAGS_LIMITED | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,// appearance0x03,// length of this dataGAP_ADTYPE_APPEARANCE,LO_UINT16(GAP_APPEARE_HID_KEYBOARD),HI_UINT16(GAP_APPEARE_HID_KEYBOARD),// service UUIDs0x05,// length of this dataGAP_ADTYPE_16BIT_MORE,LO_UINT16(HID_SERV_UUID),HI_UINT16(HID_SERV_UUID),LO_UINT16(BATT_SERV_UUID),HI_UINT16(BATT_SERV_UUID)
};
// Device name attribute value
static CONST uint8_t attDeviceName[GAP_DEVICE_NAME_LEN] = "HID Keyboard";
// HID Dev configuration
static hidDevCfg_t hidEmuKbdCfg =
{DEFAULT_HID_IDLE_TIMEOUT,// Idle timeoutHID_KBD_FLAGS// HID feature flags
};
// TRUE if boot mouse enabled
static uint8_t hidBootMouseEnabled = FALSE;
/*********************************************************************
* LOCAL FUNCTIONS
*/
// Application task and event processing.
static void HidEmuKbd_init(void);
static void HidEmuKbd_taskFxn(UArg a0, UArg a1);
static void HidEmuKbd_processAppMsg(hidEmuKbdEvt_t *pMsg);
static void HidEmuKbd_processStackMsg(ICall_Hdr *pMsg);
static void HidEmuKbd_processGattMsg(gattMsgEvent_t *pMsg);
static uint8_t HidEmuKbd_enqueueMsg(uint16_t event, uint8_t state);
// Key press.
static void HidEmuKbd_keyPressHandler(uint8_t keys);
static void HidEmuKbd_handleKeys(uint8_t shift, uint8_t keys);
// HID reports.
static void HidEmuKbd_sendReport(uint8_t keycode);
static void HidEmuKbd_sendMouseReport(uint8_t buttons);
static uint8_t HidEmuKbd_receiveReport(uint8_t len, uint8_t *pData);
static uint8_t HidEmuKbd_reportCB(uint8_t id, uint8_t type, uint16_t uuid,uint8_t oper, uint16_t *pLen, uint8_t *pData);
static void HidEmuKbd_hidEventCB(uint8_t evt);
/*********************************************************************
* PROFILE CALLBACKS
*/
static hidDevCB_t hidEmuKbdHidCBs =
{HidEmuKbd_reportCB,HidEmuKbd_hidEventCB,NULL
};
/*********************************************************************
* PUBLIC FUNCTIONS
*/
/*********************************************************************
* @fnHidEmuKbd_createTask
*
* @briefTask creation function for the HID emulated keyboard.
*
* @paramnone
*
* @return none
*/
void HidEmuKbd_createTask(void)
{Task_Params taskParams;// Configure taskTask_Params_init(&taskParams);taskParams.stack = hidEmuKbdTaskStack;taskParams.stackSize = HIDEMUKBD_TASK_STACK_SIZE;taskParams.priority = HIDEMUKBD_TASK_PRIORITY;Task_construct(&hidEmuKbdTask, HidEmuKbd_taskFxn, &taskParams, NULL);
}
/*********************************************************************
* @fnHidEmuKbd_init
*
* @briefInitialization function for the HidEmuKbd App Task.
*This is called during initialization and should contain
*any application specific initialization (ie. hardware
*initialization/setup, table initialization, power up
*notification ...).
*
* @paramnone
*
* @return none
*/
void HidEmuKbd_init(void)
{
// ******************************************************************// N0 STACK API CALLS CAN OCCUR BEFORE THIS CALL TO ICall_registerApp// ******************************************************************// Register the current thread as an ICall dispatcher application// so that the application can send and receive messages.ICall_registerApp(&selfEntity, &sem);// Hard code the DB Address till CC2650 board gets its own IEEE address//uint8 bdAddress[B_ADDR_LEN] = { 0x22, 0x22, 0x22, 0x22, 0x22, 0x5A };//HCI_EXT_SetBDADDRCmd(bdAddress);// Set device's Sleep Clock Accuracy//HCI_EXT_SetSCACmd(40);// Create an RTOS queue for message from profile to be sent to app.appMsgQueue = Util_constructQueue(&appMsg);dispHandle = Display_open(Display_Type_LCD, NULL);// Setup the GAPVOID GAP_SetParamValue(TGAP_CONN_PAUSE_PERIPHERAL,DEFAULT_CONN_PAUSE_PERIPHERAL);// Setup the GAP Peripheral Role Profile{uint8_t initial_advertising_enable = TRUE;// By setting this to zero, the device will go into the waiting state after// being discoverable for 30.72 second, and will not being advertising again// until the enabler is set back to TRUEuint16_t gapRole_AdvertOffTime = 0;uint8_t enable_update_request = DEFAULT_ENABLE_UPDATE_REQUEST;uint16_t desired_min_interval = DEFAULT_DESIRED_MIN_CONN_INTERVAL;uint16_t desired_max_interval = DEFAULT_DESIRED_MAX_CONN_INTERVAL;uint16_t desired_slave_latency = DEFAULT_DESIRED_SLAVE_LATENCY;uint16_t desired_conn_timeout = DEFAULT_DESIRED_CONN_TIMEOUT;// Set the GAP Role ParametersGAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),&initial_advertising_enable);GAPRole_SetParameter(GAPROLE_ADVERT_OFF_TIME, sizeof(uint16_t),&gapRole_AdvertOffTime);GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advData), advData);GAPRole_SetParameter(GAPROLE_SCAN_RSP_DATA, sizeof(scanData), scanData);GAPRole_SetParameter(GAPROLE_PARAM_UPDATE_ENABLE, sizeof(uint8_t),&enable_update_request);GAPRole_SetParameter(GAPROLE_MIN_CONN_INTERVAL, sizeof(uint16_t),&desired_min_interval);GAPRole_SetParameter(GAPROLE_MAX_CONN_INTERVAL, sizeof(uint16_t),&desired_max_interval);GAPRole_SetParameter(GAPROLE_SLAVE_LATENCY, sizeof(uint16_t),&desired_slave_latency);GAPRole_SetParameter(GAPROLE_TIMEOUT_MULTIPLIER, sizeof(uint16_t),&desired_conn_timeout);}// Set the GAP CharacteristicsGGS_SetParameter(GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN,(void *)attDeviceName);// Setup the GAP Bond Manager{uint32_t passkey = DEFAULT_PASSCODE;uint8_t pairMode = DEFAULT_PAIRING_MODE;uint8_t mitm = DEFAULT_MITM_MODE;uint8_t ioCap = DEFAULT_IO_CAPABILITIES;uint8_t bonding = DEFAULT_BONDING_MODE;GAPBondMgr_SetParameter(GAPBOND_DEFAULT_PASSCODE, sizeof(uint32_t),&passkey);GAPBondMgr_SetParameter(GAPBOND_PAIRING_MODE, sizeof(uint8_t), &pairMode);GAPBondMgr_SetParameter(GAPBOND_MITM_PROTECTION, sizeof(uint8_t), &mitm);GAPBondMgr_SetParameter(GAPBOND_IO_CAPABILITIES, sizeof(uint8_t), &ioCap);GAPBondMgr_SetParameter(GAPBOND_BONDING_ENABLED, sizeof(uint8_t), &bonding);}// Setup Battery Characteristic Values{uint8_t critical = DEFAULT_BATT_CRITICAL_LEVEL;Batt_SetParameter(BATT_PARAM_CRITICAL_LEVEL, sizeof (uint8_t), &critical);}// Set up HID keyboard serviceHidKbd_AddService();// Register for HID Dev callbackHidDev_Register(&hidEmuKbdCfg, &hidEmuKbdHidCBs);// Start the GAP Role and Register the Bond Manager.HidDev_StartDevice();// Initialize keys on SmartRF06EB.Board_initKeys(HidEmuKbd_keyPressHandler);Display_print0(dispHandle, 0, 0, "HID EMU KBD");
}
/*********************************************************************
* @fnHidEmuKbd_taskFxn
*
* @briefHidEmuKbd Application Task event processor. This function
*is called to process all events for the task. Events
*include timers, messages and any other user defined events.
*
* @parama0, a1 - not used.
*
* @return none
*/
void HidEmuKbd_taskFxn(UArg a0, UArg a1)
{// Initialize the application.HidEmuKbd_init();// Application main loop.for (;;){// Waits for a signal to the semaphore associated with the calling thread.// Note that the semaphore associated with a thread is signaled when a// message is queued to the message receive queue of the thread or when// ICall_signal() function is called onto the semaphore.ICall_Errno errno = ICall_wait(ICALL_TIMEOUT_FOREVER);if (errno == ICALL_ERRNO_SUCCESS){ICall_EntityID dest;ICall_ServiceEnum src;ICall_HciExtEvt *pMsg = NULL;if (ICall_fetchServiceMsg(&src, &dest,(void **)&pMsg) == ICALL_ERRNO_SUCCESS){if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity)){// Process inter-task messageHidEmuKbd_processStackMsg((ICall_Hdr *)pMsg);}if (pMsg){ICall_freeMsg(pMsg);}}// If RTOS queue is not empty, process app message.while (!Queue_empty(appMsgQueue)){hidEmuKbdEvt_t *pMsg = (hidEmuKbdEvt_t *)Util_dequeueMsg(appMsgQueue);if (pMsg){// Process message.HidEmuKbd_processAppMsg(pMsg);// Free the space from the message.ICall_free(pMsg);}}}}
}
/*********************************************************************
* @fnHidEmuKbd_processStackMsg
*
* @briefProcess an incoming stack message.
*
* @parampMsg - message to process
*
* @return none
*/
static void HidEmuKbd_processStackMsg(ICall_Hdr *pMsg)
{switch (pMsg->event){//SmallMouse Addcase GAP_MSG_EVENT://HidEmuKbd_ProcessGAPMsg();Display_print0(dispHandle, 3, 0, "GAP");break;case GATT_MSG_EVENT:HidEmuKbd_processGattMsg((gattMsgEvent_t *) pMsg);break;default:// Do nothingbreak;}
}
/*********************************************************************
* @fnHidEmuKbd_processGattMsg
*
* @briefProcess GATT messages
*
* @return none
*/
static void HidEmuKbd_processGattMsg(gattMsgEvent_t *pMsg)
{GATT_bm_free(&pMsg->msg, pMsg->method);
}
/*********************************************************************
* @fnHidEmuKbd_processAppMsg
*
* @briefProcess an incoming task message.
*
* @parampMsg - message to process
*
* @return none
*/
static void HidEmuKbd_processAppMsg(hidEmuKbdEvt_t *pMsg)
{switch (pMsg->hdr.event){case HIDEMUKBD_KEY_CHANGE_EVT:HidEmuKbd_handleKeys(0, pMsg->hdr.state);break;default://Do nothing.break;}
}
/*********************************************************************
* @fnHidKEmukbd_keyPressHandler
*
* @briefKey event handler function.
*
* @parama0 - ignored
*
* @return none
*/
static void HidEmuKbd_keyPressHandler(uint8_t keys)
{// Enqueue the event.HidEmuKbd_enqueueMsg(HIDEMUKBD_KEY_CHANGE_EVT, keys);
}
/*********************************************************************
* @fnHidEmuKbd_handleKeys
*
* @briefHandles all key events for this device.
*
* @paramshift - true if in shift/alt.
* @paramkeys - bit field for key events. Valid entries:
*KEY_UP
*KEY_RIGHT
*
* @return none
*/
static void HidEmuKbd_handleKeys(uint8_t shift, uint8_t keys)
{(void)shift; // Intentionally unreferenced parameterif(keys & KEY_BTN1){HidEmuKbd_sendReport(HID_KEYBOARD_A);// Key Release.// NB: releasing a key press will not propagate a signal to this function,// so a "key release" is reported immediately afterwards here.HidEmuKbd_sendReport(KEY_NONE);Display_print0(dispHandle, 6, 0, "KEY_BTN1");Display_print0(dispHandle, 7, 0, "Send 'a'");//return;}if(keys & KEY_BTN2){if (hidBootMouseEnabled){// Key Press.HidEmuKbd_sendMouseReport(MOUSE_BUTTON_1);// Key Release.// NB: releasing a key press will not propagate a signal to this function,// so a "key release" is reported immediately afterwards here.HidEmuKbd_sendMouseReport(MOUSE_BUTTON_NONE);Display_print0(dispHandle, 6, 0, "KEY_BTN2");Display_print0(dispHandle, 7, 0, "mouse");}//return;}/*if (keys & KEY_UP){// Key Press.HidEmuKbd_sendReport(HID_KEYBOARD_UP_ARROW);// Key Release.// NB: releasing a key press will not propagate a signal to this function,// so a "key release" is reported immediately afterwards here.HidEmuKbd_sendReport(KEY_NONE);}if (keys & KEY_DOWN){// Key Press.HidEmuKbd_sendReport(HID_KEYBOARD_DOWN_ARROW);// Key Release.// NB: releasing a key press will not propagate a signal to this function,// so a "key release" is reported immediately afterwards here.HidEmuKbd_sendReport(KEY_NONE);}if (keys & KEY_LEFT){// Key Press.HidEmuKbd_sendReport(HID_KEYBOARD_LEFT_ARROW);// Key Release.// NB: releasing a key press will not propagate a signal to this function,// so a "key release" is reported immediately afterwards here.HidEmuKbd_sendReport(KEY_NONE);}if (keys & KEY_RIGHT){// Key Press.HidEmuKbd_sendReport(HID_KEYBOARD_RIGHT_ARROW);// Key Release// NB: releasing a key press will not propagate a signal to this function,// so a "key release" is reported immediately afterwards here.HidEmuKbd_sendReport(KEY_NONE);}if (keys & KEY_SELECT){if (hidBootMouseEnabled){// Key Press.HidEmuKbd_sendMouseReport(MOUSE_BUTTON_1);// Key Release.// NB: releasing a key press will not propagate a signal to this function,// so a "key release" is reported immediately afterwards here.HidEmuKbd_sendMouseReport(MOUSE_BUTTON_NONE);}}*/
}
/*********************************************************************
* @fnHidEmuKbd_sendReport
*
* @briefBuild and send a HID keyboard report.
*
* @paramkeycode - HID keycode.
*
* @return none
*/
static void HidEmuKbd_sendReport(uint8_t keycode)
{uint8_t buf[HID_KEYBOARD_IN_RPT_LEN];buf[0] = 0;// Modifier keysbuf[1] = 0;// Reservedbuf[2] = keycode;// Keycode 1buf[3] = 0;// Keycode 2buf[4] = 0;// Keycode 3buf[5] = 0;// Keycode 4buf[6] = 0;// Keycode 5buf[7] = 0;// Keycode 6HidDev_Report(HID_RPT_ID_KEY_IN, HID_REPORT_TYPE_INPUT,HID_KEYBOARD_IN_RPT_LEN, buf);
}
/*********************************************************************
* @fnHidEmuKbd_sendMouseReport
*
* @briefBuild and send a HID mouse report.
*
* @parambuttons - Mouse button code
*
* @return none
*/
static void HidEmuKbd_sendMouseReport(uint8_t buttons)
{uint8_t buf[HID_MOUSE_IN_RPT_LEN];buf[0] = buttons;// Buttonsbuf[1] = 0;// Xbuf[2] = 0;// Ybuf[3] = 0;// Wheelbuf[4] = 0;// AC PanHidDev_Report(HID_RPT_ID_MOUSE_IN, HID_REPORT_TYPE_INPUT,HID_MOUSE_IN_RPT_LEN, buf);
}
/*********************************************************************
* @fnHidEmuKbd_receiveReport
*
* @briefProcess an incoming HID keyboard report.
*
* @paramlen - Length of report.
* @parampData - Report data.
*
* @return status
*/
static uint8_t HidEmuKbd_receiveReport(uint8_t len, uint8_t *pData)
{// Verify data lengthif (len == HID_LED_OUT_RPT_LEN){return SUCCESS;}else{return ATT_ERR_INVALID_VALUE_SIZE;}
}
/*********************************************************************
* @fnHidEmuKbd_reportCB
*
* @briefHID Dev report callback.
*
* @paramid - HID report ID.
* @paramtype - HID report type.
* @paramuuid - attribute uuid.
* @paramoper - operation: read, write, etc.
* @paramlen - Length of report.
* @parampData - Report data.
*
* @return GATT status code.
*/
static uint8_t HidEmuKbd_reportCB(uint8_t id, uint8_t type, uint16_t uuid,uint8_t oper, uint16_t *pLen, uint8_t *pData)
{uint8_t status = SUCCESS;// Writeif (oper == HID_DEV_OPER_WRITE){if (uuid == REPORT_UUID){// Process write to LED output report; ignore othersif (type == HID_REPORT_TYPE_OUTPUT){status = HidEmuKbd_receiveReport(*pLen, pData);}}if (status == SUCCESS){status = HidKbd_SetParameter(id, type, uuid, *pLen, pData);}}// Readelse if (oper == HID_DEV_OPER_READ){uint8_t len;status = HidKbd_GetParameter(id, type, uuid, &len, pData);if (status == SUCCESS){*pLen = len;}}// Notifications enabledelse if (oper == HID_DEV_OPER_ENABLE){if (id == HID_RPT_ID_MOUSE_IN && type == HID_REPORT_TYPE_INPUT){hidBootMouseEnabled = TRUE;}}// Notifications disabledelse if (oper == HID_DEV_OPER_DISABLE){if (id == HID_RPT_ID_MOUSE_IN && type == HID_REPORT_TYPE_INPUT){hidBootMouseEnabled = FALSE;}}return status;
}
/*********************************************************************
* @fnHidEmuKbd_hidEventCB
*
* @briefHID Dev event callback.
*
* @paramevt - event ID.
*
* @return HID response code.
*/
static void HidEmuKbd_hidEventCB(uint8_t evt)
{// Process enter/exit suspend or enter/exit boot modereturn;
}
/*********************************************************************
* @fnHidEmuKbd_enqueueMsg
*
* @briefCreates a message and puts the message in RTOS queue.
*
* @paramevent - message event.
* @paramstate - message state.
*
* @return TRUE or FALSE
*/
static uint8_t HidEmuKbd_enqueueMsg(uint16_t event, uint8_t state)
{hidEmuKbdEvt_t *pMsg;// Create dynamic pointer to message.if (pMsg = ICall_malloc(sizeof(hidEmuKbdEvt_t))){pMsg->hdr.event = event;pMsg->hdr.state = state;// Enqueue the message.return Util_enqueueMsg(appMsgQueue, sem, (uint8_t *)pMsg);}return FALSE;
}
/*********************************************************************
*********************************************************************/
jQuery(function(j){var fullScreenToggle = j(‘#fragment-1a84591e31034fac832d29ed8584666c212387219_code-editor-fs’);var codeEditor = j(‘#fragment-1a84591e31034fac832d29ed8584666c212387219_code-editor’);fullScreenToggle.on(‘click’, function(){if (codeEditor.evolutionCodeEditor(‘fullscreen’)) {codeEditor.evolutionCodeEditor(‘fullscreen’, false);} else {codeEditor.evolutionCodeEditor(‘fullscreen’, true);}return false;});
});
Taylor:
您好,
已经收到了您的案例,调查需要些时间,感谢您的耐心等待。
,
Eirwen:
关于HID配置,请参考下面链接:
e2e.ti.com/…/4696810
TI中文支持网

