emulator: Add handling for monitor server instance

This commit is contained in:
Marcel Holtmann 2012-11-27 10:26:23 +01:00
parent 58f8c75c0b
commit b823e9e960
3 changed files with 12 additions and 0 deletions

View File

@ -65,6 +65,7 @@ int main(int argc, char *argv[])
struct server *server1;
struct server *server2;
struct server *server3;
struct server *server4;
sigset_t mask;
mainloop_init();
@ -112,5 +113,9 @@ int main(int argc, char *argv[])
if (!server3)
fprintf(stderr, "Failed to open LE server channel\n");
server4 = server_open_unix(SERVER_TYPE_MONITOR, "/tmp/bt-server-mon");
if (!server4)
fprintf(stderr, "Failed to open monitor server channel\n");
return mainloop_run();
}

View File

@ -117,6 +117,9 @@ again:
return;
}
if (!client->btdev)
return;
count = client->pkt_offset + len;
while (count > 0) {
@ -223,6 +226,8 @@ static void server_accept_callback(int fd, uint32_t events, void *user_data)
case SERVER_TYPE_AMP:
type = BTDEV_TYPE_AMP;
break;
case SERVER_TYPE_MONITOR:
goto done;
}
client->btdev = btdev_create(type, server->id);
@ -234,6 +239,7 @@ static void server_accept_callback(int fd, uint32_t events, void *user_data)
btdev_set_send_handler(client->btdev, client_write_callback, client);
done:
if (mainloop_add_fd(client->fd, EPOLLIN, client_read_callback,
client, client_destroy) < 0) {
btdev_destroy(client->btdev);

View File

@ -28,6 +28,7 @@ enum server_type {
SERVER_TYPE_BREDR,
SERVER_TYPE_LE,
SERVER_TYPE_AMP,
SERVER_TYPE_MONITOR,
};
struct server;