tools/mesh: Add all supported OOB methods to cfgclient
authorBrian Gix <brian.gix@intel.com>
Tue, 18 May 2021 23:35:32 +0000 (16:35 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:35 +0000 (19:08 +0530)
To support the widest range of mesh devices, we need to support any
possible capability combinations that a remote device may request.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
tools/mesh-cfgclient.c

index 12b10d8..19fd16f 100644 (file)
@@ -106,7 +106,17 @@ static struct model_info *cfgcli;
 static struct l_queue *devices;
 
 static bool prov_in_progress;
-static const char *caps[] = {"static-oob", "out-numeric", "in-numeric"};
+static const char * const caps[] = {"static-oob",
+                               "push",
+                               "twist",
+                               "blink",
+                               "beep",
+                               "vibrate",
+                               "public-oob",
+                               "out-alpha",
+                               "in-alpha",
+                               "out-numeric",
+                               "in-numeric"};
 
 static bool have_config;
 
@@ -421,7 +431,7 @@ static void agent_input_done(oob_type_t type, void *buf, uint16_t len,
        struct l_dbus_message *reply = NULL;
        struct l_dbus_message_builder *builder;
        uint32_t val_u32;
-       uint8_t oob_data[16];
+       uint8_t oob_data[64];
 
        switch (type) {
        case NONE:
@@ -437,15 +447,15 @@ static void agent_input_done(oob_type_t type, void *buf, uint16_t len,
                /* Fall Through */
 
        case HEXADECIMAL:
-               if (len > 16) {
+               if (len > sizeof(oob_data)) {
                        bt_shell_printf("Bad input length\n");
                        break;
                }
-               memset(oob_data, 0, 16);
+               memset(oob_data, 0, sizeof(oob_data));
                memcpy(oob_data, buf, len);
                reply = l_dbus_message_new_method_return(msg);
                builder = l_dbus_message_builder_new(reply);
-               append_byte_array(builder, oob_data, 16);
+               append_byte_array(builder, oob_data, len);
                l_dbus_message_builder_finalize(builder);
                l_dbus_message_builder_destroy(builder);
                break;
@@ -582,6 +592,16 @@ static struct l_dbus_message *prompt_numeric_call(struct l_dbus *dbus,
        return NULL;
 }
 
+static struct l_dbus_message *prompt_public_call(struct l_dbus *dbus,
+                                               struct l_dbus_message *msg,
+                                               void *user_data)
+{
+       l_dbus_message_ref(msg);
+       agent_input_request(HEXADECIMAL, 64, "Enter 512 bit Public Key",
+                       agent_input_done, msg);
+       return NULL;
+}
+
 static struct l_dbus_message *prompt_static_call(struct l_dbus *dbus,
                                                struct l_dbus_message *msg,
                                                void *user_data)
@@ -620,6 +640,8 @@ static void setup_agent_iface(struct l_dbus_interface *iface)
                                                "u", "s", "number", "type");
        l_dbus_interface_method(iface, "PromptStatic", 0, prompt_static_call,
                                                "ay", "s", "data", "type");
+       l_dbus_interface_method(iface, "PublicKey", 0, prompt_public_call,
+                                                       "ay", "", "data");
 }
 
 static bool register_agent(void)