Skip to content

Commit

Permalink
Merge branch 'main' of github.com:umts/embedded-departure-board into …
Browse files Browse the repository at this point in the history
…stop_414
  • Loading branch information
bandogora committed Dec 11, 2024
2 parents f6e953c + 61f045c commit 668dc5e
Show file tree
Hide file tree
Showing 26 changed files with 337 additions and 313 deletions.
2 changes: 1 addition & 1 deletion app/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Language: Cpp
BasedOnStyle: Google

AlignAfterOpenBracket: BlockIndent
# ColumnLimit: 100
ColumnLimit: 100
...
2 changes: 1 addition & 1 deletion app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/keys/private/boot-ecdsa-p256.pem")
SET(mcuboot_CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256 "y")
endif()

set(EXTRA_CONF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/app.conf)
set(EXTRA_CONF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/sign.conf)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(embedded-departure-board)
Expand Down
27 changes: 27 additions & 0 deletions app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ source "Kconfig.zephyr"
config STOP_ID
string "Bus stop ID"

config STOP_MAX_ROUTES
int "Maximum number of routes expected at the configured stop"

config ROUTE_MAX_DEPARTURES
int "Maximum number of departures expected for EACH route"

config UPDATE_STOP_FREQUENCY_SECONDS
int "The frequency at which stop departure times are updated in seconds"

config NUMBER_OF_DISPLAY_BOXES
int "The number of display boxes connected to the sign"

config MAX_TIME_INACTIVE_BEFORE_RESET_MS
int "Maximum amount of time the system can remain inactive before it resets in milliseconds"

config STOP_REQUEST_INFOPOINT
bool "Select if JSON feed is directly from InfoPoint servers"

Expand All @@ -16,6 +31,18 @@ config STOP_REQUEST_PATH
config STOP_JSON_BUF_SIZE
int "Defines the max size for stop JSON response body receive buffer"

config PRIMARY_NTP_SERVER
string "Primary NTP server used to synchronize system time"

config FALLBACK_NTP_SERVER
string "Fallback NTP server used to synchronize system time if the primary server is unavailable"

config NTP_REQUEST_TIMEOUT_MS
int "Max amount of time allowed waiting for a single NTP query response for in milliseconds"

config NTP_FETCH_RETRY_COUNT
int "Max attempts to fetch time from NTP server before changing to fallback server"

config OTA_HOSTNAME
string "HTTP hostname used to download firmware upgade file"

Expand Down
2 changes: 1 addition & 1 deletion app/VERSION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION_MAJOR = 0
VERSION_MINOR = 6
VERSION_MINOR = 7
PATCHLEVEL = 1
VERSION_TWEAK = 0
EXTRAVERSION = stable
24 changes: 0 additions & 24 deletions app/app.conf

This file was deleted.

5 changes: 0 additions & 5 deletions app/boards/circuitdojo_feather_nrf9160_ns.conf
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ CONFIG_LTE_PTW_VALUE_LTE_M="0000"
# RAI is only supported for NBIoT currently
# CONFIG_LTE_RAI_REQ=y

# Enable External RTC
CONFIG_DATE_TIME=y
CONFIG_COUNTER=y
CONFIG_PCF85063A=y

# Neopixels over SPI
CONFIG_SPI=y
CONFIG_LED_STRIP=y
Expand Down
30 changes: 22 additions & 8 deletions app/boards/circuitdojo_feather_nrf9160_ns.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,20 @@
pinctrl-0 = <&i2c1_default>;
pinctrl-1 = <&i2c1_sleep>;
pinctrl-names = "default", "sleep";
pcf85063a: pcf85063a@51 {
compatible = "nxp,pcf85063a";
reg = <0x51>;
};
sen0562@23 {
compatible = "dfrobot,sen0562";
reg = <0x23>;
};

pcf85063a: pcf85063a@51 {
status = "disabled";
};

lis2dh: lis2dh@18 {
status = "disabled";
};

sen0562@23 {
status = "okay";
compatible = "dfrobot,sen0562";
reg = <0x23>;
};
};

&uart0 {
Expand Down Expand Up @@ -85,6 +91,13 @@ sen0562@23 {
};
};

&rtc0 {
status = "okay";
// Set the frequency to 8Hz
prescaler = <4095>;
wakeup-source;
};

&pwm0 {
status = "okay";
pinctrl-0 = <&pwm0_default>;
Expand Down Expand Up @@ -170,6 +183,7 @@ sen0562@23 {
};

aliases {
rtc = &rtc0;
led-strip = &led_strip;
mux = &multiplexer;
};
Expand Down
34 changes: 13 additions & 21 deletions app/child_image/mcuboot.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Core should be on a clean state when TF-M starts
CONFIG_MCUBOOT_CLEANUP_ARM_CORE=y

# Enable echo command
CONFIG_BOOT_MGMT_ECHO=y

# Increase MCUboot image sectors and set static partition size
CONFIG_BOOT_MAX_IMG_SECTORS=256
CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x20000
Expand Down Expand Up @@ -32,27 +29,22 @@ CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y
CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y

# Logging RTT
# Console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=n

# Logging
CONFIG_LOG=y
CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_LOG_MODE_MINIMAL=n
CONFIG_LOG_MODE_IMMEDIATE=y
CONFIG_RTT_CONSOLE=y
CONFIG_LOG_DEFAULT_LEVEL=2

# RTT
# We use serial for MCUmgr so no UART
CONFIG_USE_SEGGER_RTT=y
CONFIG_UART_CONSOLE=n
CONFIG_RTT_CONSOLE=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_DEBUG=y
CONFIG_LOG_BACKEND_RTT_MODE_DROP=y

# # Logging UART
# CONFIG_CONSOLE=y
# CONFIG_UART_CONSOLE=y
# CONFIG_LOG=y
# CONFIG_LOG_DEFAULT_LEVEL=3
# CONFIG_LOG_MODE_MINIMAL=n
# CONFIG_LOG_MODE_IMMEDIATE=y
# CONFIG_LOG_BACKEND_UART=y
# CONFIG_DEBUG=y
# CONFIG_LOG_MODE_OVERFLOW=y
CONFIG_SEGGER_RTT_MODE_NO_BLOCK_TRIM=y

# Debugging
CONFIG_DEBUG=n
2 changes: 1 addition & 1 deletion app/pm_static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ mcuboot_primary:
end_address: 0xf2000
orig_span: &id001
- tfm
- app
- mcuboot_pad
- app
region: flash_primary
size: 0xd2000
span: *id001
Expand Down
29 changes: 15 additions & 14 deletions app/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CONFIG_REBOOT=y
CONFIG_PM_DEVICE=y

# Compiler optimizations
# Optimize for speed since spce isn't a huge concern for this app
# Optimize for speed since space isn't a huge concern for this app
CONFIG_SPEED_OPTIMIZATIONS=y

# Flash operations.
Expand All @@ -27,6 +27,9 @@ CONFIG_WDT_DISABLE_AT_BOOT=n
CONFIG_GPIO=y
CONFIG_MULTIPLEXER=y

# Counter
CONFIG_COUNTER=y

# I2C
CONFIG_I2C=y

Expand All @@ -44,7 +47,7 @@ CONFIG_SNTP=y
# Set mem sizes
# Needs to be larger than expected routes JSON, see app.conf.
# Currently set to double the size because we have plenty of memory.
CONFIG_MAIN_STACK_SIZE=20480
CONFIG_MAIN_STACK_SIZE=40960
# Increase heap size for networking operations
CONFIG_HEAP_MEM_POOL_SIZE=1024

Expand Down Expand Up @@ -84,26 +87,24 @@ CONFIG_FAULT_DUMP=0

# Logging
CONFIG_LOG=y
CONFIG_LOG_MODE_DEFERRED=y
# 1 = Error, 2 = Warn, 3 = Info, 4 = Debug
CONFIG_LOG_DEFAULT_LEVEL=2
# CONFIG_LOG_MAX_LEVEL=2
# CONFIG_LOG_INFO_COLOR_GREEN=y
# CONFIG_LOG_BACKEND_SHOW_COLOR=n
# The default stack size of 1024 seems okay for log level 1 and 2, but not 3 and 4.
# We have enough unused RAM and I'd rather avoid any potential logging stack overflows either way.
CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=2048

# Log UART
# CONFIG_LOG_MODE_MINIMAL=y
# CONFIG_LOG_MODE_DEFERRED=y
# CONFIG_LOG_MODE_OVERFLOW=y
# CONFIG_LOG_BUFFER_SIZE=2048
# CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=2048
# We can't use MCUMGR over serial when serial logging is enabled, so we use RTT in production.
# Uncomment this option and comment out the Log RTT options if you want to use the USB serial logging testing.
# CONFIG_LOG_BACKEND_UART=y

# Log RTT
# # Log RTT
CONFIG_LOG_BACKEND_UART=n
CONFIG_LOG_MODE_MINIMAL=n
CONFIG_RTT_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_SEGGER_RTT_MODE_NO_BLOCK_TRIM=y
# CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=4096

# Network Logging
# CONFIG_NET_LOG=y
Expand Down
42 changes: 42 additions & 0 deletions app/sign.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Stop settings
CONFIG_STOP_ID="414"
CONFIG_STOP_MAX_ROUTES=7
CONFIG_ROUTE_MAX_DEPARTURES=6
CONFIG_UPDATE_STOP_FREQUENCY_SECONDS=30

# Display settings
CONFIG_NUMBER_OF_DISPLAY_BOXES=6
# Adjust DISPLAY_BOXES display settings in app/src/update_stop.h

# Maximum amount of time the system can remain inactive before it resets.
# Must be larger than CONFIG_UPDATE_STOP_FREQUENCY_SECONDS
CONFIG_MAX_TIME_INACTIVE_BEFORE_RESET_MS=60000

# Stop data request settings
CONFIG_STOP_REQUEST_INFOPOINT=y
CONFIG_STOP_REQUEST_HOSTNAME="bustracker.pvta.com"
# CONFIG_STOP_REQUEST_HOSTNAME="pvta.jes.contact"
CONFIG_STOP_REQUEST_PATH="/InfoPoint/rest/SignageStopDepartures/GetSignageDeparturesByStopId?stopId=414"
# CONFIG_STOP_REQUEST_PATH="/stop/414"

# Defines the max size for JSON response body receive buffer.
# Actual size required varies quite a bit depending on how many routes
# are currently running for a given stop.
CONFIG_STOP_JSON_BUF_SIZE=20480

# NTP settings
CONFIG_PRIMARY_NTP_SERVER="time.nist.gov"
CONFIG_FALLBACK_NTP_SERVER="us.pool.ntp.org"
# The NIST time servers should never be queried more frequently than once every 4 seconds.
CONFIG_NTP_REQUEST_TIMEOUT_MS=4010
CONFIG_NTP_FETCH_RETRY_COUNT=2

# OTA DFU settings
CONFIG_OTA_HOSTNAME="pvta.jes.contact"
CONFIG_OTA_PATH="/firmware"

# Set to 'y' to enable I2C ambient light sensor
CONFIG_LIGHT_SENSOR=y

# Set to 'y' to run visual display tests
CONFIG_LED_DISPLAY_TEST=n
12 changes: 6 additions & 6 deletions app/src/display/led_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ int led_test_patern(void) {
memcpy(&pixels[test], &pixel, sizeof(struct led_rgb));
memcpy(&pixels[63 + test], &pixel, sizeof(struct led_rgb));

for (size_t i = 0; i < NUMBER_OF_DISPLAY_BOXES; i++) {
for (size_t i = 0; i < CONFIG_NUMBER_OF_DISPLAY_BOXES; i++) {
mux_set_active_port(mux, i);
if (led_strip_update_rgb(strip, pixels, STRIP_NUM_PIXELS) != 0) {
LOG_ERR("Failed to update LED strip, test: %d", 0);
Expand All @@ -168,7 +168,7 @@ int led_test_patern(void) {
LOG_INF("Running number display test.");
static const DisplayBox display_boxes[] = DISPLAY_BOXES;
for (size_t test = 0; test < 10; test++) {
for (size_t i = 0; i < NUMBER_OF_DISPLAY_BOXES; i++) {
for (size_t i = 0; i < CONFIG_NUMBER_OF_DISPLAY_BOXES; i++) {
if (write_num_to_display(
&display_boxes[i], display_boxes[i].brightness, test * 111
)) {
Expand All @@ -180,7 +180,7 @@ int led_test_patern(void) {

LOG_INF("Number display test done. Setting enable pin low on all displays.");

for (size_t i = 0; i < NUMBER_OF_DISPLAY_BOXES; i++) {
for (size_t i = 0; i < CONFIG_NUMBER_OF_DISPLAY_BOXES; i++) {
if (display_off(i)) {
return -1;
}
Expand All @@ -204,15 +204,15 @@ int max_power_test(void) {
return -1;
}

for (size_t box = 0; box < NUMBER_OF_DISPLAY_BOXES; box++) {
for (size_t box = 0; box < CONFIG_NUMBER_OF_DISPLAY_BOXES; box++) {
if (display_off(box)) {
return -1;
}
}

LOG_INF("Running individual box power display test.");

for (size_t i = 0; i < NUMBER_OF_DISPLAY_BOXES; i++) {
for (size_t i = 0; i < CONFIG_NUMBER_OF_DISPLAY_BOXES; i++) {
if (i != 0) {
if (display_off(i - 1)) {
return -1;
Expand All @@ -227,7 +227,7 @@ int max_power_test(void) {
}

LOG_INF("Running max power display test.");
for (size_t j = 0; j < NUMBER_OF_DISPLAY_BOXES; j++) {
for (size_t j = 0; j < CONFIG_NUMBER_OF_DISPLAY_BOXES; j++) {
if (write_num_to_display(
&display_boxes[j], display_boxes[j].brightness, 888
)) {
Expand Down
Loading

0 comments on commit 668dc5e

Please sign in to comment.