-
Notifications
You must be signed in to change notification settings - Fork 0
Description
In my opinion, regex should not be used as a means to represent the protocol. First and foremost regex is genuinely a pain to decifer and to maintain. As well, regex is most powerful when using it to parse unvalidated input or searching unstructured data. For example, when a user enters something like an email address in a text box, regex is VERY good for ensuring it is of the correct form. When searching through files on your filesystem or text in a text file regex is as well extremely powerful there to help with your search. It is not a tool for ensuring a protocol payload is of the right form.
To make it easy for even MCU to parse, it can be newline or like CSV. The protocol message could then be of the form:
a
1
# this would be an empty line to accommodate the space for an ID
Your message here
Or CSV:
a,1,,My hair's on fire
a,1,18afbc,shelving message
That presents a MUCH more structured layout for the protocol.