EmotiBit / EmotiBit_FeatherWing

Firmware to run Emotibit with Adafruit feather M0 WiFi and Feather ESP32
MIT License
19 stars 8 forks source link

Feat WiFi creds over serial #283

Closed nitin710 closed 3 months ago

nitin710 commented 10 months ago

Description

Requirements

Issues Referenced

Documentation update

Notes for Reviewer

Successfully entered config file edit mode.
@FV,1.9.0~
Options available in this mode:
1. Add a wifi credential. Usage: @WA,{"ssid":"SSSS","password" : "PPPP"}~
  - Replace SSSS with network name and PPPP with network password
2. List wifi credentials. Usage: @LS,~
3. Delete Wifi Credential. Usage: @WD,<credential number>~
  - use List option to get a wifi list. Then use the number in the list to delete a credential

>>>>>>>>>>>[serial input] @WA,{"ssid":"emoti-net","password" : "emotibit-rocks"}~
typetag: WA
payload: {"ssid":"emoti-net","password" : "emotibit-rocks"}
Parsed output: 
ssid: emoti-net
password: emotibit-rocks

config file exists. Appending to file.
@AK,WA~
Updated file contents:
{
  "WifiCredentials": [
    {
      "ssid": "emoti-net",
      "password": "emotibit-rocks"
    }
  ]
}

>>>>>>>>>>>[serial input] @LS,~
typetag: LS
payload: 
##################################
config file credetials:
0. emoti-net : emotibit-rocks
1. SSSS : PPPP
##################################
@AK,LS~

>>>>>>>>>>>[serial input] @WD,1~
typetag: WD
payload: 1
Deleting entry: 1. SSSS
@AK,WD~

Testing

Results

Test Feather ESP32 Feather M0
Add credentials when config.txt does not exist ✔️ ✔️
Add credentials when config.txt fails parsing ✔️
Add cred, config exists, can be parsed ✔️ ✔️
delete valid option ✔️ ✔️
delete invalid option ✔️ ✔️
add enterprise cred ✔️ ✔️

Feature Tests

Steps to test

Shared files

Checklist to allow merge

nitin710 commented 9 months ago

WIP

nitin710 commented 9 months ago

Moving this provision to a different class.

Current functions getting affected

{
  bool setupSdCard(int chipSelPin, bool loadConfig);
  bool loadConfigFile(String filename); // need to pass wifi object handle
  bool writeSdCardMessages(File &dataFile, String &stringToWrite);
  void printConfigInfo(File &file, String &stringToWrite)
  void processWiFiConfigInputs(String &configFileName);
}

New class

class UserAccessibleStorage
{
  bool setup(enum hwVersion, string sku); 
  bool loadConfigFile(String filename, EmotiBitWiFi &emotibitWifi); 
  bool writeToStorage(File &dataFile, String &stringToWrite);
  void writeConfigInfo(File &file, String &stringToWrite);
  void processWiFiConfigInput(String &configFileName);
  bool createDataFile(String filename);
}
nitin710 commented 9 months ago

Discussion points

nitin710 commented 9 months ago

possible stored data types

Organizing into categories

Summary

Next steps

nitin710 commented 3 months ago

@produceconsumerobot made the requested changes. Ready for review. (long list of changes.)