Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp22288ybx; Tue, 29 Oct 2019 13:42:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwEeQMzQF/7FVVpIuJo6jgbSOy8nUppCAZmkn6zDdBoOrlYylKbhqsPl0RQsB7k6aeALb0 X-Received: by 2002:a17:906:9391:: with SMTP id l17mr5334794ejx.315.1572381721654; Tue, 29 Oct 2019 13:42:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572381721; cv=none; d=google.com; s=arc-20160816; b=IQOr7lKMHF3XuwWI1qUufpaSfPVDUQKkrb0jbpz7FANoJi+slwI4gc6zt4e4MBy4rq CeDfkuftijBbcRRtUcebeSJLAm+2ZV779SNrSlhoIQBpesseGBzOIvOG4BmDZF/HEdO1 jtqocacxfDT0coeHi5ORPTD/ZjpwXkO1PZl2xysM9Pap9NY0N+bD2x7D3yzfDrnCJXsP 66dnILSnPA8ZbRMmIbdUANsazhnAZOZJOjqaO4847F4awIll6EAVlVXH5JTgwjz7hEO3 MeooS4UofuVz89nrHD4PyeCrRWU/GLsEs0D1qs6at48hcmlDQzD2TKezHcGxKY622UKC ZYuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=C6gqLv31TMAvmpzqJkN4Y0UmPqhuduOE568AKf9acdU=; b=dUzHbn0AdIzFeqnIqcAKklp9/F02TpihDOGlZp2EYw9MGNKisQrl3zDrH8cqC4UlVQ F88hZcCUOTTRW1ErjNFGpdR71DKCLKZ9nuom6YSIX+eMpZLQBemjEOci8T7+/XVNN0pU Xx3+qTPVFuu1sC6ZdunI9HKEccnqhiKo0bxQuto5DNlHtPm/kKnG0l1G7RpF4q2vI26x rH89DW2k0orldM+BFPjh/8rraFZ9Phwot32CzELXVbEg1qxSrMJZESLyljH9HcWnkTU7 6lwYtXtaZhBUx1FGOzBwxQO0drypjyJFDY0kYb4lKY2QOFptqAsOxoKeZPRjJQyb8HOx 0Ypw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r5si7808859eja.353.2019.10.29.13.41.37; Tue, 29 Oct 2019 13:42:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727417AbfJ2Uk5 (ORCPT + 99 others); Tue, 29 Oct 2019 16:40:57 -0400 Received: from mga01.intel.com ([192.55.52.88]:15193 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725840AbfJ2Uk5 (ORCPT ); Tue, 29 Oct 2019 16:40:57 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Oct 2019 13:40:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,245,1569308400"; d="scan'208";a="401277155" Received: from ingas-nuc1.sea.intel.com ([10.255.229.102]) by fmsmga006.fm.intel.com with ESMTP; 29 Oct 2019 13:40:56 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ 01/10] tools/mesh: Remove extra dependencies from agent.c Date: Tue, 29 Oct 2019 13:40:45 -0700 Message-Id: <20191029204054.30599-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191029204054.30599-1-inga.stotland@intel.com> References: <20191029204054.30599-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This removes dependency on glib and mesh/util.c. Also, fixes few style glitches. --- tools/mesh/agent.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/tools/mesh/agent.c b/tools/mesh/agent.c index 08e498541..0ec76f3b7 100644 --- a/tools/mesh/agent.c +++ b/tools/mesh/agent.c @@ -30,12 +30,9 @@ #include #include -#include - #include #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: -- 2.21.0