DELEMENT(BTHH_ERR_HDL),
ENDMAP
+static char connected_device_addr[MAX_ADDR_STR_LEN];
/*
* Callback for connection state change.
* state will have one of the values from bthh_connection_state_t
haltest_info("%s: bd_addr=%s connection_state=%s\n", __func__,
bt_bdaddr_t2str(bd_addr, addr),
bthh_connection_state_t2str(state));
+ if (state == BTHH_CONN_STATE_CONNECTED)
+ strcpy(connected_device_addr, addr);
}
/*
{
char addr[MAX_ADDR_STR_LEN];
- /* TODO: print actual hid_info */
+ /* TODO: bluedroid does not seem to ever call this callback */
haltest_info("%s: bd_addr=%s\n", __func__,
bt_bdaddr_t2str(bd_addr, addr));
}
/* connect */
+static void connect_c(int argc, const const char **argv,
+ enum_func *penum_func, void **puser)
+{
+ if (argc == 3) {
+ *puser = (void *) connected_device_addr;
+ *penum_func = enum_one_string;
+ }
+}
+
static void connect_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
/* disconnect */
+/* Same completion as connect_c */
+#define disconnect_c connect_c
+
static void disconnect_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
/* virtual_unplug */
+/* Same completion as connect_c */
+#define virtual_unplug_c connect_c
+
static void virtual_unplug_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
RETURN_IF_NULL(if_hh);
VERIFY_ADDR_ARG(2, &addr);
- /* TODO: not implemented yet */
+ /* TODO: set_info does not seem to be called anywhere */
EXEC(if_hh->set_info, &addr, hid_info);
}
/* get_protocol */
+static void get_protocol_c(int argc, const const char **argv,
+ enum_func *penum_func, void **puser)
+{
+ if (argc == 3) {
+ *puser = connected_device_addr;
+ *penum_func = enum_one_string;
+ } else if (argc == 4) {
+ *puser = TYPE_ENUM(bthh_protocol_mode_t);
+ *penum_func = enum_defines;
+ }
+}
+
static void get_protocol_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
/* set_protocol */
+/* Same completion as get_protocol_c */
+#define set_protocol_c get_protocol_c
+
static void set_protocol_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
/* get_report */
+static void get_report_c(int argc, const const char **argv,
+ enum_func *penum_func, void **puser)
+{
+ if (argc == 3) {
+ *puser = connected_device_addr;
+ *penum_func = enum_one_string;
+ } else if (argc == 4) {
+ *puser = TYPE_ENUM(bthh_report_type_t);
+ *penum_func = enum_defines;
+ }
+}
+
static void get_report_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
/* set_report */
+static void set_report_c(int argc, const const char **argv,
+ enum_func *penum_func, void **puser)
+{
+ if (argc == 3) {
+ *puser = connected_device_addr;
+ *penum_func = enum_one_string;
+ } else if (argc == 4) {
+ *puser = TYPE_ENUM(bthh_report_type_t);
+ *penum_func = enum_defines;
+ }
+}
+
static void set_report_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
/* send_data */
+static void send_data_c(int argc, const const char **argv,
+ enum_func *penum_func, void **puser)
+{
+ if (argc == 3) {
+ *puser = connected_device_addr;
+ *penum_func = enum_one_string;
+ }
+}
+
static void send_data_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
/* Methods available in bthh_interface_t */
static struct method methods[] = {
STD_METHOD(init),
- STD_METHOD(connect),
- STD_METHOD(disconnect),
- STD_METHOD(virtual_unplug),
+ STD_METHODCH(connect, "<addr>"),
+ STD_METHODCH(disconnect, "<addr>"),
+ STD_METHODCH(virtual_unplug, "<addr>"),
STD_METHOD(set_info),
- STD_METHOD(get_protocol),
- STD_METHOD(set_protocol),
- STD_METHOD(get_report),
- STD_METHOD(set_report),
- STD_METHOD(send_data),
+ STD_METHODCH(get_protocol, "<addr> <mode>"),
+ STD_METHODCH(set_protocol, "<addr> <mode>"),
+ STD_METHODCH(get_report, "<addr> <type> <report_id> <size>"),
+ STD_METHODCH(set_report, "<addr> <type> <hex_encoded_report>"),
+ STD_METHODCH(send_data, "<addr> <hex_encoded_data>"),
STD_METHOD(cleanup),
END_METHOD
};