Introducing typetags to support WiFi creds over serial#25
Conversation
produceconsumerobot
left a comment
There was a problem hiding this comment.
@nitin710 code review complete
| #include <Arduino.h> | ||
| #endif | ||
|
|
||
| class EmotiBitSerial |
There was a problem hiding this comment.
We should have the serial messages 'R', 'C', 'D' 'F', etc defined here so that there is a single source of truth instead of magic chars everywhere.
There was a problem hiding this comment.
Added Inputs
struct Inputs
{
static const char RESET = 'R';
static const char CONFIG_UPDATE = 'C';
static const char DEBUG_MODE = 'D';
static const char FACTORY_TEST_MODE = 'F';
};
| return true; | ||
| } | ||
|
|
||
| void EmotiBitSerial::sendMessage(String typeTag, String payload) |
There was a problem hiding this comment.
is EmotiBitSerial::sendMessage essentially just a replica of EmotiBitFactoryTest::sendMessage ?
There was a problem hiding this comment.
Perhaps we should use the EmotiBitFactoryTest::sendMessage code here and call EmotiBitSerial::sendMessage from EmotiBitFactoryTest::sendMessage?
There was a problem hiding this comment.
Moved guts of EmotiBitFactoryTest::sendMessage into EmotiBitSerial::sendMessage and made a pass through call in EmotiBitFactoryTest::sendMessage
| static void sendMessage(String typeTag, String payload = ""); | ||
|
|
||
| #endif | ||
| static const char MSG_START_CHAR = '@'; |
There was a problem hiding this comment.
MSG_START_CHAR and other vars are now a multiple source of truth with EmotiBitFactoryTest vars of same name
There was a problem hiding this comment.
Removed it from Factory test. It now only exists in EmotiBitSerial
src/EmotiBitSerial.cpp
Outdated
| { | ||
| int payloadDelimiterIndex = message.indexOf(PAYLOAD_DELIMITER); | ||
| int messageDelimiterIndex = message.indexOf(MSG_TERM_CHAR); | ||
| if (payloadDelimiterIndex > 0 && messageDelimiterIndex > 0) |
There was a problem hiding this comment.
Perhaps we should also check that messageDelimiterIndex > payloadDelimiterIndex +1?
or +2 if we don't want to accept an empty string payload
There was a problem hiding this comment.
I was iffy about implementing the +2 (for the empty string test). But, after thinking about it, I added it.
Reason being, if we have 1 space, it can be unintentional, but if its more than a space, the user probably meant it.
So I added both checks.
| #include "EmotiBitSerial.h" | ||
|
|
||
| #ifdef ARDUINO | ||
| bool EmotiBitSerial::parseSerialMessage(String message, String &typetag, String &payload) |
There was a problem hiding this comment.
Shouldn't this function be able to handle typetag-only messages with no payload, e.g. like many messages processed in EmotiBit::processFactoryTestMessages()?
There was a problem hiding this comment.
Added that functionality.
We can now enter only Typetags
|
Made changes as per review. |
Description
EmotiBitSerialclassRequirements
Issues Referenced
Documentation update
None
Notes for Reviewer
Testing
Checklist to allow merge
masterDIGITAL_WRITE_DEBUG= false (if set true while testing)Screenshots: