Permalink
Browse files

mgmt: Add support for discovering event

  • Loading branch information...
Johan Hedberg
Johan Hedberg committed Mar 31, 2011
1 parent 421efd4 commit 6f7add54356eb162223d1a096dd1945bf32366f3
Showing with 49 additions and 0 deletions.
  1. +8 −0 doc/mgmt-api.txt
  2. +2 −0 lib/mgmt.h
  3. +39 −0 plugins/mgmtops.c
View
@@ -525,3 +525,11 @@ Event Code 0x0013
Controller Index <controller id>
Event Parameters Address (6 Octets)
Name (249 Octets)
+
+
+Discovering Event
+=================
+
+Event Code 0x00014
+Controller Index <controller id>
+Event Parameters Discovering (1 Octet)
View
@@ -291,3 +291,5 @@ struct mgmt_ev_remote_name {
bdaddr_t bdaddr;
uint8_t name[MGMT_MAX_NAME_LENGTH];
} __packed;
+
+#define MGMT_EV_DISCOVERING 0x0014
View
@@ -1316,6 +1316,42 @@ static void mgmt_remote_name(int sk, uint16_t index, void *buf, size_t len)
btd_event_remote_name(&info->bdaddr, &ev->bdaddr, 0, (char *) ev->name);
}
+static void mgmt_discovering(int sk, uint16_t index, void *buf, size_t len)
+{
+ struct mgmt_mode *ev = buf;
+ struct controller_info *info;
+ struct btd_adapter *adapter;
+ int state;
+
+ if (len < sizeof(*ev)) {
+ error("Too small discovering event");
+ return;
+ }
+
+ DBG("Controller %u discovering %u", index, ev->val);
+
+ if (index > max_index) {
+ error("Unexpected index %u in discovering event", index);
+ return;
+ }
+
+ info = &controllers[index];
+
+ adapter = manager_find_adapter(&info->bdaddr);
+ if (!adapter)
+ return;
+
+ state = adapter_get_state(adapter);
+
+ if (ev->val) {
+ if (!(state & (STATE_STDINQ | STATE_LE_SCAN | STATE_PINQ)))
+ state |= STATE_PINQ;
+ } else
+ state &= ~(STATE_STDINQ | STATE_PINQ);
+
+ adapter_set_state(adapter, state);
+}
+
static gboolean mgmt_event(GIOChannel *io, GIOCondition cond, gpointer user_data)
{
char buf[MGMT_BUF_SIZE];
@@ -1417,6 +1453,9 @@ static gboolean mgmt_event(GIOChannel *io, GIOCondition cond, gpointer user_data
case MGMT_EV_REMOTE_NAME:
mgmt_remote_name(sk, index, buf + MGMT_HDR_SIZE, len);
break;
+ case MGMT_EV_DISCOVERING:
+ mgmt_discovering(sk, index, buf + MGMT_HDR_SIZE, len);
+ break;
default:
error("Unknown Management opcode %u (index %u)", opcode, index);
break;

0 comments on commit 6f7add5

Please sign in to comment.