diff --git a/src/btstack_util.c b/src/btstack_util.c index 3c7aaca22..c6a8d19fb 100644 --- a/src/btstack_util.c +++ b/src/btstack_util.c @@ -312,3 +312,14 @@ int sscanf_bd_addr(const char * addr_string, bd_addr_t addr){ } return result; } + +uint32_t btstack_atoi(const char *str){ + uint32_t val = 0; + while (1){ + char chr = *str; + if (!chr || chr < '0' || chr > '9') + return val; + val = (val * 10) + (chr - '0'); + str++; + } +} \ No newline at end of file diff --git a/src/btstack_util.h b/src/btstack_util.h index a177aa02d..7ab067cc8 100644 --- a/src/btstack_util.h +++ b/src/btstack_util.h @@ -216,6 +216,14 @@ void uuid_add_bluetooth_prefix(uint8_t * uuid128, uint32_t short_uuid); */ int uuid_has_bluetooth_prefix(uint8_t * uuid128); +/** + * @brief Parse unsigned number + * @param str to parse + * @return value + */ +uint32_t btstack_atoi(const char *str); + + #if defined __cplusplus } #endif