diff --git a/proximity/reporter.c b/proximity/reporter.c
index 94c930b..1e0a5f5 100644
--- a/proximity/reporter.c
+++ b/proximity/reporter.c
#include "reporter.h"
#define LINK_LOSS_SVC_UUID 0x1803
+#define TX_POWER_SVC_UUID 0x1804
#define ALERT_LEVEL_CHR_UUID 0x2A06
+#define POWER_LEVEL_CHR_UUID 0x2A07
enum {
NO_ALERT = 0x00,
HIGH_ALERT = 0x02,
};
+static uint16_t tx_power_handle;
+
static void register_link_loss(void)
{
uint16_t start_handle, h;
g_assert(h - start_handle == svc_size);
}
+static void register_tx_power(void)
+{
+ uint16_t start_handle, h;
+ const int svc_size = 4;
+ uint8_t atval[256];
+ bt_uuid_t uuid;
+
+ start_handle = attrib_db_find_avail(svc_size);
+ if (start_handle == 0) {
+ error("Not enough free handles to register service");
+ return;
+ }
+
+ DBG("start_handle=0x%04x", start_handle);
+
+ h = start_handle;
+
+ /* Primary service definition */
+ bt_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
+ att_put_u16(TX_POWER_SVC_UUID, &atval[0]);
+ attrib_db_add(h++, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 2);
+
+ /* Power level characteristic */
+ bt_uuid16_create(&uuid, GATT_CHARAC_UUID);
+ atval[0] = ATT_CHAR_PROPER_READ | ATT_CHAR_PROPER_NOTIFY;
+ att_put_u16(h + 1, &atval[1]);
+ att_put_u16(POWER_LEVEL_CHR_UUID, &atval[3]);
+ attrib_db_add(h++, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 5);
+
+ /* Power level value */
+ bt_uuid16_create(&uuid, POWER_LEVEL_CHR_UUID);
+ att_put_u8(0x00, &atval[0]);
+ tx_power_handle = h;
+ attrib_db_add(h++, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 1);
+
+ /* Client characteristic configuration */
+ bt_uuid16_create(&uuid, GATT_CLIENT_CHARAC_CFG_UUID);
+ atval[0] = 0x00;
+ atval[1] = 0x00;
+ attrib_db_add(h++, &uuid, ATT_NONE, ATT_NONE, atval, 2);
+
+ g_assert(h - start_handle == svc_size);
+}
+
int reporter_init(void)
{
/*
DBG("Proximity Reporter");
register_link_loss();
+ register_tx_power();
return 0;
}