You can see gatt-example practice, or defined profiles under profile/ directory such as alert/server.c. Basically, you just have to register your service using gatt_service_add() function, following the existing code. For example :
gatt_service_add(adapter, GATT_PRIM_SVC_UUID, 0xFFFF,
/* Char 1 */
GATT_OPT_CHR_UUID16, 0xAAAA,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ, read_func_callback,
/* Char 2 Define here */
...
/* Char 3 Define here */
...
GATT_OPT_INVALID);
}
Also, I forgot the details but in order to get alert server working, you need to enable experimental (and maintainer mode?) during configuration by adding "--enable-maintainer-mode" and "--enable-experimental"
To run, run the compiled "bluetoothd" with -n and -d options to debug (also -E for enabling experimental services). You may want to reset your adapter again after running bluetoothd. And then you can connect from remote device using gatttool (also with bluetoothd running on remote device).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…