mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-16 08:44:38 +08:00
tools/mesh: Remove extra dependencies from agent.c
This removes dependency on glib and mesh/util.c. Also, fixes few style glitches.
This commit is contained in:
parent
05e7b8ffe4
commit
2777515a79
@ -30,12 +30,9 @@
|
||||
#include <stdbool.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <lib/bluetooth.h>
|
||||
|
||||
#include "src/shared/shell.h"
|
||||
#include "tools/mesh/util.h"
|
||||
#include "tools/mesh/agent.h"
|
||||
|
||||
struct input_request {
|
||||
@ -63,6 +60,22 @@ static void reset_input_request(void)
|
||||
pending_request.user_data = NULL;
|
||||
}
|
||||
|
||||
static bool str2hex(const char *str, uint16_t in_len, uint8_t *out,
|
||||
uint16_t out_len)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
if (in_len < out_len * 2)
|
||||
return false;
|
||||
|
||||
for (i = 0; i < out_len; i++) {
|
||||
if (sscanf(&str[i * 2], "%02hhx", &out[i]) != 1)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void response_hexadecimal(const char *input, void *user_data)
|
||||
{
|
||||
uint8_t buf[MAX_HEXADECIMAL_OOB_LEN];
|
||||
@ -111,8 +124,8 @@ static bool request_hexadecimal(uint16_t len)
|
||||
return false;
|
||||
|
||||
bt_shell_printf("Request hexadecimal key (hex %d octets)\n", len);
|
||||
bt_shell_prompt_input("mesh", "Enter key (hex number):", response_hexadecimal,
|
||||
NULL);
|
||||
bt_shell_prompt_input("mesh", "Enter key (hex number):",
|
||||
response_hexadecimal, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -130,7 +143,8 @@ static uint32_t power_ten(uint8_t power)
|
||||
static bool request_decimal(uint16_t len)
|
||||
{
|
||||
bt_shell_printf("Request decimal key (0 - %d)\n", power_ten(len) - 1);
|
||||
bt_shell_prompt_input("mesh", "Enter Numeric key:", response_decimal, NULL);
|
||||
bt_shell_prompt_input("mesh-agent", "Enter Numeric key:",
|
||||
response_decimal, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -141,8 +155,8 @@ static bool request_ascii(uint16_t len)
|
||||
return false;
|
||||
|
||||
bt_shell_printf("Request ASCII key (max characters %d)\n", len);
|
||||
bt_shell_prompt_input("mesh", "Enter key (ascii string):", response_ascii,
|
||||
NULL);
|
||||
bt_shell_prompt_input("mesh", "Enter key (ascii string):",
|
||||
response_ascii, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -153,7 +167,7 @@ bool agent_input_request(oob_type_t type, uint16_t max_len, agent_input_cb cb,
|
||||
bool result;
|
||||
|
||||
if (pending_request.type != NONE)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
switch (type) {
|
||||
case HEXADECIMAL:
|
||||
|
Loading…
Reference in New Issue
Block a user