mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-17 01:04:40 +08:00
emulator: Create support for enabling AMP controllers
This commit is contained in:
parent
2c33d253f5
commit
9f3814a34f
@ -45,7 +45,8 @@ static void signal_callback(int signum, void *user_data)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct vhci *vhci;
|
||||
struct server *server;
|
||||
struct server *server1;
|
||||
struct server *server2;
|
||||
sigset_t mask;
|
||||
|
||||
mainloop_init();
|
||||
@ -56,13 +57,17 @@ int main(int argc, char *argv[])
|
||||
|
||||
mainloop_set_signal(&mask, signal_callback, NULL, NULL);
|
||||
|
||||
vhci = vhci_open(VHCI_TYPE_BREDR, 0x23);
|
||||
vhci = vhci_open(VHCI_TYPE_BREDR);
|
||||
if (!vhci)
|
||||
fprintf(stderr, "Failed to open Virtual HCI device\n");
|
||||
|
||||
server = server_open_unix("/tmp/bt-server-bredr", 0x42);
|
||||
if (!server)
|
||||
fprintf(stderr, "Failed to open server channel\n");
|
||||
server1 = server_open_unix(SERVER_TYPE_BREDR, "/tmp/bt-server-bredr");
|
||||
if (!server1)
|
||||
fprintf(stderr, "Failed to open BR/EDR server channel\n");
|
||||
|
||||
server2 = server_open_unix(SERVER_TYPE_BREDR, "/tmp/bt-server-amp");
|
||||
if (!server2)
|
||||
fprintf(stderr, "Failed to open AMP server channel\n");
|
||||
|
||||
return mainloop_run();
|
||||
}
|
||||
|
@ -46,7 +46,10 @@
|
||||
#include "btdev.h"
|
||||
#include "server.h"
|
||||
|
||||
#define uninitialized_var(x) x = x
|
||||
|
||||
struct server {
|
||||
enum server_type type;
|
||||
uint16_t id;
|
||||
int fd;
|
||||
};
|
||||
@ -189,6 +192,7 @@ static void server_accept_callback(int fd, uint32_t events, void *user_data)
|
||||
{
|
||||
struct server *server = user_data;
|
||||
struct client *client;
|
||||
enum btdev_type uninitialized_var(type);
|
||||
|
||||
if (events & (EPOLLERR | EPOLLHUP))
|
||||
return;
|
||||
@ -205,7 +209,16 @@ static void server_accept_callback(int fd, uint32_t events, void *user_data)
|
||||
return;
|
||||
}
|
||||
|
||||
client->btdev = btdev_create(BTDEV_TYPE_BREDR, server->id);
|
||||
switch (server->type) {
|
||||
case SERVER_TYPE_BREDR:
|
||||
type = BTDEV_TYPE_BREDR;
|
||||
break;
|
||||
case SERVER_TYPE_AMP:
|
||||
type = BTDEV_TYPE_AMP;
|
||||
break;
|
||||
}
|
||||
|
||||
client->btdev = btdev_create(type, server->id);
|
||||
if (!client->btdev) {
|
||||
close(client->fd);
|
||||
free(client);
|
||||
@ -254,7 +267,7 @@ static int open_unix(const char *path)
|
||||
return fd;
|
||||
}
|
||||
|
||||
struct server *server_open_unix(const char *path, uint16_t id)
|
||||
struct server *server_open_unix(enum server_type type, const char *path)
|
||||
{
|
||||
struct server *server;
|
||||
|
||||
@ -263,7 +276,8 @@ struct server *server_open_unix(const char *path, uint16_t id)
|
||||
return NULL;
|
||||
|
||||
memset(server, 0, sizeof(*server));
|
||||
server->id = id;
|
||||
server->type = type;
|
||||
server->id = 0x42;
|
||||
|
||||
server->fd = open_unix(path);
|
||||
if (server->fd < 0) {
|
||||
@ -315,7 +329,7 @@ static int open_tcp(void)
|
||||
return fd;
|
||||
}
|
||||
|
||||
struct server *server_open_tcp(uint16_t id)
|
||||
struct server *server_open_tcp(enum server_type type)
|
||||
{
|
||||
struct server *server;
|
||||
|
||||
@ -324,7 +338,8 @@ struct server *server_open_tcp(uint16_t id)
|
||||
return server;
|
||||
|
||||
memset(server, 0, sizeof(*server));
|
||||
server->id = id;
|
||||
server->type = type;
|
||||
server->id = 0x43;
|
||||
|
||||
server->fd = open_tcp();
|
||||
if (server->fd < 0) {
|
||||
|
@ -24,8 +24,13 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum server_type {
|
||||
SERVER_TYPE_BREDR,
|
||||
SERVER_TYPE_AMP,
|
||||
};
|
||||
|
||||
struct server;
|
||||
|
||||
struct server *server_open_unix(const char *path, uint16_t id);
|
||||
struct server *server_open_tcp(uint16_t id);
|
||||
struct server *server_open_unix(enum server_type type, const char *path);
|
||||
struct server *server_open_tcp(enum server_type type);
|
||||
void server_close(struct server *server);
|
||||
|
@ -80,7 +80,7 @@ static void vhci_read_callback(int fd, uint32_t events, void *user_data)
|
||||
btdev_receive_h4(vhci->btdev, buf, len);
|
||||
}
|
||||
|
||||
struct vhci *vhci_open(enum vhci_type type, uint16_t id)
|
||||
struct vhci *vhci_open(enum vhci_type type)
|
||||
{
|
||||
struct vhci *vhci;
|
||||
|
||||
@ -104,7 +104,7 @@ struct vhci *vhci_open(enum vhci_type type, uint16_t id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vhci->btdev = btdev_create(BTDEV_TYPE_BREDR, id);
|
||||
vhci->btdev = btdev_create(BTDEV_TYPE_BREDR, 0x23);
|
||||
if (!vhci->btdev) {
|
||||
close(vhci->fd);
|
||||
free(vhci);
|
||||
|
@ -25,11 +25,11 @@
|
||||
#include <stdint.h>
|
||||
|
||||
enum vhci_type {
|
||||
VHCI_TYPE_BREDR = 0,
|
||||
VHCI_TYPE_AMP = 1,
|
||||
VHCI_TYPE_BREDR,
|
||||
VHCI_TYPE_AMP,
|
||||
};
|
||||
|
||||
struct vhci;
|
||||
|
||||
struct vhci *vhci_open(enum vhci_type type, uint16_t id);
|
||||
struct vhci *vhci_open(enum vhci_type type);
|
||||
void vhci_close(struct vhci *vhci);
|
||||
|
Loading…
Reference in New Issue
Block a user