xref: /nrf52832-nimble/packages/NimBLE-latest/apps/btshell/src/cmd.h (revision 042d53a763ad75cb1465103098bb88c245d95138)
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements.  See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership.  The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License.  You may obtain a copy of the License at
9  *
10  *  http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied.  See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 #ifndef CMD_H
21 #define CMD_H
22 
23 #include <inttypes.h>
24 #include "host/ble_uuid.h"
25 
26 struct kv_pair {
27     char *key;
28     int val;
29 };
30 
31 const struct kv_pair *parse_kv_find(const struct kv_pair *kvs, char *name);
32 int parse_arg_find_idx(const char *key);
33 char *parse_arg_extract(const char *key);
34 long parse_arg_long_bounds(char *name, long min, long max, int *out_status);
35 long parse_arg_long_bounds_dflt(char *name, long min, long max,
36                                    long dflt, int *out_status);
37 uint64_t parse_arg_uint64_bounds(char *name, uint64_t min,
38                                  uint64_t max, int *out_status);
39 long parse_arg_long(char *name, int *staus);
40 uint8_t parse_arg_bool(char *name, int *status);
41 uint8_t parse_arg_bool_dflt(char *name, uint8_t dflt, int *out_status);
42 uint8_t parse_arg_uint8(char *name, int *status);
43 uint8_t parse_arg_uint8_dflt(char *name, uint8_t dflt, int *out_status);
44 uint16_t parse_arg_uint16(char *name, int *status);
45 uint16_t parse_arg_uint16_dflt(char *name, uint16_t dflt, int *out_status);
46 uint32_t parse_arg_uint32(char *name, int *out_status);
47 uint32_t parse_arg_uint32_dflt(char *name, uint32_t dflt, int *out_status);
48 uint64_t parse_arg_uint64(char *name, int *out_status);
49 int parse_arg_kv(char *name, const struct kv_pair *kvs, int *out_status);
50 int parse_arg_kv_dflt(char *name, const struct kv_pair *kvs, int def_val,
51                          int *out_status);
52 int parse_arg_byte_stream(char *name, int max_len, uint8_t *dst, int *out_len);
53 int parse_arg_byte_stream_exact_length(char *name, uint8_t *dst, int len);
54 int parse_arg_mac(char *name, uint8_t *dst);
55 int parse_arg_uuid(char *name, ble_uuid_any_t *uuid);
56 int parse_arg_all(int argc, char **argv);
57 int parse_eddystone_url(char *full_url, uint8_t *out_scheme, char *out_body,
58                         uint8_t *out_body_len, uint8_t *out_suffix);
59 int cmd_parse_conn_start_end(uint16_t *out_conn, uint16_t *out_start,
60                              uint16_t *out_end);
61 
62 void cmd_init(void);
63 
64 #endif
65