mqtt: string views in API and internal callbacks

* stateless callbacks for mqttRegister. no module uses the lambda / std
  func with captures or otherwise, so it is kind of pointless to have it
* make sure we know topic and payload length at all invocations and
  not constantly trying to re-parse the same string over and over again
* clean-up api related to string parsing and make sure we allow
  stringview as input
* clean-up id / unsigned number parsing to work with views instead of
  using a generic strto{,u}l; sometimes this works, sometimes doesn't.
  as noticed previously with IR implementation, it *will* parse until
  the '\0' is found in the input and we can't interpret parts of the
  string without doing a copy for the strtoul
* fixing additional bugs caught in ifan, leds, sensors and lights that
  were causing build failures. plus, more range-based parsing code for
  the same reason as described above
This commit is contained in:
Maxim Prokhorov
2022-10-20 23:42:46 +03:00
parent 0970269033
commit a11942fd7b
40 changed files with 1077 additions and 912 deletions

View File

@@ -773,7 +773,7 @@ namespace terminal {
void button(::terminal::CommandContext&& ctx) {
if (ctx.argv.size() == 2) {
size_t id;
if (!tryParseId(ctx.argv[1], buttonCount, id)) {
if (!tryParseId(ctx.argv[1], buttonCount(), id)) {
terminalError(ctx, F("Invalid button ID"));
return;
}