gatt_browser.c (c30af2ff06c06811b258011679693e728853a136) gatt_browser.c (a4fe6467953bdb173fdf96a604f6527ed88f81c3)
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 88 unchanged lines hidden (view full) ---

97static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
98
99// Handles GATT client query results, sends queries and the
100// GAP disconnect command when the querying is done.
101static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
102
103static void gatt_client_setup(void){
104
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 88 unchanged lines hidden (view full) ---

97static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
98
99// Handles GATT client query results, sends queries and the
100// GAP disconnect command when the querying is done.
101static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
102
103static void gatt_client_setup(void){
104
105 // register for HCI events
106 hci_event_callback_registration.callback = &handle_hci_event;
107 hci_add_event_handler(&hci_event_callback_registration);
108
109 // Initialize L2CAP and register HCI event handler
110 l2cap_init();
111
112 // Initialize GATT client
113 gatt_client_init();
114
115 // Optinoally, Setup security manager
116 sm_init();
117 sm_set_io_capabilities(IO_CAPABILITY_NO_INPUT_NO_OUTPUT);
105 // Initialize L2CAP and register HCI event handler
106 l2cap_init();
107
108 // Initialize GATT client
109 gatt_client_init();
110
111 // Optinoally, Setup security manager
112 sm_init();
113 sm_set_io_capabilities(IO_CAPABILITY_NO_INPUT_NO_OUTPUT);
114
115 // register for HCI events
116 hci_event_callback_registration.callback = &handle_hci_event;
117 hci_add_event_handler(&hci_event_callback_registration);
118}
119/* LISTING_END */
120
121static void printUUID(uint8_t * uuid128, uint16_t uuid16){
122 if (uuid16){
123 printf("%04x",uuid16);
124 } else {
125 printf("%s", uuid128_to_str(uuid128));

--- 166 unchanged lines hidden (view full) ---

292 usage(argv[0]);
293 return 0;
294 }
295#else
296 (void)argc;
297 (void)argv;
298#endif
299
118}
119/* LISTING_END */
120
121static void printUUID(uint8_t * uuid128, uint16_t uuid16){
122 if (uuid16){
123 printf("%04x",uuid16);
124 } else {
125 printf("%s", uuid128_to_str(uuid128));

--- 166 unchanged lines hidden (view full) ---

292 usage(argv[0]);
293 return 0;
294 }
295#else
296 (void)argc;
297 (void)argv;
298#endif
299
300 // setup ATT server - only needed if LE Peripheral does ATT queries on its own, e.g. Android phones
301 att_server_init(profile_data, NULL, NULL);
302
303 // setup GATT client
304 gatt_client_setup();
305
300 // setup GATT client
301 gatt_client_setup();
302
303 // setup ATT server - only needed if LE Peripheral does ATT queries on its own, e.g. Android and iOS
304 att_server_init(profile_data, NULL, NULL);
305
306 // turn on!
307 hci_power_control(HCI_POWER_ON);
308
309 return 0;
310}
311
312/* EXAMPLE_END */
313
314
306 // turn on!
307 hci_power_control(HCI_POWER_ON);
308
309 return 0;
310}
311
312/* EXAMPLE_END */
313
314