Filter results by

Older Versions

Older API versions are available as a download. To view, extract the file and open the index.html file in a web browser.

artik_bluetooth.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2017 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  */
18 
19 #ifndef __ARTIK_BLUETOOTH_H
20 #define __ARTIK_BLUETOOTH_H
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #include "artik_error.h"
27 #include "artik_types.h"
28 
51 #define MAX_BT_NAME_LEN 128
52 #define MAX_BT_ADDR_LEN 128
53 #define MAX_BT_UUID_LEN 128
54 
55 #define BT_ADV_TYPE_BROADCAST "broadcast"
56 #define BT_ADV_TYPE_PERIPHERAL "peripheral"
57 
61  typedef enum {
62  BT_CAPA_KEYBOARDDISPLAY = 0, /*<! The agent is able to display and to write text*/
63  BT_CAPA_DISPLAYONLY, /*<! The agent is only able to display text*/
64  BT_CAPA_DISPLAYYESNO, /*<! The agent is able to display and confirm with yes/no*/
65  BT_CAPA_KEYBOARDONLY, /*<! The agent is only able to write text*/
66  BT_CAPA_NOINPUTNOOUTPUT, /*<! The agent has not input or output capability */
67  BT_CAPA_END
69 
73  typedef enum {
74  BT_EVENT_SCAN = 0, /*<! This event is raised when a Bluetooth device is discovered*/
75  BT_EVENT_BOND, /*<! This event is raised when a Bluetooth device is paired/unpaired*/
76  BT_EVENT_CONNECT, /*<! This event is raised when a Bluetooth device is connected/disconnected*/
77  BT_EVENT_SPP_CONNECT, /*<! This event is raised when a SPP profile is connected*/
78  BT_EVENT_SPP_RELEASE, /*<! This event is raised when a SPP profile is released*/
79  BT_EVENT_SPP_DISCONNECT, /*<! This event is raised when a SPP profile is disconnected*/
80  BT_EVENT_AGENT_REQUEST_PINCODE, /*<! This event is raised when request pincode*/
81  BT_EVENT_AGENT_DISPLAY_PINCODE, /*<! This event is raised when display pincode*/
82  BT_EVENT_AGENT_REQUEST_PASSKEY, /*<! This event is raised when request passkey*/
83  BT_EVENT_AGENT_DISPLAY_PASSKEY, /*<! This event is raised when display passkey*/
84  BT_EVENT_AGENT_CONFIRM, /*<! This event is raised when need to confirm the passkey*/
85  BT_EVENT_AGENT_AUTHORIZE, /*<! This event is raised when need to authorize the connection*/
86  BT_EVENT_AGENT_AUTHORIZE_SERVICE, /*<! This event is raised when need to authorize the service*/
87  BT_EVENT_AGENT_RELEASE, /*<! This event is raised when agent is released*/
88  BT_EVENT_AGENT_CANCEL, /*<! This event is raised when agent is canceled*/
89  BT_EVENT_PROXIMITY,
90  BT_EVENT_PF_HEARTRATE, /*<! This event is raised when heart rate data is received. */
91  BT_EVENT_FTP, /*<! This event is raised to monitor a FTP transfer. */
92  BT_EVENT_SERVICE_RESOLVED, /*<! This event is raised when bluetooth services are resolved. */
93  BT_EVENT_GATT_CHARACTERISTIC, /*<! This event is raised when custom gatt data is received. */
94  BT_EVENT_GATT_SERVICE_READY, /*<! This event is raised when a GATT services are registered. */
95  BT_EVENT_ADVERTISING_READY, /*<! This event is raised when an advertisement is registered. */
96  BT_EVENT_END
98 
130  typedef void (*artik_bt_callback) (artik_bt_event event, void *data,
131  void *user_data);
132 
136  typedef struct {
137  /*<! The event to set callback*/
138  artik_bt_event event;
139  /*<! The callback function of the event*/
141  /*<! The user data for the event*/
142  void *user_data;
144 
148  typedef struct {
149  /*<! The address of remote device is connected*/
150  char *device_addr;
151  /*<! The socket handle of the connection*/
152  int fd;
153  /*<! The version of the connection*/
154  int version;
155  /*<! The features of the connection*/
156  int features;
158 
162  typedef enum {
163  /*<! Miscellaneous major device class */
164  BT_MAJOR_DEVICE_CLASS_MISC = 0x00,
165  /*<! Computer major device class */
166  BT_MAJOR_DEVICE_CLASS_COMPUTER = 0x01,
167  /*<! Phone major device class */
168  BT_MAJOR_DEVICE_CLASS_PHONE = 0x02,
169  /*<! LAN/Network access point major device class */
170  BT_MAJOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT = 0x03,
171  /*<! Audio/Video major device class */
172  BT_MAJOR_DEVICE_CLASS_AUDIO_VIDEO = 0x04,
173  /*<! Peripheral major device class */
174  BT_MAJOR_DEVICE_CLASS_PERIPHERAL = 0x05,
175  /*<! Imaging major device class */
176  BT_MAJOR_DEVICE_CLASS_IMAGING = 0x06,
177  /*<! Wearable device class */
178  BT_MAJOR_DEVICE_CLASS_WEARABLE = 0x07,
179  /*<! Toy device class */
180  BT_MAJOR_DEVICE_CLASS_TOY = 0x08,
181  /*<! Health device class */
182  BT_MAJOR_DEVICE_CLASS_HEALTH = 0x09,
183  /*<! Uncategorized major device class */
184  BT_MAJOR_DEVICE_CLASS_UNCATEGORIZED = 0x1F
186 
190  typedef enum {
191  /*<! Uncategorized minor device class of computer */
192  BT_MINOR_DEVICE_CLASS_COMPUTER_UNCATEGORIZED = 0x00,
193  /*<! Desktop workstation minor device class of computer */
194  BT_MINOR_DEVICE_CLASS_COMPUTER_DESKTOP_WORKSTATION = 0x04,
195  /*<! Server minor device class of computer */
196  BT_MINOR_DEVICE_CLASS_COMPUTER_SERVER_CLASS = 0x08,
197  /*<! Laptop minor device class of computer */
198  BT_MINOR_DEVICE_CLASS_COMPUTER_LAPTOP = 0x0C,
199  /*<! Handheld PC/PDA minor device class of computer */
200  BT_MINOR_DEVICE_CLASS_COMPUTER_HANDHELD_PC_OR_PDA = 0x10,
201  /*<! Palm sized PC/PDA minor device class of computer */
202  BT_MINOR_DEVICE_CLASS_COMPUTER_PALM_SIZED_PC_OR_PDA = 0x14,
203  /*<! Wearable(watch sized) minor device class of computer */
204  BT_MINOR_DEVICE_CLASS_COMPUTER_WEARABLE_COMPUTER = 0x18,
205 
206  /*<! Uncategorized minor device class of phone */
207  BT_MINOR_DEVICE_CLASS_PHONE_UNCATEGORIZED = 0x00,
208  /*<! Cellular minor device class of phone */
209  BT_MINOR_DEVICE_CLASS_PHONE_CELLULAR = 0x04,
210  /*<! Cordless minor device class of phone */
211  BT_MINOR_DEVICE_CLASS_PHONE_CORDLESS = 0x08,
212  /*<! Smart phone minor device class of phone */
213  BT_MINOR_DEVICE_CLASS_PHONE_SMART_PHONE = 0x0C,
214  /*<! Wired modem or voice gateway minor device class of phone */
215  BT_MINOR_DEVICE_CLASS_PHONE_WIRED_MODEM_OR_VOICE_GATEWAY = 0x10,
216  /*<! Common ISDN minor device class of phone */
217  BT_MINOR_DEVICE_CLASS_PHONE_COMMON_ISDN_ACCESS = 0x14,
218 
219  /*<! Fully available minor device class of LAN/Network access point */
220  BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_FULLY_AVAILABLE = 0x04,
221  /*<! 1-17% utilized minor device class of LAN/Network access point */
222  BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_1_TO_17_PERCENT_UTILIZED = 0x20,
223  /*<! 17-33% utilized minor device class of LAN/Network access point */
224  BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_17_TO_33_PERCENT_UTILIZED = 0x40,
225  /*<! 33-50% utilized minor device class of LAN/Network access point */
226  BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_33_TO_50_PERCENT_UTILIZED = 0x60,
227  /*<! 50-67% utilized minor device class of LAN/Network access point */
228  BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_50_to_67_PERCENT_UTILIZED = 0x80,
229  /*<! 67-83% utilized minor device class of LAN/Network access point */
230  BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_67_TO_83_PERCENT_UTILIZED = 0xA0,
231  /*<! 83-99% utilized minor device class of LAN/Network access point */
232  BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_83_TO_99_PERCENT_UTILIZED = 0xC0,
233  /*<! No service available minor device class of LAN/Network access point */
234  BT_MINOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT_NO_SERVICE_AVAILABLE = 0xE0,
235 
236  /*<! Uncategorized minor device class of audio/video */
237  BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_UNCATEGORIZED = 0x00,
238  /*<! Wearable headset minor device class of audio/video */
239  BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_WEARABLE_HEADSET = 0x04,
240  /*<! Hands-free minor device class of audio/video */
241  BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_HANDS_FREE = 0x08,
242  /*<! Microphone minor device class of audio/video */
243  BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_MICROPHONE = 0x10,
244  /*<! Loudspeaker minor device class of audio/video */
245  BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_LOUDSPEAKER = 0x14,
246  /*<! Headphones minor device class of audio/video */
247  BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_HEADPHONES = 0x18,
248  /*<! Portable audio minor device class of audio/video */
249  BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_PORTABLE_AUDIO = 0x1C,
250  /*<! Car audio minor device class of audio/video */
251  BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_CAR_AUDIO = 0x20,
252  /*<! Set-top box minor device class of audio/video */
253  BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_SET_TOP_BOX = 0x24,
254  /*<! Hifi audio minor device class of audio/video */
255  BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_HIFI_AUDIO_DEVICE = 0x28,
256  /*<! VCR minor device class of audio/video */
257  BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VCR = 0x2C,
258  /*<! Video camera minor device class of audio/video */
259  BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VIDEO_CAMERA = 0x30,
260  /*<! Camcorder minor device class of audio/video */
261  BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_CAMCORDER = 0x34,
262  /*<! Video monitor minor device class of audio/video */
263  BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VIDEO_MONITOR = 0x38,
264  /*<! Video display and loudspeaker minor device class of audio/video */
265  BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VIDEO_DISPLAY_LOUDSPEAKER = 0x3C,
266  /*<! Video conferencing minor device class of audio/video */
267  BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_VIDEO_CONFERENCING = 0x40,
268  /*<! Gaming/toy minor device class of audio/video */
269  BT_MINOR_DEVICE_CLASS_AUDIO_VIDEO_GAMING_TOY = 0x48,
270 
271  /*<! Uncategorized minor device class of peripheral */
272  BT_MINOR_DEVICE_CLASS_PERIPHERA_UNCATEGORIZED = 0x00,
273  /*<! Key board minor device class of peripheral */
274  BT_MINOR_DEVICE_CLASS_PERIPHERAL_KEY_BOARD = 0x40,
275  /*<! Pointing device minor device class of peripheral */
276  BT_MINOR_DEVICE_CLASS_PERIPHERAL_POINTING_DEVICE = 0x80,
277  /*<! Combo keyboard or pointing device minor device class of peripheral */
278  BT_MINOR_DEVICE_CLASS_PERIPHERAL_COMBO_KEYBOARD_POINTING_DEVICE = 0xC0,
279  /*<! Joystick minor device class of peripheral */
280  BT_MINOR_DEVICE_CLASS_PERIPHERAL_JOYSTICK = 0x04,
281  /*<! Game pad minor device class of peripheral */
282  BT_MINOR_DEVICE_CLASS_PERIPHERAL_GAME_PAD = 0x08,
283  /*<! Remote control minor device class of peripheral */
284  BT_MINOR_DEVICE_CLASS_PERIPHERAL_REMOTE_CONTROL = 0x0C,
285  /*<! Sensing device minor device class of peripheral */
286  BT_MINOR_DEVICE_CLASS_PERIPHERAL_SENSING_DEVICE = 0x10,
287  /*<! Digitizer minor device class of peripheral */
288  BT_MINOR_DEVICE_CLASS_PERIPHERAL_DIGITIZER_TABLET = 0x14,
289  /*<! Card reader minor device class of peripheral */
290  BT_MINOR_DEVICE_CLASS_PERIPHERAL_CARD_READER = 0x18,
291  /*<! Digital pen minor device class of peripheral */
292  BT_MINOR_DEVICE_CLASS_PERIPHERAL_DIGITAL_PEN = 0x1C,
293  /*<! Handheld scanner minor device class of peripheral */
294  BT_MINOR_DEVICE_CLASS_PERIPHERAL_HANDHELD_SCANNER = 0x20,
295  /*<! Handheld gestural input device minor device class of peripheral */
296  BT_MINOR_DEVICE_CLASS_PERIPHERAL_HANDHELD_GESTURAL_INPUT_DEVICE = 0x24,
297 
298  /*<! Display minor device class of imaging */
299  BT_MINOR_DEVICE_CLASS_IMAGING_DISPLAY = 0x10,
300  /*<! Camera minor device class of imaging */
301  BT_MINOR_DEVICE_CLASS_IMAGING_CAMERA = 0x20,
302  /*<! Scanner minor device class of imaging */
303  BT_MINOR_DEVICE_CLASS_IMAGING_SCANNER = 0x40,
304  /*<! Printer minor device class of imaging */
305  BT_MINOR_DEVICE_CLASS_IMAGING_PRINTER = 0x80,
306 
307  /*<! Wrist watch minor device class of wearable */
308  BT_MINOR_DEVICE_CLASS_WEARABLE_WRIST_WATCH = 0x04,
309  /*<! Pager minor device class of wearable */
310  BT_MINOR_DEVICE_CLASS_WEARABLE_PAGER = 0x08,
311  /*<! Jacket minor device class of wearable */
312  BT_MINOR_DEVICE_CLASS_WEARABLE_JACKET = 0x0C,
313  /*<! Helmet minor device class of wearable */
314  BT_MINOR_DEVICE_CLASS_WEARABLE_HELMET = 0x10,
315  /*<! Glasses minor device class of wearable */
316  BT_MINOR_DEVICE_CLASS_WEARABLE_GLASSES = 0x14,
317 
318  /*<! Robot minor device class of toy */
319  BT_MINOR_DEVICE_CLASS_TOY_ROBOT = 0x04,
320  /*<! Vehicle minor device class of toy */
321  BT_MINOR_DEVICE_CLASS_TOY_VEHICLE = 0x08,
322  /*<! Doll/Action minor device class of toy */
323  BT_MINOR_DEVICE_CLASS_TOY_DOLL_ACTION = 0x0C,
324  /*<! Controller minor device class of toy */
325  BT_MINOR_DEVICE_CLASS_TOY_CONTROLLER = 0x10,
326  /*<! Game minor device class of toy */
327  BT_MINOR_DEVICE_CLASS_TOY_GAME = 0x14,
328 
329  /*<! Uncategorized minor device class of health */
330  BT_MINOR_DEVICE_CLASS_HEALTH_UNCATEGORIZED = 0x00,
331  /*<! Blood pressure monitor minor device class of health */
332  BT_MINOR_DEVICE_CLASS_HEALTH_BLOOD_PRESSURE_MONITOR = 0x04,
333  /*<! Thermometer minor device class of health */
334  BT_MINOR_DEVICE_CLASS_HEALTH_THERMOMETER = 0x08,
335  /*<! Weighing scale minor device class of health */
336  BT_MINOR_DEVICE_CLASS_HEALTH_WEIGHING_SCALE = 0x0C,
337  /*<! Glucose minor device class of health */
338  BT_MINOR_DEVICE_CLASS_HEALTH_GLUCOSE_METER = 0x10,
339  /*<! Pulse oximeter minor device class of health */
340  BT_MINOR_DEVICE_CLASS_HEALTH_PULSE_OXIMETER = 0x14,
341  /*<! Heart/Pulse rate monitor minor device class of health */
342  BT_MINOR_DEVICE_CLASS_HEALTH_HEART_PULSE_RATE_MONITOR = 0x18,
343  /*<! Health data display minor device class of health */
344  BT_MINOR_DEVICE_CLASS_HEALTH_DATA_DISPLAY = 0x1C,
345  /*<! Step counter minor device class of health */
346  BT_MINOR_DEVICE_CLASS_HEALTH_STEP_COUNTER = 0x20,
347  /*<! Body composition analyzer minor device class of health */
348  BT_MINOR_DEVICE_CLASS_HEALTH_BODY_COMPOSITION_ANALYZER = 0x24,
349  /*<! Peak flow monitor minor device class of health */
350  BT_MINOR_DEVICE_CLASS_HEALTH_PEAK_FLOW_MONITOR = 0x28,
351  /*<! Medication monitor minor device class of health */
352  BT_MINOR_DEVICE_CLASS_HEALTH_MEDICATION_MONITOR = 0x2C,
353  /*<! Knee prosthesis minor device class of health */
354  BT_MINOR_DEVICE_CLASS_HEALTH_KNEE_PROSTHESIS = 0x30,
355  /*<! Ankle prosthesis minor device class of health */
356  BT_MINOR_DEVICE_CLASS_HEALTH_ANKLE_PROSTHESIS = 0x34
358 
362  typedef enum {
363  BT_SERVICE_CLASS_LIMITED_DISCOVERABLE_MODE = 0x002000,
364  BT_SERVICE_CLASS_POSITIONING = 0x010000,
365  BT_SERVICE_CLASS_NETWORKING = 0x020000,
366  BT_SERVICE_CLASS_RENDERING = 0x040000,
367  BT_SERVICE_CLASS_CAPTURING = 0x080000,
368  BT_SERVICE_CLASS_OBJECT_TRANSFER = 0x100000,
369  BT_SERVICE_CLASS_AUDIO = 0x200000,
370  BT_SERVICE_CLASS_TELEPHONY = 0x400000,
371  BT_SERVICE_CLASS_INFORMATION = 0x800000
373 
374 
378  typedef struct {
379  /*<! Major device class. */
381  /*<! Minor device class. */
383  /*<! Device service class */
384  artik_bt_device_service_class service_class;
385  } artik_bt_class;
386 
393  typedef struct {
394  char *uuid; /*<! UUID of the profile*/
395  char *uuid_name; /*<! The friendly name of the profile */
396  } artik_bt_uuid;
397 
401  typedef enum {
402  /*<! The characteristic is broadcastable */
403  BT_GATT_CHAR_PROPERTY_BROADCAST = 0x01,
404  /*<! The characteristic is readable*/
405  BT_GATT_CHAR_PROPERTY_READ = 0x02,
406  /*<! The characteristic can be written without response */
407  BT_GATT_CHAR_PROPERTY_WRITE_NO_RESPONSE = 0x04,
408  /*<! The characteristic is writable*/
409  BT_GATT_CHAR_PROPERTY_WRITE = 0x08,
410  /*<! The characteristic supports notification */
411  BT_GATT_CHAR_PROPERTY_NOTIFY = 0x10,
412  /*<! The characteristic supports indication*/
413  BT_GATT_CHAR_PROPERTY_INDICATE = 0x20,
414  /*<! The characteristic supports write with signature */
415  BT_GATT_CHAR_PROPERTY_SIGNED_WRITE = 0x40
417 
421  typedef enum {
422  /*<! The descriptor is readable*/
423  BT_GATT_DESC_PROPERTY_READ = 0x01,
424  /*<! The descriptor is writable */
425  BT_GATT_DESC_PROPERTY_WRITE = 0x02,
426  /*<! The descriptor supports encrypted read */
427  BT_GATT_DESC_PROPERTY_ENC_READ = 0x04,
428  /*<! The descriptor supports encrypted write */
429  BT_GATT_DESC_PROPERTY_ENC_WRITE = 0x08,
430  /*<! The descriptor supports encrypted and authenticated read */
431  BT_GATT_DESC_PROPERTY_ENC_AUTH_READ = 0x10,
432  /*<! The descriptor supports encrypted and authenticated write */
433  BT_GATT_DESC_PROPERTY_ENC_AUTH_WRITE = 0x20,
434  /*<! The descriptor supports secure read */
435  BT_GATT_DESC_PROPERTY_SEC_READ = 0x40,
436  /*<! The descriptor supports secure write */
437  BT_GATT_DESC_PROPERTY_SEC_WRITE = 0x80
439 
443  typedef enum {
444  /*<! The request is successful*/
445  BT_GATT_REQ_STATE_TYPE_OK,
446  /*<! The request is failed*/
447  BT_GATT_REQ_STATE_TYPE_FAILED,
448  /*<! The request is in progress*/
449  BT_GATT_REQ_STATE_TYPE_IN_PROGRESS,
450  /*<! The request is not permitted */
451  BT_GATT_REQ_STATE_TYPE_NOT_PERMITTED,
452  /*<! The request has an invalid value length */
453  BT_GATT_REQ_STATE_TYPE_INVALID_VALUE_LENGTH,
454  /*<! The request is not authorized */
455  BT_GATT_REQ_STATE_TYPE_NOT_AUTHORIZED,
456  /*<! The request is not supported */
457  BT_GATT_REQ_STATE_TYPE_NOT_SUPPORTED
459 
466  typedef struct {
467  /*<! GATT characteristic UUID */
468  char *char_uuid;
469  /*<! GATT service UUID */
470  char *srv_uuid;
471  /*<! GATT property key */
472  char *key;
473  /*<! GATT property value */
474  char *value;
475  /*<! The value of the characteristic*/
476  unsigned char *bytes;
477  /*<! Number of byte in bytes */
478  int length;
480 
484  typedef struct {
485  const char *uuid; /*<! 128-bit service UUID */
486  bool primary; /*<! If true, this GATT service is a primary service */
488 
492  typedef struct {
493  char *uuid; /*<! 128-bit characteristic UUID */
494  unsigned char *value; /*<! The initial value of the GATT characteristic */
495  int length; /*<! The value's length */
496  int property; /*<! The GATT characteristic property see \ref artik_bt_gatt_char_properties */
498 
502  typedef struct {
503  char *uuid; /*<! 128-bit descriptor UUID */
504  unsigned char *value; /*<! The initial value of the GATT descriptor */
505  int length; /*<! The value's length */
506  int property; /*<! The GATT descriptor property see \ref artik_bt_gatt_desc_properties */
508 
515  typedef void *artik_bt_gatt_req;
516 
527  typedef void (*artik_bt_gatt_req_write)(artik_bt_gatt_req request,
528  const unsigned char *value,
529  int len,
530  void *user_data);
531 
541  typedef void (*artik_bt_gatt_req_read)(artik_bt_gatt_req request,
542  void *user_data);
543 
549  typedef void (*artik_bt_gatt_req_notify)(bool state,
550  void *user_data);
551 
558  typedef struct {
559  /*<! The address of remote device */
560  char *remote_address;
561  /*<! The name of remote device */
562  char *remote_name;
563  /*<! The Bluetooth classes */
564  artik_bt_class cod;
565  /*<! The strength indicator of received signal */
566  short rssi;
567  /*<! The UUID list */
568  artik_bt_uuid *uuid_list;
569  /*<! The number of uuid */
570  int uuid_length;
571  /*<! The bonding state */
572  bool is_bonded;
573  /*<! The connection state */
574  bool is_connected;
575  /*<! The authorization state */
576  bool is_authorized;
577  /*<! manufacturer specific data length */
578  int manufacturer_data_len;
579  /*<! manufacturer specific data */
580  char *manufacturer_data;
581  /*<! manufacturer ID */
582  short manufacturer_id;
583  /*<! manufacturer name */
584  char manufacturer_name[MAX_BT_NAME_LEN];
585  /*<! service data length */
586  int svc_data_len;
587  /*<! service data */
588  char *svc_data;
589  /*<! 128 bit service uuid */
590  char svc_uuid[MAX_BT_UUID_LEN];
591  } artik_bt_device;
592 
599  typedef struct {
600  char *address;
601  char *name;
602  char *alias;
605  bool pairable;
606  unsigned int pair_timeout;
607  unsigned int discover_timeout;
608  bool discovering;
612 
619  typedef struct {
620  /*<! Type of advertising ("broadcast" or "peripheral") */
621  const char *type;
622  /*<! List of UUIDs (128-bit version) to include in the "Service UUID" field of the advertising data */
623  const char **svc_uuid;
624  /*<! Length of svc_uuid */
625  int svc_uuid_len;
626  /*<! Manufacturer ID */
627  unsigned short mfr_id;
628  /*<! Manufacturer Data to include in the advertising data */
629  unsigned char *mfr_data;
630  /*<! The length of mfr_data*/
631  int mfr_data_len;
632  /*<! Array of UUID to include in "Service Solicitation" advertisement data. */
633  const char **solicit_uuid;
634  /*<! The length of solicit_uuid */
635  int solicit_uuid_len;
636  /*<! The UUID of the service associate with the svc_data*/
637  const char *svc_id;
638  /*<! Data to include in the advertisement packet*/
639  unsigned char *svc_data;
640  /*<! The length of svc_data */
641  int svc_data_len;
642  /*<! If true, the Tx Power is included in the advertisement packet. */
643  bool tx_power;
645 
649  typedef enum {
655  BT_DEVICE_ALL
657 
661  typedef enum {
666 
676  typedef struct {
678  unsigned int uuid_length;
679  int16_t rssi;
680  artik_bt_scan_type type;
682 
686  typedef enum {
692 
696  typedef struct {
700  char *title;
705  char *artist;
709  char *album;
714  char *genre;
719  unsigned int number_of_tracks;
724  unsigned int number;
728  unsigned int duration;
730 
734  typedef struct {
740  char *player;
744  char *name;
750  char *type;
759  char *folder;
765  bool playable;
772 
773  /*metadata property will be used to replace below properties.*/
779  char *title;
785  char *artist;
791  char *album;
797  char *genre;
803  unsigned int number_of_tracks;
809  unsigned int number;
810  /*
811  * \brief Playing time in milliseconds
812  *
813  * This field is available if the property \ref type is set to "audio" or "video"
814  */
815  unsigned int duration;
817 
821  typedef struct artik_bt_avrcp_item {
825  int index;
826 
831 
836 
842 
846  typedef struct {
847  char *name;
848  char *service;
857  char *role;
858  long channel;
859  long PSM;
863  long version;
864  long features;
866 
873  typedef struct {
874  char *object_path;
875  char *name;
876  char *file_name;
883  char *status;
884  unsigned long long transfered;
885  unsigned long long size;
887 
894  typedef struct artik_bt_ftp_file {
895  char *file_type;
896  char *file_name;
897  char *modified;
899  unsigned long long size;
902 
903  typedef void (*prop_change_callback)(artik_bt_ftp_property property,
904  char *prop_str, long long prop_int);
905 
912  typedef struct {
913  unsigned short bpm;
914  unsigned short energy;
915  bool contact;
916  unsigned short *interval;
917  unsigned short interval_count;
919 
929 
935  typedef enum {
939 
944  typedef struct {
945  /*<! The handle to be passed to the callbakc functions */
946  artik_bt_agent_request_handle handle;
947  /*<! The address of the request device */
948  char *device;
950 
954  typedef struct {
955  /*<! The address of the request device */
956  char *device;
957  /*<! The pincode to be display */
958  char *pincode;
960 
964  typedef struct {
965  /*<! The address of the request device */
966  char *device;
967  /*<! The passkey to be display */
968  unsigned int passkey;
969  /*<! The entered of the request device */
970  unsigned int entered;
972 
976  typedef struct {
977  /*<! The handle to be passed to the callbakc functions */
978  artik_bt_agent_request_handle handle;
979  /*<! The address of the request device */
980  char *device;
981  /*<! The passkey need to be confirmed */
982  unsigned int passkey;
984 
988  typedef struct {
989  /*<! The handle to be passed to the callbakc functions */
990  artik_bt_agent_request_handle handle;
991  /*<! The address of device to be authorized*/
992  char *device;
993  /*<! The device uuid need to be authorized*/
994  char *uuid;
996 
1004  typedef struct {
1010  artik_error(*start_scan) ();
1016  artik_error(*stop_scan) ();
1027  artik_error(*get_device) (const char *addr, artik_bt_device * device);
1038  artik_error(*get_devices) (artik_bt_device_type device_type,
1039  artik_bt_device**devices, int *num_devices);
1049  artik_error(*start_bond) (const char *addr);
1056  artik_error(*stop_bond) (const char *addr);
1066  artik_error(*connect) (const char *addr);
1076  artik_error(*disconnect) (const char *addr);
1084  artik_error(*free_device) (artik_bt_device * device);
1094  artik_error(*free_devices) (artik_bt_device**device_list, int count);
1101  artik_error(*init) (void);
1109  artik_error(*deinit) (void);
1121  artik_error(*set_callback) (artik_bt_event event,
1122  artik_bt_callback user_callback, void *user_data);
1134  *user_callbacks, unsigned int size);
1143  artik_error(*unset_callback) (artik_bt_event event);
1148  artik_error(*remove_unpaired_devices) ();
1158  artik_error(*remove_device) (const char *addr);
1166  artik_error(*set_scan_filter) (artik_bt_scan_filter * filter);
1178  artik_error(*set_alias) (const char *alias);
1199  artik_error(*set_discoverable) (bool discoverable);
1210  artik_error(*set_pairable) (bool pairable);
1220  artik_error(*set_pairableTimeout) (unsigned int timeout);
1230  artik_error(*set_discoverableTimeout) (unsigned int timeout);
1236  bool (*is_scanning)(void);
1244  artik_error(*get_adapter_info) (artik_bt_adapter * adapter);
1250  artik_error(*remove_devices) (void);
1259  artik_error(*connect_profile) (const char *addr, const char *uuid);
1267  artik_error(*set_trust) (const char *addr);
1275  artik_error(*unset_trust) (const char *addr);
1283  artik_error(*set_block) (const char *addr);
1291  artik_error(*unset_block) (const char *addr);
1299  bool (*is_paired)(const char *addr);
1307  bool (*is_connected)(const char *addr);
1315  bool (*is_trusted)(const char *addr);
1323  bool (*is_blocked)(const char *addr);
1331  artik_error(*gatt_add_service) (artik_bt_gatt_service svc, int *id);
1341  artik_error(*gatt_add_characteristic) (int svc_id,
1342  artik_bt_gatt_chr chr, int *id);
1343  /* \brief Add a new GATT descriptor
1344  *
1345  * \param[in] service_id The internal id of the GATT service to which
1346  * the descriptor belongs to
1347  * \param[in] char_id The internal id of the GATT characteristic to which the
1348  * the descriptor belongs to
1349  * \param[in] desc The descriptor properties.
1350  * \param[out] id The internal id of the descriptor.
1351  *
1352  * \return S_OK on success, otherwise a negative error value.
1353  */
1354  artik_error(*gatt_add_descriptor) (int service_id, int char_id,
1355  artik_bt_gatt_desc desc, int *id);
1356  /* \brief Remove a GATT service
1357  *
1358  * \param[in] sid The internal id of the GATT service to which
1359  * the descriptor belongs to
1360  * \return S_OK on success, otherwise a negative error value.
1361  */
1362  artik_error(*gatt_remove_service) (int sid);
1363  /* \brief Remove a GATT characteristic
1364  *
1365  * \param[in] sid The internal id of the GATT service to which
1366  * the descriptor belongs to
1367  * \param[in] cid The internal id of the GATT characteristic to which
1368  * the descriptor belongs to
1369  * \return S_OK on success, otherwise a negative error value.
1370  */
1371  artik_error(*gatt_remove_characteristic) (int sid, int cid);
1372  /* \brief Remove a GATT descriptor
1373  *
1374  * \param[in] sid The internal id of the GATT service to which
1375  * the descriptor belongs to
1376  * \param[in] cid The internal id of the GATT characteristic to
1377  * which the the descriptor belongs to
1378  * \param[in] did The internal id of the GATT descriptor to which the
1379  * descriptor belongs to
1380  * \return S_OK on success, otherwise a negative error value.
1381  */
1382  artik_error(*gatt_remove_descriptor) (int sid, int cid, int did);
1390  artik_error(*gatt_set_char_on_read_request) (int svc_id, int char_id,
1391  artik_bt_gatt_req_read callback, void *user_data);
1399  artik_error(*gatt_set_char_on_write_request) (int svc_id, int char_id,
1400  artik_bt_gatt_req_write callback, void *user_data);
1408  artik_error(*gatt_set_char_on_notify_request) (int svc_id, int char_id,
1409  artik_bt_gatt_req_notify callback, void *user_data);
1420  artik_error(*gatt_set_desc_on_read_request) (int svc_id, int char_id, int desc_id,
1421  artik_bt_gatt_req_read callback, void *user_data);
1432  artik_error(*gatt_set_desc_on_write_request) (int svc_id, int char_id, int desc_id,
1433  artik_bt_gatt_req_write callback, void *user_data);
1440  artik_error(*gatt_register_service) (int id);
1447  artik_error(*gatt_unregister_service) (int id);
1456  artik_error(*gatt_get_service_list) (const char *addr,
1457  artik_bt_uuid **uuid_list, int *len);
1467  artik_error(*gatt_get_characteristic_list) (const char *addr,
1468  const char *srv_uuid, artik_bt_uuid **uuid_list, int *len);
1479  artik_error(*gatt_get_descriptor_list) (const char *addr, const char *srv_uuid,
1480  const char *char_uuid, artik_bt_uuid **uuid_list, int *len);
1491  artik_error(*gatt_char_read_value) (const char *addr, const char *srv_uuid,
1492  const char *char_uuid, unsigned char **byte, int *byte_len);
1503  artik_error(*gatt_char_write_value) (const char *addr, const char *srv_uuid,
1504  const char *char_uuid, const unsigned char byte[], int byte_len);
1516  artik_error(*gatt_desc_read_value) (const char *addr, const char *srv_uuid,
1517  const char *char_uuid, const char *desc_uuid,
1518  unsigned char **byte, int *byte_len);
1530  artik_error(*gatt_desc_write_value) (const char *addr, const char *srv_uuid,
1531  const char *char_uuid, const char *desc_uuid,
1532  const unsigned char byte[], int byte_len);
1541  artik_error(*gatt_start_notify) (const char *addr, const char *srv_uuid,
1542  const char *char_uuid);
1551  artik_error(*gatt_stop_notify) (const char *addr, const char *srv_uuid,
1552  const char *char_uuid);
1562  artik_error(*gatt_get_char_properties) (const char *addr, const char *srv_uuid,
1563  const char *char_uuid, artik_bt_gatt_char_properties * properties);
1571  artik_error(*register_advertisement)
1572  (artik_bt_advertisement * user_adv, int *id);
1579  artik_error(*unregister_advertisement) (int id);
1588  artik_error(*gatt_req_set_value) (artik_bt_gatt_req req,
1589  int len, const unsigned char *value);
1598  artik_error(*gatt_req_set_result) (artik_bt_gatt_req req,
1599  artik_bt_gatt_req_state_type state, const char *err_msg);
1609  artik_error(*gatt_notify) (int svc_id, int char_id, unsigned char *byte,
1610  int len);
1621  artik_error(*avrcp_controller_change_folder) (int index);
1634  artik_error(*avrcp_controller_list_item)(int start_item, int end_item,
1635  artik_bt_avrcp_item**item_list);
1644  artik_error(*avrcp_controller_free_items)(
1645  artik_bt_avrcp_item**item_list);
1654  artik_error(*avrcp_controller_get_repeat_mode)(
1655  artik_bt_avrcp_repeat_mode * repeat_mode);
1664  artik_error(*avrcp_controller_set_repeat_mode)(artik_bt_avrcp_repeat_mode repeat_mode);
1671  bool (*avrcp_controller_is_connected)(void);
1678  artik_error(*avrcp_controller_resume_play) (void);
1685  artik_error(*avrcp_controller_pause) (void);
1692  artik_error(*avrcp_controller_stop) (void);
1699  artik_error(*avrcp_controller_next) (void);
1706  artik_error(*avrcp_controller_previous) (void);
1713  artik_error(*avrcp_controller_fast_forward) (void);
1720  artik_error(*avrcp_controller_rewind) (void);
1730  artik_error(*avrcp_controller_get_property)(int index,
1731  artik_bt_avrcp_item_property **properties);
1740  artik_error(*avrcp_controller_free_property)(
1741  artik_bt_avrcp_item_property **properties);
1750  artik_error(*avrcp_controller_play_item)(int index);
1759  artik_error(*avrcp_controller_add_to_playing)(int index);
1768  artik_error(*avrcp_controller_get_name) (char **name);
1779  artik_error(*avrcp_controller_get_status) (char **status);
1789  artik_error(*avrcp_controller_get_subtype) (char **subtype);
1800  artik_error(*avrcp_controller_get_type) (char **type);
1807  bool (*avrcp_controller_is_browsable)(void);
1816  artik_error(*avrcp_controller_get_position) (unsigned int *position);
1825  artik_error(*avrcp_controller_get_metadata) (
1835  artik_error(*avrcp_controller_free_metadata) (
1846  artik_error(*pan_register) (const char *uuid, const char *bridge);
1855  artik_error(*pan_unregister) (const char *uuid);
1867  artik_error(*pan_connect) (const char *mac_addr,
1868  const char *uuid, char **network_interface);
1875  artik_error(*pan_disconnect) (void);
1882  bool (*pan_is_connected)(void);
1891  artik_error(*pan_get_interface) (char **_interface);
1900  artik_error(*pan_get_UUID) (char **uuid);
1909  artik_error(*spp_register_profile)(artik_bt_spp_profile_option * opt);
1916  artik_error(*spp_unregister_profile)();
1925  artik_error(*ftp_create_session)(char *dest_addr);
1932  artik_error(*ftp_remove_session)(void);
1941  artik_error(*ftp_change_folder)(char *folder);
1950  artik_error(*ftp_create_folder)(char *folder);
1959  artik_error(*ftp_delete_file)(char *file);
1968  artik_error(*ftp_list_folder)(artik_bt_ftp_file * *file_list);
1977  artik_error(*ftp_free_list)(artik_bt_ftp_file * *file_list);
1987  artik_error(*ftp_get_file)(char *target_file, char *source_file);
1997  artik_error(*ftp_put_file)(char *source_file, char *target_file);
2004  artik_error(*ftp_resume_transfer)(void);
2011  artik_error(*ftp_suspend_transfer)(void);
2021  artik_error(*agent_register_capability)(artik_bt_agent_capability e);
2028  artik_error(*agent_set_default)(void);
2035  artik_error(*agent_unregister)(void);
2045  artik_error(*agent_send_pincode)(artik_bt_agent_request_handle handle, char *pincode);
2057  artik_error(*agent_send_passkey)(artik_bt_agent_request_handle handle, unsigned int passkey);
2068  artik_error(*agent_send_error)(artik_bt_agent_request_handle handle, artik_bt_agent_request_error e,
2069  const char *err_msg);
2079  artik_error(*agent_send_empty_response)(artik_bt_agent_request_handle handle);
2090  artik_error(*a2dp_source_get_state)(char **state);
2092 
2093  extern const artik_bluetooth_module bluetooth_module;
2094 
2095 #ifdef __cplusplus
2096 }
2097 #endif
2098 #endif /*__ARTIK_BLUETOOTH_H */
the struct of callback user data in BT_EVENT_AGENT_AUTHORIZE_SERVICE event.
char * album
Name of the album.
artik_bt_gatt_req_state_type
Request status.
char * genre
The genre name of the track. This may be "Not Available" if it&#39;s not provided by player.
unsigned int duration
The duration in milliseconds of the track.
Description of AVRCP item&#39;s properties.
char * type
Type of the item.
List of FTP items.
Class structure of device and service.
Bluetooth advertisement definition.
Bluetooth GATT data definition.
Bluetooth module operations.
Description of AVRCP track metadata.
unsigned int pair_timeout
char * player
Player object path.
artik_bt_uuid * uuid_list
struct artik_bt_ftp_file artik_bt_ftp_file
List of FTP items.
char * folder
Folder type.
char * status
Give the current status of the transfer.
Bluetooth adapter definition.
List of AVRCP items.
Custom types.
GATT descriptor definition.
bool playable
Indicate if the media can be played.
Description of SPP profile option.
unsigned long long transfered
unsigned int number_of_tracks
The number of tracks in total. This may be 0 if it&#39;s not provided by player.
artik_bt_device_type
This enum type is used to specify the type of device.
artik_bt_avrcp_track_metadata * metadata
Metadata of the media.
artik_bt_agent_request_error
The errors returned to the bluetooth service when a request failed.
artik_bt_event
All events come from the Bluetooth module.
artik_bt_minor_device_class
Enumerations of minor device class.
artik_bt_scan_type type
artik_bt_avrcp_repeat_mode
This enum type is used to specify the repeat mode.
artik_bt_class cod
GATT service definition.
the struct of callback user data in BT_EVENT_AGENT_DISPLAY_PINCODE event.
artik_bt_device_service_class
Service class part of class of device returned from device discovery.
artik_bt_gatt_desc_properties
Descriptor property.
unsigned int discover_timeout
artik_bt_gatt_char_properties
Characteristic property.
char * artist
The artist name of the track. This may be "Not Available" if it&#39;s not provided by player...
the struct of callback user data in BT_EVENT_SPP_CONNECT event.
char * album
The album name of the track.
Bluetooth scan filter definition.
unsigned int uuid_length
void * artik_bt_gatt_req
GATT request handle type.
struct artik_bt_avrcp_item * next_item
Next item in the list.
char * name
Displayable name.
int artik_error
Error type.
Definition: artik_error.h:35
Bluetooth UUID definition.
struct artik_bt_avrcp_item artik_bt_avrcp_item
List of AVRCP items.
unsigned int number
Number of the media.
unsigned long long size
void(* artik_bt_callback)(artik_bt_event event, void *data, void *user_data)
Event callback function prototype.
void(* artik_bt_gatt_req_read)(artik_bt_gatt_req request, void *user_data)
Method called when a client performs read on a characteristic.
char * title
The title name of the track.
void(* artik_bt_gatt_req_write)(artik_bt_gatt_req request, const unsigned char *value, int len, void *user_data)
Method called when a client performs write on a characteristic.
void * artik_bt_agent_request_handle
Bluetooth service request handle type.
the struct to set callbacks of the Bluetooth module.
Bluetooth HRP data definition.
char * title
Title of the media.
unsigned int number
The number of the track. This may be 0 if it&#39;s not provided by player.
artik_bt_uuid * uuid_list
Bluetooth device definition.
artik_bt_scan_type
This enum type is used to specify the type of scan.
artik_bt_agent_capability
This enumeration reflects the input and output capabilities of the agent.
the struct of callback user data in BT_EVENT_AGENT_REQUEST_PINCODE, BT_EVENT_AGENT_REQUEST_PASSKEY an...
int index
The index of this item.
struct artik_bt_ftp_file * next_file
char * item_obj_path
Pointer to string internally used by the API.
artik_bt_avrcp_item_property * property
Properties for this item.
unsigned long long size
the struct of callback user data in BT_EVENT_AGENT_CONFIRM event.
void(* artik_bt_gatt_req_notify)(bool state, void *user_data)
Method called when a client wants subscribe or unsubscribe to GATT notification.
char * artist
Name of the artist.
Error codes.
Bluetooth FTP definition.
unsigned int number_of_tracks
Number of tracks in the album.
GATT characteristic definition.
char * role
This field is used by asymetric profile that do not have UUIDs available to uniquely identify each si...
artik_bt_major_device_class
Enumerations of major device class.
the struct of callback user data in BT_EVENT_AGENT_DISPLAY_PASSKEY event.
Last updated on: