




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Application Flow:· Write device class· Turn Security on· Allow SDP browsing· Initialize HID library l Message = CL_INIT_CFM(Initialize the connection library) Message = HID_INIT_CFM(Initialize the HID library)· Set app state to appDiscoverable.· Store the library handle
2、.status = successPanic and exit application.Cstatus = successPanic and exit application.YNYNYMessageLoop:· Initialize the app_handler· Initialize the PIO lines (1,2,3,4 as o/p and 6,7,8,9 as i/p)· Initialize the connection manager YABNYNSet appstate =appDiscoverableSet appstate =appDi
3、scovera-bleConnected· Set the trust level· Set appstate = appCableConnectedAuthenticateSuccess?· Store the connection instance.· Save the HID interrupt sinkYConnection success? Message = HID_CONNECT_CFM(Confirm connection)· Stop the pin-code entry· Set the auth status t
4、o trusted.Y· Stop the pin-code entry.· Set auth status to idleNAuthenticate = success ? Message =CL_SM_PIN_CODE_IND(Send pin-code response) ABAYBsYY Message = CL_SM_AUTHENTICATE_CFM(Authentication check)· Store host device address· Send the fixed pin-code response of 0000BxCGener
5、ate a new STROBE_MESSAGE after delay of 5 ms· Detect if any modifier (ALT, CTRL or SHIFT) has been pressed.· Prepare the HID input report.· Connect the interrupt stream· Send the HID report over the interrupt line· Disconnect the interrupt stream· Prepare a blank HID in
6、put report to notify the host end of data· Connect the interrupt stream· Send the blank HID input report· Disconnect the interrupt stream· Clear tmpYYStore the key_state. tmp = key_stateNNCheck if key is released(tmp > key_state) ?If a new key_state is generated i.e. a new key
7、 is pressed or a key is released· Strobe PIO line 3 and read contents of PIO line 9,8,7,6 in 0-3 bits of key_state.· Strobe PIO line 2 and read contents of PIO line 9,8,7,6 in 4-7 bits of key_state.· Strobe PIO line 1 and read contents of PIO line 9,8,7,6 in 8-11 bits of key_state.
8、83; Strobe PIO line 4 and read contents of PIO line 9,8,7,6 in 12-15 bits of key_state.YA Message = STROBE_MESSAGE(Generated every 5 ms to detect key state)Description: The above diagram shows the application flow. The application goes through four major stages:1. Library Initialization: The code fo
9、r this functionality is in the file main.c and hid_keyboard_sm.cOn powering the Bluetooth chip following two libraries are initialized:a. Connection library: The initialization is done in the main function of the application. Before initialization the PIO lines direction and debounce are set. Functi
10、on:· void ConnectionInitEx ( Task theAppTask, const msg_filter * msgFilter ) After initialization of the connection manager the message CL_INIT_CFM is sent to the application handler. On receiving the above message following actions are performed:i. Check if the connectio
11、n library initialization was successful, if yes proceed to following steps else panic and exit the application.ii. Write the class of the device as a (HID_MAJOR_DEVICE_CLASS | HID_MINOR_KEYBOARD).Function:· void ConnectionWriteClassOfDevice ( uint32 cod ) iii. Turn the se
12、curity on.Functions:· void ConnectionSmSetSecurityMode ( Task theAppTask, dm_security_mode sec_mode, encryption_mode enc_mode ) · void ConnectionSmRegisterIncomingService ( dm_protocol_id protocol_id, uint32 channel, dm_security_level se
13、curity_level ) iv. Allow SDP record browsing.Function:· void ConnectionSmSetSdpSecurityIn ( bool enable ) v. Initialize the HID library.Function:· void HidInit ( Task theAppTask, const hid_config * config ) b. HID library: After initializa
14、tion of the HID library the message HID_INIT_CFM is sent to the application handler. On receiving above message the following actions are performed:i. Check if the HID library initialization was successful if yes proceed to following steps else panic and exit the application.ii. Record the hid libra
15、ry handle.iii. Initialize the application variables.iv. Set the application state to discoverable i.e. app_state = appDiscoverableNow the chip is in discoverable mode and waits for incoming connection. 2. HID Connection: The code for this functionality is in the file main.c and hid_keyboard_auth.c.
16、Any host can now discover the chip and try to pair with it. The default passkey used for connection is 0000. This is stored in the application therefore any host device needs to use the above mentioned passkey for pairing. a. On an attempt by the host device for connection the message CL_SM_PIN_CODE
17、_IND is sent to the application handler. In response the following actions are performed:i. The host address is stored.ii. Response is sent to the host with passkey as 0000.Function:· void ConnectionSmPinCodeResponse ( const bdaddr * bd_addr, uint16 size_pin_code, const uint8
18、* pin_code ) b. After the host verifies the connection a response is sent to the chip by the host. The message CL_SM_AUTHENTICATE_CFM is received by the application handler. The following actions are performed:i. If authentication by the host device was successful then goto step ii. else
19、 step iii. ii. Set the application state to cable connected i.e. app_state = appCabledConnected and authentication state to trusted i.e.auth_state = appAuthTrustediii. Set the application state to discoverable i.e. app_state = appDiscoverable and authentication state to idle i.e. auth_state = appAut
20、hIdleThe device once in appCableConnected is ready to send input data to the host. 3. Detection of Key-press: The code for this functionality is in the file main.c.The input matrix is connected to the PIO lines. The Bluecore chip has 12 PIO lines and the input matrix has 16 lines. Since the number o
21、f PIO lines are less multiplexing is done. The PIO lines 0, 1, 2 and 4 are output lines and 6, 7, 8 and 9 are input lines. Once the application moves into the cableConnected state an initial strobe message is generated in the application handler. Later on the strobe messages are generated every 5 ms
22、.On receiving the strobe message the following actions are performed: i. Sampling: The output lines are strobed in sequence of 2, 1, 0 and 4. On each strobe of output line the input lines 6, 7, 8 and 9 are sampled. The 4 bits are assembled and stored in the key state. The key state is of 2 bytes and
23、 the contents of it are as follows:· 0-3 bits: Sampled when output line 2 is strobed. o Bit 0 PIO line 9o Bit 1 PIO line 8o Bit 2 PIO line 7o Bit 3 PIO line 6· 4-7 bits: Sampled when output line 1 is strobed. o Bit 4 PIO line 9o Bit 5 PIO line 8o Bit 6 PIO line 7o Bit 7 PIO line 6· 8-
24、11 bits: Sampled when output line 0 is strobed. o Bit 8 PIO line 9o Bit 9 PIO line 8o Bit 10 PIO line 7o Bit 11 PIO line 6· 12-15 bits: Sampled when output line 3 is strobed. o Bit 12 PIO line 9o Bit 13 PIO line 8o Bit 14 PIO line 7o Bit 15 PIO line 6Once the new state is sampled it is compared
25、 with the previous state stored to check if a new key has been pressed or a pressed key has been released. If the new key state sampled is different than the previous state stored then set the previous state to new state and report the key press by calling the function void appHandleMyDataAux(appTas
26、kData *theApp, uint16 contents_pio).4. Reporting of Key-press: The code for this functionality is in the file hid_keyboard_aux.c. Once a new key state has been detected, it has to be determined whether a new key has been pressed or a pressed key has been released. As per the chording functionality o
27、n the twiddler a key-code is reported to the host only on key release. So initially a check is made for this by comparing the previous key state stored with the new key state reported. i. If the new key state is less than previous key state then a key has been released else a new key has been presse
28、d. If new key state is less than previous key state then goto step ii. else goto step vi.ii. Prepare the data for HID input report using the previous key state since it is the key state to be reported. The data for HID input report is of 9 bytes. The contents are described as follows:a. Byte 0: This
29、 byte is set to 0x01 for input report b. Byte 1: Reservedc. Byte 2: This byte is used to report the modifiers. The twiddler has following modifiers:· Control key: The byte is set to 0x01· Alt key: The byte is set to 0x04· Shift key: The byte is set to 0x02 If no modifier is pressed th
30、en the byte is set to 0x00. d. Byte 3-8: These six bytes are used to report the HID key-code of the key pressed. So in one input report six key presses can be sent. Based on the key state detected the HID key-codes to be reported are obtained using HID key-code mapping case structure. iii. The input
31、 report formed is sent over the HID interrupt line.Function:· void HidInterruptReport ( HID * hid, hid_report_type report_type, uint16 report_length, const uint8 * data ) · bool StreamConnect ( Source , Sink ) · void StreamDisc
32、onnect ( Source , Sink ) iv. After reporting the data an empty report needs to be sent so that the host can detect end of input. So an empty report (all 9 bytes set to 0x00) is sent over HID interrupt line.· void HidInterruptReport ( HID * hid, hid_report_type
33、 report_type, uint16 report_length, const uint8 * data ) · bool StreamConnect ( Source , Sink ) · void StreamDisconnect ( Source , Sink ) v. Clear the previous key state.vi. Set the previous key state to new key state.Improvements:1. Most of the HID devices use the control line for reporting th
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年绥化市青冈县人民政府办公室选调工作人员5人考前自测高频考点模拟试题(含答案详解)
- 2025甘肃天水市武山县人力资源和社会保障局招聘城镇公益性岗位人员26人考前自测高频考点模拟试题及答案详解(网校专用)
- 基因检测疫病识别-洞察与解读
- 2025河南郑州二七区一国企招聘各部门人员9人考前自测高频考点模拟试题及参考答案详解1套
- 2025湖南长沙高新区中心幼儿园和馨园招聘教师2人模拟试卷及答案详解一套
- 2025年泉州安溪城建集团有限公司招聘17人考前自测高频考点模拟试题及答案详解(夺冠)
- 2025广东韶关市始兴县事业单位招聘暨“青年人才”和“急需紧缺人才”招聘89人模拟试卷含答案详解
- 2025广西百色市西林县社会保险事业管理中心招聘编外聘用人员6人考前自测高频考点模拟试题附答案详解(完整版)
- 2025甘肃嘉陵关市卫生健康委公开招聘公益性岗位人员考前自测高频考点模拟试题附答案详解
- 2025呼伦贝尔市政务服务与数据管理局所属事业单位竞争性比选工作人员考前自测高频考点模拟试题及答案详解(典优)
- 食品新产品开发 课件 第二章 食品新产品开发流程
- 高中化学374个必备知识点
- 单轴燃气蒸汽联合循环机组调试程序
- 舟山海域赤潮发生特点及成因分析
- 湿陷性黄土湿陷量计算表
- 丝杠安全操作保养规定
- 体育测量与评价PPT课件-第九章 运动员选材的测量与评价
- 《情满今生》读书笔记模板
- 胸痛中心网络医院STEMI患者绕行急诊和CCU方案流程图
- 大众蔚揽保养手册
- 急危重病人营养与代谢支持
评论
0/150
提交评论