1bcf00d8fSMatthias Ringwald /*
2bcf00d8fSMatthias Ringwald * Copyright (C) 2014 BlueKitchen GmbH
3bcf00d8fSMatthias Ringwald *
4bcf00d8fSMatthias Ringwald * Redistribution and use in source and binary forms, with or without
5bcf00d8fSMatthias Ringwald * modification, are permitted provided that the following conditions
6bcf00d8fSMatthias Ringwald * are met:
7bcf00d8fSMatthias Ringwald *
8bcf00d8fSMatthias Ringwald * 1. Redistributions of source code must retain the above copyright
9bcf00d8fSMatthias Ringwald * notice, this list of conditions and the following disclaimer.
10bcf00d8fSMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright
11bcf00d8fSMatthias Ringwald * notice, this list of conditions and the following disclaimer in the
12bcf00d8fSMatthias Ringwald * documentation and/or other materials provided with the distribution.
13bcf00d8fSMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of
14bcf00d8fSMatthias Ringwald * contributors may be used to endorse or promote products derived
15bcf00d8fSMatthias Ringwald * from this software without specific prior written permission.
16bcf00d8fSMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for
17bcf00d8fSMatthias Ringwald * personal benefit and not for any commercial purpose or for
18bcf00d8fSMatthias Ringwald * monetary gain.
19bcf00d8fSMatthias Ringwald *
20bcf00d8fSMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21bcf00d8fSMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22bcf00d8fSMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
232fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
242fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25bcf00d8fSMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26bcf00d8fSMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27bcf00d8fSMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28bcf00d8fSMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29bcf00d8fSMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30bcf00d8fSMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31bcf00d8fSMatthias Ringwald * SUCH DAMAGE.
32bcf00d8fSMatthias Ringwald *
33bcf00d8fSMatthias Ringwald * Please inquire about commercial licensing options at
34bcf00d8fSMatthias Ringwald * [email protected]
35bcf00d8fSMatthias Ringwald *
36bcf00d8fSMatthias Ringwald */
37bcf00d8fSMatthias Ringwald
38e501bae0SMatthias Ringwald #define BTSTACK_FILE__ "gatt_browser.c"
39ab2c6ae4SMatthias Ringwald
40bcf00d8fSMatthias Ringwald // *****************************************************************************
41ec8ae085SMilanka Ringwald /* EXAMPLE_START(gatt_browser): GATT Client - Discover Primary Services
42bcf00d8fSMatthias Ringwald *
43bcf00d8fSMatthias Ringwald * @text This example shows how to use the GATT Client
44bcf00d8fSMatthias Ringwald * API to discover primary services and their characteristics of the first found
45bcf00d8fSMatthias Ringwald * device that is advertising its services.
46bcf00d8fSMatthias Ringwald *
47bcf00d8fSMatthias Ringwald * The logic is divided between the HCI and GATT client packet handlers.
48bcf00d8fSMatthias Ringwald * The HCI packet handler is responsible for finding a remote device,
49bcf00d8fSMatthias Ringwald * connecting to it, and for starting the first GATT client query.
50bcf00d8fSMatthias Ringwald * Then, the GATT client packet handler receives all primary services and
51bcf00d8fSMatthias Ringwald * requests the characteristics of the last one to keep the example short.
52bcf00d8fSMatthias Ringwald *
53bcf00d8fSMatthias Ringwald */
54bcf00d8fSMatthias Ringwald // *****************************************************************************
55bcf00d8fSMatthias Ringwald
56bcf00d8fSMatthias Ringwald #include <stdint.h>
57bcf00d8fSMatthias Ringwald #include <stdio.h>
58bcf00d8fSMatthias Ringwald #include <stdlib.h>
59bcf00d8fSMatthias Ringwald #include <string.h>
60bcf00d8fSMatthias Ringwald
61bcf00d8fSMatthias Ringwald #include "btstack.h"
62a63a688aSMatthias Ringwald
63a63a688aSMatthias Ringwald // gatt_browser.gatt contains the declaration of the provided GATT Services + Characteristics
64a63a688aSMatthias Ringwald // gatt_browser.h contains the binary representation of gatt_browser.gatt
65a63a688aSMatthias Ringwald // it is generated by the build system by calling: $BTSTACK_ROOT/tool/compile_gatt.py gatt_browser.gatt gatt_browser.h
66a63a688aSMatthias Ringwald // it needs to be regenerated when the GATT Database declared in gatt_browser.gatt file is modified
67add9769eSMatthias Ringwald #include "gatt_browser.h"
68bcf00d8fSMatthias Ringwald
69bcf00d8fSMatthias Ringwald typedef struct advertising_report {
70bcf00d8fSMatthias Ringwald uint8_t type;
71bcf00d8fSMatthias Ringwald uint8_t event_type;
72bcf00d8fSMatthias Ringwald uint8_t address_type;
73bcf00d8fSMatthias Ringwald bd_addr_t address;
74bcf00d8fSMatthias Ringwald uint8_t rssi;
75bcf00d8fSMatthias Ringwald uint8_t length;
763ee82ab1SMilanka Ringwald const uint8_t * data;
77bcf00d8fSMatthias Ringwald } advertising_report_t;
78bcf00d8fSMatthias Ringwald
79c30af2ffSMatthias Ringwald static bd_addr_t cmdline_addr;
80bcf00d8fSMatthias Ringwald static int cmdline_addr_found = 0;
81bcf00d8fSMatthias Ringwald
828e101757SMatthias Ringwald static hci_con_handle_t connection_handle;
83bcf00d8fSMatthias Ringwald static gatt_client_service_t services[40];
84bcf00d8fSMatthias Ringwald static int service_count = 0;
85bcf00d8fSMatthias Ringwald static int service_index = 0;
86bcf00d8fSMatthias Ringwald
87bcf00d8fSMatthias Ringwald static btstack_packet_callback_registration_t hci_event_callback_registration;
88bcf00d8fSMatthias Ringwald
89bcf00d8fSMatthias Ringwald /* @section GATT client setup
90bcf00d8fSMatthias Ringwald *
91bcf00d8fSMatthias Ringwald * @text In the setup phase, a GATT client must register the HCI and GATT client
92bcf00d8fSMatthias Ringwald * packet handlers, as shown in Listing GATTClientSetup.
93bcf00d8fSMatthias Ringwald * Additionally, the security manager can be setup, if signed writes, or
94bcf00d8fSMatthias Ringwald * encrypted, or authenticated connection are required, to access the
95bcf00d8fSMatthias Ringwald * characteristics, as explained in Section on [SMP](../protocols/#sec:smpProtocols).
96bcf00d8fSMatthias Ringwald */
97bcf00d8fSMatthias Ringwald
98bcf00d8fSMatthias Ringwald /* LISTING_START(GATTClientSetup): Setting up GATT client */
99bcf00d8fSMatthias Ringwald
100bcf00d8fSMatthias Ringwald // Handles connect, disconnect, and advertising report events,
101bcf00d8fSMatthias Ringwald // starts the GATT client, and sends the first query.
102bcf00d8fSMatthias Ringwald static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
103bcf00d8fSMatthias Ringwald
104bcf00d8fSMatthias Ringwald // Handles GATT client query results, sends queries and the
105bcf00d8fSMatthias Ringwald // GAP disconnect command when the querying is done.
106bcf00d8fSMatthias Ringwald static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
107bcf00d8fSMatthias Ringwald
gatt_client_setup(void)108bcf00d8fSMatthias Ringwald static void gatt_client_setup(void){
109bcf00d8fSMatthias Ringwald
110bcf00d8fSMatthias Ringwald // Initialize L2CAP and register HCI event handler
111bcf00d8fSMatthias Ringwald l2cap_init();
112bcf00d8fSMatthias Ringwald
113bcf00d8fSMatthias Ringwald // Initialize GATT client
114bcf00d8fSMatthias Ringwald gatt_client_init();
115bcf00d8fSMatthias Ringwald
116bcf00d8fSMatthias Ringwald // Optinoally, Setup security manager
117bcf00d8fSMatthias Ringwald sm_init();
118bcf00d8fSMatthias Ringwald sm_set_io_capabilities(IO_CAPABILITY_NO_INPUT_NO_OUTPUT);
119a4fe6467SMatthias Ringwald
120a4fe6467SMatthias Ringwald // register for HCI events
121a4fe6467SMatthias Ringwald hci_event_callback_registration.callback = &handle_hci_event;
122a4fe6467SMatthias Ringwald hci_add_event_handler(&hci_event_callback_registration);
123bcf00d8fSMatthias Ringwald }
124bcf00d8fSMatthias Ringwald /* LISTING_END */
125bcf00d8fSMatthias Ringwald
printUUID(uint8_t * uuid128,uint16_t uuid16)126bcf00d8fSMatthias Ringwald static void printUUID(uint8_t * uuid128, uint16_t uuid16){
127bcf00d8fSMatthias Ringwald if (uuid16){
128bcf00d8fSMatthias Ringwald printf("%04x",uuid16);
129bcf00d8fSMatthias Ringwald } else {
130bcf00d8fSMatthias Ringwald printf("%s", uuid128_to_str(uuid128));
131bcf00d8fSMatthias Ringwald }
132bcf00d8fSMatthias Ringwald }
133bcf00d8fSMatthias Ringwald
dump_advertising_report(advertising_report_t * e)134bcf00d8fSMatthias Ringwald static void dump_advertising_report(advertising_report_t * e){
135bcf00d8fSMatthias Ringwald printf(" * adv. event: evt-type %u, addr-type %u, addr %s, rssi %u, length adv %u, data: ", e->event_type,
136bcf00d8fSMatthias Ringwald e->address_type, bd_addr_to_str(e->address), e->rssi, e->length);
137bcf00d8fSMatthias Ringwald printf_hexdump(e->data, e->length);
138bcf00d8fSMatthias Ringwald
139bcf00d8fSMatthias Ringwald }
140bcf00d8fSMatthias Ringwald
dump_characteristic(gatt_client_characteristic_t * characteristic)141bcf00d8fSMatthias Ringwald static void dump_characteristic(gatt_client_characteristic_t * characteristic){
142bcf00d8fSMatthias Ringwald printf(" * characteristic: [0x%04x-0x%04x-0x%04x], properties 0x%02x, uuid ",
143bcf00d8fSMatthias Ringwald characteristic->start_handle, characteristic->value_handle, characteristic->end_handle, characteristic->properties);
144bcf00d8fSMatthias Ringwald printUUID(characteristic->uuid128, characteristic->uuid16);
145bcf00d8fSMatthias Ringwald printf("\n");
146bcf00d8fSMatthias Ringwald }
147bcf00d8fSMatthias Ringwald
dump_service(gatt_client_service_t * service)148bcf00d8fSMatthias Ringwald static void dump_service(gatt_client_service_t * service){
149bcf00d8fSMatthias Ringwald printf(" * service: [0x%04x-0x%04x], uuid ", service->start_group_handle, service->end_group_handle);
150bcf00d8fSMatthias Ringwald printUUID(service->uuid128, service->uuid16);
151bcf00d8fSMatthias Ringwald printf("\n");
152bcf00d8fSMatthias Ringwald }
153bcf00d8fSMatthias Ringwald
fill_advertising_report_from_packet(advertising_report_t * report,uint8_t * packet)154bcf00d8fSMatthias Ringwald static void fill_advertising_report_from_packet(advertising_report_t * report, uint8_t *packet){
1553ee82ab1SMilanka Ringwald gap_event_advertising_report_get_address(packet, report->address);
1563ee82ab1SMilanka Ringwald report->event_type = gap_event_advertising_report_get_advertising_event_type(packet);
1573ee82ab1SMilanka Ringwald report->address_type = gap_event_advertising_report_get_address_type(packet);
1583ee82ab1SMilanka Ringwald report->rssi = gap_event_advertising_report_get_rssi(packet);
1593ee82ab1SMilanka Ringwald report->length = gap_event_advertising_report_get_data_length(packet);
1603ee82ab1SMilanka Ringwald report->data = gap_event_advertising_report_get_data(packet);
161bcf00d8fSMatthias Ringwald }
162bcf00d8fSMatthias Ringwald
163bcf00d8fSMatthias Ringwald /* @section HCI packet handler
164bcf00d8fSMatthias Ringwald *
165bcf00d8fSMatthias Ringwald * @text The HCI packet handler has to start the scanning,
166bcf00d8fSMatthias Ringwald * to find the first advertising device, to stop scanning, to connect
167bcf00d8fSMatthias Ringwald * to and later to disconnect from it, to start the GATT client upon
168bcf00d8fSMatthias Ringwald * the connection is completed, and to send the first query - in this
169bcf00d8fSMatthias Ringwald * case the gatt_client_discover_primary_services() is called, see
170bcf00d8fSMatthias Ringwald * Listing GATTBrowserHCIPacketHandler.
171bcf00d8fSMatthias Ringwald */
172bcf00d8fSMatthias Ringwald
173bcf00d8fSMatthias Ringwald /* LISTING_START(GATTBrowserHCIPacketHandler): Connecting and disconnecting from the GATT client */
handle_hci_event(uint8_t packet_type,uint16_t channel,uint8_t * packet,uint16_t size)174bcf00d8fSMatthias Ringwald static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
1759ec2630cSMatthias Ringwald UNUSED(channel);
1769ec2630cSMatthias Ringwald UNUSED(size);
1779ec2630cSMatthias Ringwald
178bcf00d8fSMatthias Ringwald if (packet_type != HCI_EVENT_PACKET) return;
179bcf00d8fSMatthias Ringwald advertising_report_t report;
180bcf00d8fSMatthias Ringwald
1810e2df43fSMatthias Ringwald uint8_t event = hci_event_packet_get_type(packet);
182bcf00d8fSMatthias Ringwald switch (event) {
183bcf00d8fSMatthias Ringwald case BTSTACK_EVENT_STATE:
184bcf00d8fSMatthias Ringwald // BTstack activated, get started
185cdc7d1abSMilanka Ringwald if (btstack_event_state_get_state(packet) != HCI_STATE_WORKING) break;
186bcf00d8fSMatthias Ringwald if (cmdline_addr_found){
187bcf00d8fSMatthias Ringwald printf("Trying to connect to %s\n", bd_addr_to_str(cmdline_addr));
188bcf00d8fSMatthias Ringwald gap_connect(cmdline_addr, 0);
189bcf00d8fSMatthias Ringwald break;
190bcf00d8fSMatthias Ringwald }
191bcf00d8fSMatthias Ringwald printf("BTstack activated, start scanning!\n");
192bcf00d8fSMatthias Ringwald gap_set_scan_parameters(0,0x0030, 0x0030);
193bcf00d8fSMatthias Ringwald gap_start_scan();
194bcf00d8fSMatthias Ringwald break;
195045013feSMatthias Ringwald case GAP_EVENT_ADVERTISING_REPORT:
196bcf00d8fSMatthias Ringwald fill_advertising_report_from_packet(&report, packet);
1973ee82ab1SMilanka Ringwald dump_advertising_report(&report);
1983ee82ab1SMilanka Ringwald
199bcf00d8fSMatthias Ringwald // stop scanning, and connect to the device
200bcf00d8fSMatthias Ringwald gap_stop_scan();
201bcf00d8fSMatthias Ringwald gap_connect(report.address,report.address_type);
202bcf00d8fSMatthias Ringwald break;
203bba48196SMatthias Ringwald case HCI_EVENT_META_GAP:
204bcf00d8fSMatthias Ringwald // wait for connection complete
205bba48196SMatthias Ringwald if (hci_event_gap_meta_get_subevent_code(packet) != GAP_SUBEVENT_LE_CONNECTION_COMPLETE) break;
2068e101757SMatthias Ringwald printf("\nGATT browser - CONNECTED\n");
207bba48196SMatthias Ringwald connection_handle = gap_subevent_le_connection_complete_get_connection_handle(packet);
208bcf00d8fSMatthias Ringwald // query primary services
2098e101757SMatthias Ringwald gatt_client_discover_primary_services(handle_gatt_client_event, connection_handle);
210bcf00d8fSMatthias Ringwald break;
211bcf00d8fSMatthias Ringwald case HCI_EVENT_DISCONNECTION_COMPLETE:
212bcf00d8fSMatthias Ringwald printf("\nGATT browser - DISCONNECTED\n");
213bcf00d8fSMatthias Ringwald break;
214bcf00d8fSMatthias Ringwald default:
215bcf00d8fSMatthias Ringwald break;
216bcf00d8fSMatthias Ringwald }
217bcf00d8fSMatthias Ringwald }
218bcf00d8fSMatthias Ringwald /* LISTING_END */
219bcf00d8fSMatthias Ringwald
220bcf00d8fSMatthias Ringwald /* @section GATT Client event handler
221bcf00d8fSMatthias Ringwald *
222bcf00d8fSMatthias Ringwald * @text Query results and further queries are handled by the GATT client packet
223bcf00d8fSMatthias Ringwald * handler, as shown in Listing GATTBrowserQueryHandler. Here, upon
224bcf00d8fSMatthias Ringwald * receiving the primary services, the
225bcf00d8fSMatthias Ringwald * gatt_client_discover_characteristics_for_service() query for the last
226bcf00d8fSMatthias Ringwald * received service is sent. After receiving the characteristics for the service,
227bcf00d8fSMatthias Ringwald * gap_disconnect is called to terminate the connection. Upon
228bcf00d8fSMatthias Ringwald * disconnect, the HCI packet handler receives the disconnect complete event.
229bcf00d8fSMatthias Ringwald */
230bcf00d8fSMatthias Ringwald
231bcf00d8fSMatthias Ringwald /* LISTING_START(GATTBrowserQueryHandler): Handling of the GATT client queries */
232bcf00d8fSMatthias Ringwald
handle_gatt_client_event(uint8_t packet_type,uint16_t channel,uint8_t * packet,uint16_t size)233bcf00d8fSMatthias Ringwald static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
2349ec2630cSMatthias Ringwald UNUSED(packet_type);
2359ec2630cSMatthias Ringwald UNUSED(channel);
2369ec2630cSMatthias Ringwald UNUSED(size);
2379ec2630cSMatthias Ringwald
238bcf00d8fSMatthias Ringwald gatt_client_service_t service;
239bcf00d8fSMatthias Ringwald gatt_client_characteristic_t characteristic;
2400e2df43fSMatthias Ringwald switch(hci_event_packet_get_type(packet)){
241dd5af05eSMatthias Ringwald case GATT_EVENT_SERVICE_QUERY_RESULT:
242bcf00d8fSMatthias Ringwald gatt_event_service_query_result_get_service(packet, &service);
243bcf00d8fSMatthias Ringwald dump_service(&service);
244bcf00d8fSMatthias Ringwald services[service_count++] = service;
245bcf00d8fSMatthias Ringwald break;
246bcf00d8fSMatthias Ringwald case GATT_EVENT_CHARACTERISTIC_QUERY_RESULT:
247bcf00d8fSMatthias Ringwald gatt_event_characteristic_query_result_get_characteristic(packet, &characteristic);
248bcf00d8fSMatthias Ringwald dump_characteristic(&characteristic);
249bcf00d8fSMatthias Ringwald break;
250bcf00d8fSMatthias Ringwald case GATT_EVENT_QUERY_COMPLETE:
251bcf00d8fSMatthias Ringwald // GATT_EVENT_QUERY_COMPLETE of search characteristics
252bcf00d8fSMatthias Ringwald if (service_index < service_count) {
253bcf00d8fSMatthias Ringwald service = services[service_index++];
254bcf00d8fSMatthias Ringwald printf("\nGATT browser - CHARACTERISTIC for SERVICE %s, [0x%04x-0x%04x]\n",
255bcf00d8fSMatthias Ringwald uuid128_to_str(service.uuid128), service.start_group_handle, service.end_group_handle);
2568e101757SMatthias Ringwald gatt_client_discover_characteristics_for_service(handle_gatt_client_event, connection_handle, &service);
257bcf00d8fSMatthias Ringwald break;
258bcf00d8fSMatthias Ringwald }
259bcf00d8fSMatthias Ringwald service_index = 0;
260bcf00d8fSMatthias Ringwald break;
261bcf00d8fSMatthias Ringwald default:
262bcf00d8fSMatthias Ringwald break;
263bcf00d8fSMatthias Ringwald }
264bcf00d8fSMatthias Ringwald }
265bcf00d8fSMatthias Ringwald /* LISTING_END */
266bcf00d8fSMatthias Ringwald
267bcf00d8fSMatthias Ringwald int btstack_main(int argc, const char * argv[]);
btstack_main(int argc,const char * argv[])268bcf00d8fSMatthias Ringwald int btstack_main(int argc, const char * argv[]){
269bcf00d8fSMatthias Ringwald
2707ea7688aSMatthias Ringwald #ifdef HAVE_BTSTACK_STDIN
2718e101757SMatthias Ringwald // process command line arguments when running in a shell
272*2e80d8ecSSteven Buytaert int arg;
273bcf00d8fSMatthias Ringwald cmdline_addr_found = 0;
274bcf00d8fSMatthias Ringwald
275*2e80d8ecSSteven Buytaert for (arg = 1; arg < argc; arg++) {
276bcf00d8fSMatthias Ringwald if(!strcmp(argv[arg], "-a") || !strcmp(argv[arg], "--address")){
277*2e80d8ecSSteven Buytaert if (arg + 1 < argc) {
278bcf00d8fSMatthias Ringwald arg++;
279a6efb919SMatthias Ringwald cmdline_addr_found = sscanf_bd_addr(argv[arg], cmdline_addr);
280bcf00d8fSMatthias Ringwald }
281*2e80d8ecSSteven Buytaert if (!cmdline_addr_found) {
2828e101757SMatthias Ringwald fprintf(stderr, "\nUsage: %s [-a|--address aa:bb:cc:dd:ee:ff]\n", argv[0]);
283*2e80d8ecSSteven Buytaert fprintf(stderr, "If no argument is provided, %s will start scanning and connect to the first found device.\n"
284*2e80d8ecSSteven Buytaert "To connect to a specific device use argument [-a].\n\n", argv[0]);
285*2e80d8ecSSteven Buytaert return 1;
286*2e80d8ecSSteven Buytaert }
287*2e80d8ecSSteven Buytaert }
288*2e80d8ecSSteven Buytaert }
289*2e80d8ecSSteven Buytaert if (!cmdline_addr_found) {
290*2e80d8ecSSteven Buytaert fprintf(stderr, "No specific address specified or found; start scanning for any advertiser.\n");
291bcf00d8fSMatthias Ringwald }
292eb8fc740SMatthias Ringwald #else
2936316c8edSMatthias Ringwald (void)argc;
2946316c8edSMatthias Ringwald (void)argv;
295eb8fc740SMatthias Ringwald #endif
296bcf00d8fSMatthias Ringwald
297add9769eSMatthias Ringwald // setup GATT client
298bcf00d8fSMatthias Ringwald gatt_client_setup();
299bcf00d8fSMatthias Ringwald
300a4fe6467SMatthias Ringwald // setup ATT server - only needed if LE Peripheral does ATT queries on its own, e.g. Android and iOS
301a4fe6467SMatthias Ringwald att_server_init(profile_data, NULL, NULL);
302a4fe6467SMatthias Ringwald
303bcf00d8fSMatthias Ringwald // turn on!
304bcf00d8fSMatthias Ringwald hci_power_control(HCI_POWER_ON);
305bcf00d8fSMatthias Ringwald
306bcf00d8fSMatthias Ringwald return 0;
307bcf00d8fSMatthias Ringwald }
308bcf00d8fSMatthias Ringwald
309bcf00d8fSMatthias Ringwald /* EXAMPLE_END */
310bcf00d8fSMatthias Ringwald
311bcf00d8fSMatthias Ringwald
312