Skip to content

Commit

Permalink
Merge pull request #24 from UCSD-E4E/cellular
Browse files Browse the repository at this point in the history
Cellular and Data storage
  • Loading branch information
ntlhui authored Feb 9, 2024
2 parents 78145c4 + 4774141 commit 49fb30e
Show file tree
Hide file tree
Showing 57 changed files with 3,730 additions and 333 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,5 @@ smartfin-fw3.cpp
target/
*.bin
nul
out/docs/application/Service Diagram.png
out/docs/fw_flow/Firmware Flowchart.png
5 changes: 3 additions & 2 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"windowsSdkVersion": "10.0.22000.0",
"compilerPath": "~\\.particle\\toolchains\\gcc-arm\\10.2.1\\bin\\arm-none-eabi-gcc.exe",
"intelliSenseMode": "windows-gcc-arm",
"cStandard": "c17",
"cppStandard": "c++17",
"cStandard": "c11",
"cppStandard": "c++11",
"configurationProvider": "particle.particle-vscode-core",
"mergeConfigurations": true,
"browse": {
Expand All @@ -26,6 +26,7 @@
"~\\.particle\\toolchains\\deviceOS\\5.3.0\\hal\\inc",
"~\\.particle\\toolchains\\deviceOS\\5.3.0\\hal\\shared",
"~\\.particle\\toolchains\\deviceOS\\5.3.0\\hal\\src\\gcc",
"~\\.particle\\toolchains\\deviceOS\\5.3.0\\hal\\src\\nRF52840\\posix",
"~\\.particle\\toolchains\\deviceOS\\5.3.0\\services\\inc",
"~\\.particle\\toolchains\\deviceOS\\5.3.0\\system",
"~\\.particle\\toolchains\\deviceOS\\5.3.0\\wiring",
Expand Down
17 changes: 13 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,20 @@
"particle.targetDevice": "",
"cmake.configureOnOpen": false,
"C_Cpp.codeAnalysis.clangTidy.enabled": false,
"C_Cpp.default.cppStandard": "c++17",
"C_Cpp.default.cStandard": "c17",
"C_Cpp.default.intelliSenseMode": "windows-gcc-arm",
"C_Cpp.intelliSenseEngine": "Tag Parser",
"C_Cpp.default.cppStandard": "c++11",
"C_Cpp.default.cStandard": "c11",
"C_Cpp.doxygen.generatedStyle": "/**",
"C_Cpp.autoAddFileAssociations": false,
"editor.rulers": [
80
],
"particle.enableVerboseLocalCompilerLogging": true,
"C_Cpp.vcFormat.space.pointerReferenceAlignment": "left",
"C_Cpp.formatting": "vcFormat",
"C_Cpp.vcFormat.newLine.scopeBracesOnSeparateLines": true,
"C_Cpp.vcFormat.newLine.beforeOpenBrace.type": "newLine",
"C_Cpp.vcFormat.newLine.beforeOpenBrace.block": "newLine",
"C_Cpp.vcFormat.indent.preserveWithinParentheses": true,
"C_Cpp.vcFormat.indent.preprocessor": "oneLeft",

}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ gps-nmea-parser | 1.2.0 | Apache 2.0 | https://github.com/particle-iot/gps-nme
tracker edge | v18 | Apache 2.0 | https://github.com/particle-iot/tracker-edge | lib/tracker-edge
SparkFun ICM | 1.2.0 | MIT | https://github.com/UCSD-E4E/SparkFun_ICM-20948_ParticleLibrary | lib/SparkFun_ICM-20948_ParticleLibrary
Max 31725 | 2019 | Apache 2.0 | https://os.mbed.com/teams/MaximIntegrated/code/MAX31725_Accurate_Temperature_Sensor//file/b4fdbbe79036/max31725.h/ | temperature/
urlsafe-b64 | 022c4cc | MIT | https://github.com/Akagi201/urlsafe-b64 | src/cellular/encoding
base85 | 9c52d27 | MIT | https://github.com/rafagafe/base85 | src/cellular/encoding



Expand Down
112 changes: 68 additions & 44 deletions docs/application.puml
Original file line number Diff line number Diff line change
@@ -1,66 +1,90 @@
' Green for modules that are complete
' Yellow for modules that are WIP
' Red for modules that are not implemented
@startuml Service Diagram
top to bottom direction

skinparam nodesep 50
skinparam ranksep 150

package "Device OS" {
[Cellular] as cellular
[I2C] as i2c
[Serial] as serial
[Filesystem] as fs
[SPI] as spi
[NVRAM] as nvram
[Cellular] as cellular #Yellow
[I2C] as i2c #Green
[Serial] as serial #Green
[Filesystem] as fs #Green
[SPI] as spi #Green
[GPIO] as gpio #Green
[EEPROM] as eeprom #Green
}


package "Application" {
[CLI] as cli
[Ride] as ride
[Charge Task] as charge_task
[Sleep Task] as sleep_task
[Location Service] as loc_service
[CLI] as cli #Green
[Ride] as ride #Red
[Charge Task] as charge_task #Green
[Sleep Task] as sleep_task #Green
[Data Upload] as upload #Red
}

package "Board Support Package" {
[Temp Sensor] as temp_sensor
[Water Sensor] as water_sensor
[GPS] as gps
[LED] as led
[ICM] as icm
[Temp Sensor] as temp_sensor #Green
[Water Sensor] as water_sensor #Green
[Location Service] as loc_service #Green
[GPS] as gps #Green
[LED] as led #Green
[ICM] as icm #Green
}
[ConIO] as conio
[Recorder] as recorder
[FLOG] as flog

ride --> temp_sensor
ride --> gps
ride --> icm
package "Application Support Package" {
[ConIO] as conio #Green
[Recorder] as recorder #Green
[FLOG] as flog #Green
[NVRAM] as nvram #Green
}

ride <-- temp_sensor
ride <-- gps
ride <-- icm
ride --> recorder
ride --> flog
ride --> water_sensor
loc_service --> gps
' ride -r-> flog
ride <-- water_sensor
loc_service -r-> gps
charge_task --> led
charge_task --> flog
' charge_task -r-> flog
sleep_task --> led
sleep_task --> nvram
sleep_task --> flog
' sleep_task -r-> flog

cli --> gps
cli --> temp_sensor
cli --> conio
cli --> flog
cli --> icm
cli --> nvram
cli --> water_sensor
cli <-- gps
cli <-- temp_sensor
cli <--> conio
' cli -r-> flog
cli <-- icm
cli <--> nvram
cli <-- water_sensor

gps --> spi
icm --> i2c
water_sensor --> i2c
temp_sensor --> i2c
conio --> serial
recorder --> fs
recorder --> cellular
recorder --> nvram
recorder --> flog
conio --> flog
gps --> flog
icm --> flog
water_sensor --> flog
temp_sensor --> flog
recorder <--> fs

water_sensor --> gpio
led --> gpio
ride --> led
nvram --> eeprom
eeprom -> fs
upload <-- recorder
upload --> cellular
upload <-- water_sensor
upload --> led
charge_task --> gpio
upload --> gpio
sleep_task <-- water_sensor
' recorder -u-> flog
' conio -u-> flog
' gps -u-> flog
' icm -u-> flog
' water_sensor -u-> flog
' temp_sensor -u-> flog
@enduml
13 changes: 13 additions & 0 deletions docs/arch.puml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ class SystemFlags_t{
bool hasCharger
bool inWater
}

class Recorder {
int init()
int hasData()
int getLastPacket(void*, size_t, char* size_t)
int popLastPacket(size_t)
void setSessionName(const char*)
int getNumFiles()
int openSession(const char* const)
int closeSession()
int putBytes(const void*, size_t)
int putData(T)
}
LocationService o-- pLocService
SystemDesc o-- SystemFlags_t
@enduml
116 changes: 62 additions & 54 deletions docs/fw_flow.puml
Original file line number Diff line number Diff line change
@@ -1,75 +1,83 @@
@startuml Firmware Flowchart
hide empty description

Sleep: D1 OFF
Sleep: DS1 Charging Status
Sleep: DS2 Water Detect Status
Sleep: Cell Modem OFF

Connect: D1 Solid Blue
Connect: DS1 Charging Status
Connect: DS2 Water Detect Status
Connect: Cell Modem ON
state DataUpload {
Connect: D1 Solid Blue
Connect: DS1 Charging Status
Connect: DS2 Water Detect Status
Connect: Cell Modem ON

Transmit: D1 Blink Blue
Transmit: DS1 Charging Status
Transmit: DS2 Water Detect Status
Transmit: Cell Modem ON
}

state Ride {
state "Deployed/No GPS" as deployed_nogps
deployed_nogps: D1 Solid White
deployed_nogps: DS1 Charging Status
deployed_nogps: DS2 Water Detect Status
deployed_nogps: Cell Modem OFF

state "Charged Complete" as charge_complete
charge_complete: D1 OFF
charge_complete: DS1 Solid Green
charge_complete: DS2 Water Detect Status
charge_complete: Cell Modem OFF
state "Deployed/GPS" as deployed_gps
deployed_gps: D1 Blink White
deployed_gps: DS1 Charging Status
deployed_gps: DS2 Water Detect Status
deployed_gps: Cell Modem OFF

state "Deployed/No GPS" as deployed_nogps
deployed_nogps: D1 Solid White
deployed_nogps: DS1 Charging Status
deployed_nogps: DS2 Water Detect Status
deployed_nogps: Cell Modem OFF
}

Transmit: D1 Blink Blue
Transmit: DS1 Charging Status
Transmit: DS2 Water Detect Status
Transmit: Cell Modem ON

Charging: D1 OFF
Charging: DS1 Blink Green
Charging: DS2 Water Detect Status
Charging: Cell Modem OFF
state ChargeTask {
state "Charged Complete" as charge_complete
charge_complete: D1 OFF
charge_complete: DS1 Solid Green
charge_complete: DS2 Water Detect Status
charge_complete: Cell Modem OFF

Charging: D1 OFF
Charging: DS1 Blink Green
Charging: DS2 Water Detect Status
Charging: Cell Modem OFF
}

state "CLI" as CLI
CLI: D1 Solid Yellow
CLI: DS1 Charging Status
CLI: DS2 Water Detect Status
CLI: Cell Modem OFF

state "Deployed/GPS" as deployed_gps
deployed_gps: D1 Blink White
deployed_gps: DS1 Charging Status
deployed_gps: DS2 Water Detect Status
deployed_gps: Cell Modem OFF

state choice1 <<choice>>
state choice2 <<choice>>
[*] --> Setup
Setup --> Sleep
Sleep --> choice1 : USB Connect
Sleep --> deployed_nogps : Water Detected
choice1 --> Connect : Data to transmit: Yes
choice1 --> Charging : Data to transmit: No
deployed_nogps --> Sleep : Low Battery
deployed_nogps --> choice2 : Out of water
deployed_nogps --> deployed_gps : GPS Lock
Connect --> Transmit : Connected
Connect --> Sleep : Low Battery or No Connection
Charging --> charge_complete : Charge Complete
Charging --> Sleep : USB Disconnect
Charging --> CLI : "#CLI"
choice2 --> Connect : Data to transmit: Yes
choice2 --> Sleep : Data to transmit: No
deployed_gps --> choice2 : Out of water
deployed_gps --> Sleep : Low Battery
deployed_gps --> deployed_nogps : Lost GPS Lock
charge_complete --> Sleep : USB Disconnect or ~40 days elapsed
CLI --> Connect : Upload Data Command
CLI --> deployed_nogps : Deploy Command
CLI --> Sleep : Sleep Command or CLI timeout
Transmit --> deployed_nogps : Water Detected
Transmit --> Sleep : Transmit Complete or Low Battery
Transmit --> Connect : Lost Connection
[*] -d-> Setup
Setup -d-> Sleep
Sleep -d-> Ride : Water Detected
deployed_nogps -u-> deployed_gps : GPS Lock
deployed_gps -d-> deployed_nogps : Lost GPS Lock
Ride -d-> choice2 : Out of water
choice2 -d-> Connect : Data to transmit
Connect -u-> Transmit : Connected
Transmit -u-> Sleep : Transmit Complete

Sleep -l-> choice1 : USB Connect
choice1 -d-> Connect : Data to transmit
choice1 -l-> ChargeTask : No data to transmit
Charging -d-> charge_complete : Charge Complete
ChargeTask --r--> CLI : "#CLI"
CLI -d--> Connect : Upload Data Command
CLI -d--> Ride : Deploy Command
CLI -l--> Sleep : Sleep Command/CLI timeout
choice2 -u-> Sleep : No data to transmit
DataUpload -u-> Sleep : Low Battery/No Connection
Ride -l-> Sleep : Low Battery
ChargeTask -r-> Sleep : USB Disconnect/~40 days elapsed
DataUpload -r-> Ride : Water Detected
Transmit -d-> Connect : Lost Connection

@enduml
Loading

0 comments on commit 49fb30e

Please sign in to comment.