Skip to content

Introducing typetags to support WiFi creds over serial#25

Merged
nitin710 merged 11 commits intomasterfrom
feat-newTagsForSd
Mar 26, 2024
Merged

Introducing typetags to support WiFi creds over serial#25
nitin710 merged 11 commits intomasterfrom
feat-newTagsForSd

Conversation

@nitin710
Copy link
Collaborator

@nitin710 nitin710 commented Sep 14, 2023

Description

  • Adds typetags to enable updating WiFi creds over serial
  • Adds EmotiBitSerial class
    • Supporting functions to send and parse messages over serial

Requirements

  • None

Issues Referenced

  • None

Documentation update

None

Notes for Reviewer

  • None

Testing

Checklist to allow merge

  • All dependent repositories used were on branch master
  • Firmware
    • Set testingMode to TestingMode::NONE
    • Set const bool DIGITAL_WRITE_DEBUG = false (if set true while testing)
    • Update version in EmotiBit.h
    • Update library.properties to the correct version (should match EmotiBit.h)
  • doxygen style comments included for new code snippets
  • Required documentation updated

Screenshots:

Copy link
Collaborator

@produceconsumerobot produceconsumerobot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nitin710 code review complete

#include <Arduino.h>
#endif

class EmotiBitSerial
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is EmotiBitSerial::sendMessage essentially just a replica of EmotiBitFactoryTest::sendMessage ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should use the EmotiBitFactoryTest::sendMessage code here and call EmotiBitSerial::sendMessage from EmotiBitFactoryTest::sendMessage?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = '@';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSG_START_CHAR and other vars are now a multiple source of truth with EmotiBitFactoryTest vars of same name

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed it from Factory test. It now only exists in EmotiBitSerial

{
int payloadDelimiterIndex = message.indexOf(PAYLOAD_DELIMITER);
int messageDelimiterIndex = message.indexOf(MSG_TERM_CHAR);
if (payloadDelimiterIndex > 0 && messageDelimiterIndex > 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should also check that messageDelimiterIndex > payloadDelimiterIndex +1?
or +2 if we don't want to accept an empty string payload

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this function be able to handle typetag-only messages with no payload, e.g. like many messages processed in EmotiBit::processFactoryTestMessages()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added that functionality.
We can now enter only Typetags

@nitin710
Copy link
Collaborator Author

Made changes as per review.
Some test results

@TT, PL~ : TEST-PASS
TT, payload : TEST-PASS
@TT, payload : TEST-PASS
@TT,~ : TEST-PASS
@TT, ~ : TEST-PASS
@TT~ : TEST-PASS
@TT,  ~ : TEST-PASS

@nitin710 nitin710 merged commit af7e2f3 into master Mar 26, 2024
@nitin710 nitin710 deleted the feat-newTagsForSd branch March 26, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants