TEXAS INSTRUMENTS INCORPORATED Network Processor GATT How to setup GATT DB OFF CHIP on CC254X Greg Stewart 7/29/2012 This document describes how to setup a Network Processor implementation with the CC2540X where the GATT database is stored off chip. This requires the external CPU to process read and write request of the GATT database server entries.
Contents 1 Overview... 3 1.1 Network Processor GATT DATABASE OFF CHIP... 3 2 Setup... 3 2.1 Network Processor... 3 2.1.1 This guide used a SmartRF board with 2540 module running HostTestRelease. Compile HostTestRelease... 3 2.1.2 Preprocessor Options... 3 2.2 External MCU... 4 2.3 Master/Phone... 4 3 Setup GATT Table on Network Processor... 4 3.1 Send_GATT_AddService 0x2800, 3... 5 3.2 Send_GATT_AddAttribute "03:28", 0x03... 5 4 Verify GATT Table... 5 5 Advertise and Connect... 7 6 MCU Handle Request... 7
1 Overview 1.1 Network Processor GATT DATABASE OFF CHIP This document describes how to setup a Network Processor implementation with the CC2540X where the GATT database is stored off chip. This requires the external CPU to process read and write request of the GATT database server entries. Master (phone) RF Peripheral (CC254x) Network Processor UART/SPI External MCU (MSP430) 2 Setup 2.1 Network Processor 2.1.1 This guide used a SmartRF board with 2540 module running HostTestRelease. Compile HostTestRelease The hosttestrelease project is used when the CC254X is used as a network processor. This project default directory is C:\Texas Instruments\BLE-CC254x-1.2.1\Projects\ble\HostTestApp\CC254x\HostTestRelease.eww 2.1.2 Preprocessor Options To allow the MCU to receive all the GATT reads/request, it is necessary to build the application with the GATT_DB_OFF_CHIP preprocessor command.
2.2 External MCU The PC Tool HCITester.exe communicating with the SmartRF board over a UART simulates the external MCU. Please see wiki guide on setting up and running HCITester.exe. 2.3 Master/Phone The phone is simulated using Btool and a CC2540USB Dongle. 3 Setup GATT Table on Network Processor The following script is an example of GATT Table setup on the NP. This will let the NP lower layers know that there are valid attributes. Without these entries, the NP would reject any read or write request
from another BLE device. One the attributes are setup, any valid read/write request(depending on permission setup) will be forwarded to the external MCU. #initialize as peripheral Send_GAP_DeviceInit 0x04, 3, 0, 0, 1 ################################ # Generic Service ################################ #01- Add Primary Service Send_GATT_AddService 0x2800, 3 #02 Add Characteristic Declaration Send_GATT_AddAttribute "03:28", 0x03 #03 DeviceName Send_GATT_AddAttribute "00:2A", 0x03 sleep 100 ################################# # Simple BLE Service ################################# #04- Add Primary Service Send_GATT_AddService 0x2800, 4 #05 Add Characteristic Declaration - SimpleBleChar1 Send_GATT_AddAttribute "03:28", 0x03 #06 - Char 1 Value Send_GATT_AddAttribute "F1:FF", 0x03 #07 - Char1 Description Send_GATT_AddAttribute "01:29", 0x03 sleep 100 Send_ATT_FindInfoReq 0xfffe, 0x0001, 0xFFFF 3.1 Send_GATT_AddService 0x2800, 3 This command tells the NP to add a primary service and reserve space for 3 attributes ( counting itself as one). In the script above, these attributes will be a Characteristic Declaration fro Device Name and the Device Name Value attribute. 3.2 Send_GATT_AddAttribute "03:28", 0x03 This command tells the NP to add a Characteristic Declaration. The permissions are set here. Note, the value is not set, and as with attributes on a NP, any value read write request must be handled by external mcu. 4 Verify GATT Table One way to easily verify the GATT table setup is to use the ATT_FIND_INFO_REQ with the connection handle set to the loopback handle (0xFFFE).
09:00:49.453 Packet "ATT_FindInfoReq", Opcode 0xfd04 09:00:49.453 Parameters: 09:00:49.453 connectionhandle : 0xfffe 09:00:49.453 starthandle : 0x0001 09:00:49.453 endhandle : 0xFFFF 09:00:49.453 -- 09:00:49.453 Outgoing Dump: 09:00:49.453 0000: 01 04 fd 06 fe ff 01 00 ff ff... 09:00:49.468 Incoming Dump: 09:00:49.468 0000: 04 ff 06 7f 06 00 04 fd 00... 09:00:49.484 -- 09:00:49.484 Packet "HCI_Vendor_Specific_Event", Opcode 0x00ff 09:00:49.500 Parameters: 09:00:49.500 Event Opcode : 0x067f (CommandStatus) 09:00:49.500 Status : 0x00 (SUCCESS) 09:00:49.500 opcode : 0xfd04 (ATT_FindInfoReq) 09:00:49.500 datalen : 0x00 09:00:49.500 -- 09:00:49.500 Incoming Dump: 09:00:49.500 0000: 04 ff 1b... 09:00:49.500 Incoming Dump: 09:00:49.500 0000: 05 05 00 fe ff 15 01 01 00 00 28 02 00 03 28 03...(...(. 09:00:49.500 0010: 00 00 2a 04 00 00 28 05 00 03 28..*...(...( 09:00:49.515 -- 09:00:49.515 Packet "HCI_Vendor_Specific_Event", Opcode 0x00ff 09:00:49.531 Parameters: 09:00:49.531 Event Opcode : 0x0505 (ATT_FindInfoRsp) 09:00:49.531 Status : 0x00 (SUCCESS) 09:00:49.531 connectionhandle : 0xfffe 09:00:49.531 pdulen : 0x15 09:00:49.531 format : 0x01 (HANDLE_BT_UUID_TYPE - handle(s) and 16-bit Bluetooth UUID(s)) 09:00:49.531 handle : 0x0001 09:00:49.531 uuid : "00:28" 09:00:49.531 handle : 0x0002 09:00:49.531 uuid : "03:28" 09:00:49.531 handle : 0x0003 09:00:49.531 uuid : "00:2A" 09:00:49.531 handle : 0x0004 09:00:49.531 uuid : "00:28" 09:00:49.531 handle : 0x0005 09:00:49.531 uuid : "03:28" 09:00:49.531 -- 09:00:49.531 Incoming Dump: 09:00:49.531 0000: 04 ff 0f 05 05 00 fe ff 09 01 06 00 f1 ff 07 00... 09:00:49.531 0010: 01 29.) 09:00:49.546 -- 09:00:49.546 Packet "HCI_Vendor_Specific_Event", Opcode 0x00ff 09:00:49.546 Parameters: 09:00:49.546 Event Opcode : 0x0505 (ATT_FindInfoRsp) 09:00:49.546 Status : 0x00 (SUCCESS) 09:00:49.546 connectionhandle : 0xfffe 09:00:49.546 pdulen : 0x09 09:00:49.546 format : 0x01 (HANDLE_BT_UUID_TYPE - handle(s) and 16-bit Bluetooth UUID(s)) 09:00:49.546 handle : 0x0006 09:00:49.546 uuid : "F1:FF" 09:00:49.546 handle : 0x0007 09:00:49.546 uuid : "01:29" 09:00:49.546 -- 09:00:49.562 Incoming Dump: 09:00:49.562 0000: 04 ff 06 05 05 1a fe ff 00... 09:00:49.562 -- 09:00:49.562 Packet "HCI_Vendor_Specific_Event", Opcode 0x00ff 09:00:49.578 Parameters:
09:00:49.578 Event Opcode : 0x0505 (ATT_FindInfoRsp) 09:00:49.578 Status : 0x1a (bleprocedurecomplete) 09:00:49.578 connectionhandle : 0xfffe 09:00:49.578 pdulen : 0x00 09:00:49.578 -- 5 Advertise and Connect Use the following script to put the NP in discoverable mode. #Update advertising data Send_GAP_UpdateAdvertisingData 1, "02:01:04:05:05:05:07:07" #Update scan respon Send_GAP_UpdateAdvertisingData 0x00, "02:01:04:05:02:02:02:02" sleep 100 #Make discoverable: GAP_ADTYPE_ADV_IND Send_GAP_MakeDiscoverable 0x00, 0, 0, 0x07, 0x00 From BTool, initiate a connection. 6 MCU Handle Request The external mcu must handle reads and writes. Request Response Btool (OTA) NP HciTester Btool (OTA) NP HciTester From BTool.exe initiate a read request. From discovery, we know that handle 6 is the char1 value UUID (0xfff1). [56] : <Tx> - 09:16:44.218 -Type : 0x01 (Command) -Opcode : 0xFD8A (GATT_ReadCharValue) -Data Length : 0x04 (4) byte(s) ConnHandle : 0x0000 (0) Handle : 0x0006 (6) Dump(Tx): 01 8A FD 04 00 00 06 00 The NP will forward the request to the external mcu (HCITester.exe). From HCI tester, send a response for the value requested. 21:16:44.312 Incoming Dump: 21:16:44.312 0000: 04 ff 08 0a 05 00 00 00 02 06 00... 21:16:44.359 --
21:16:44.359 Packet "HCI_Vendor_Specific_Event", Opcode 0x00ff 21:16:44.406 Parameters: 21:16:44.406 Event Opcode : 0x050a (ATT_ReadReq) 21:16:44.406 Status : 0x00 (SUCCESS) 21:16:44.406 connectionhandle : 0x0000 21:16:44.406 pdulen : 0x02 21:16:44.406 handle : 0x0006 21:16:46.750 Packet "ATT_ReadRsp", Opcode 0xfd0b 21:16:46.750 Parameters: 21:16:46.750 connectionhandle : 0 21:16:46.750 value : "123" 21:16:46.750 -- 21:16:46.750 Outgoing Dump: 21:16:46.750 0000: 01 0b fd 04 00 00 12 30...0 21:16:46.750 -- 21:16:46.750 *** Script End *** 21:16:46.750 -- 21:16:46.781 Incoming Dump: 21:16:46.781 0000: 04 ff 06 7f 06 00 0b fd 00... 21:16:46.828 -- 21:16:46.828 Packet "HCI_Vendor_Specific_Event", Opcode 0x00ff 21:16:46.890 Parameters: 21:16:46.890 Event Opcode : 0x067f (CommandStatus) 21:16:46.890 Status : 0x00 (SUCCESS) 21:16:46.890 opcode : 0xfd0b (ATT_ReadRsp) 21:16:46.890 datalen : 0x00 21:16:46.890 --