Tizen 2.0 Release
[framework/connectivity/neard.git] / include / device.h
1 /*
2  *
3  *  neard - Near Field Communication manager
4  *
5  *  Copyright (C) 2012  Intel Corporation. All rights reserved.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  published by the Free Software Foundation.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 #ifndef __NEAR_DEVICE_H
23 #define __NEAR_DEVICE_H
24
25 #include <stdint.h>
26
27 #include <glib.h>
28
29 struct near_device;
30
31 typedef void (*near_device_io_cb) (uint32_t adapter_idx, uint32_t target_idx,
32                                                                 int status);
33
34 struct near_ndef_message;
35
36 #define NEAR_DEVICE_PRIORITY_LOW      -100
37 #define NEAR_DEVICE_PRIORITY_DEFAULT     0
38 #define NEAR_DEVICE_PRIORITY_HIGH      100
39
40 #define NEAR_DEVICE_SN_NPP       "com.android.npp"
41 #define NEAR_DEVICE_SN_SNEP      "urn:nfc:sn:snep"
42 #define NEAR_DEVICE_SN_HANDOVER  "urn:nfc:sn:handover"
43
44 struct near_device_driver {
45         int priority;
46
47         int (*listen)(uint32_t adapter_idx, near_device_io_cb cb);
48         int (*push)(uint32_t adapter_idx, uint32_t target_idx,
49                                         struct near_ndef_message *ndef,
50                                         char *service_name,
51                                         near_device_io_cb cb);
52 };
53
54 struct near_device *near_device_get_device(uint32_t adapter_idx,
55                                                 uint32_t target_idx);
56 int near_device_add_data(uint32_t adapter_idx, uint32_t target_idx,
57                         uint8_t *data, size_t data_length);
58 int near_device_add_records(struct near_device *device, GList *records,
59                                 near_device_io_cb cb, int status);
60 int near_device_driver_register(struct near_device_driver *driver);
61 void near_device_driver_unregister(struct near_device_driver *driver);
62
63 #endif