Initial GATT server example integration

Initial changes to start the GATT server example. For the server side,
attrib plugin will only register the GATT service record and add
the attributes into the attribute database.
This commit is contained in:
Claudio Takahasi 2010-07-07 18:19:07 -03:00 committed by Johan Hedberg
parent fc558ffc2a
commit b4ad35aafe
4 changed files with 80 additions and 19 deletions

View File

@ -171,7 +171,8 @@ endif
if ATTRIBPLUGIN
builtin_modules += attrib
builtin_sources += attrib/main.c attrib/manager.h attrib/manager.c \
attrib/client.h attrib/client.c
attrib/client.h attrib/client.c \
attrib/example.h attrib/example.c
endif
builtin_modules += hciops

44
attrib/example.c Normal file
View File

@ -0,0 +1,44 @@
/*
*
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "example.h"
int server_example_init(void)
{
/*
* FIXME: Add BR/EDR service record and attributes into the GATT
* database. BlueZ gatt server will be automatically enabled if
* any plugin registers at least one primary service.
*/
return 0;
}
void server_example_exit(void)
{
}

25
attrib/example.h Normal file
View File

@ -0,0 +1,25 @@
/*
*
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
int server_example_init(void);
void server_example_exit(void);

View File

@ -34,6 +34,7 @@
#include "manager.h"
#include "client.h"
#include "example.h"
#define GATT_UUID "00001801-0000-1000-8000-00805f9b34fb"
@ -87,38 +88,28 @@ static struct btd_device_driver client_driver = {
.remove = client_remove,
};
static int server_probe(struct btd_adapter *adapter)
{
return 0;
}
static void server_remove(struct btd_adapter *adapter)
{
}
static struct btd_adapter_driver attrib_server_driver = {
.name = "attribute-server",
.probe = server_probe,
.remove = server_remove,
};
int attrib_manager_init(DBusConnection *conn)
{
connection = dbus_connection_ref(conn);
attrib_client_init(connection);
btd_register_adapter_driver(&attrib_server_driver);
btd_register_device_driver(&client_driver);
return 0;
/*
* FIXME: Add config file option to allow
* enable/disable the GATT server and client.
*/
return server_example_init();
}
void attrib_manager_exit(void)
{
btd_unregister_adapter_driver(&attrib_server_driver);
btd_unregister_device_driver(&client_driver);
server_example_exit();
attrib_client_exit();
dbus_connection_unref(connection);
}