First Commit
This commit is contained in:
3
Firmware/CONFIG/CLOCK_CONFIG.py
Normal file
3
Firmware/CONFIG/CLOCK_CONFIG.py
Normal file
@@ -0,0 +1,3 @@
|
||||
NTP_SERVER="time-a-g.nist.gov"
|
||||
TIMEZONE_OFFSET="-5"
|
||||
DAYLIGHT_SAVING=False
|
||||
1
Firmware/CONFIG/FTC_TEAM_CONFIG.py
Normal file
1
Firmware/CONFIG/FTC_TEAM_CONFIG.py
Normal file
@@ -0,0 +1 @@
|
||||
TEAM_ASSIGNED="00000"
|
||||
6
Firmware/CONFIG/LED_MANAGER.py
Normal file
6
Firmware/CONFIG/LED_MANAGER.py
Normal file
@@ -0,0 +1,6 @@
|
||||
NUM_LEDS = 128
|
||||
LED_PIN = 0
|
||||
BRIGHTNESS = 9.0 # Set brightness of animations here, 0-1.0
|
||||
MAX_SOLID_BRIGHTNESS = 100 # Set solid color max brightness here 0-255
|
||||
# Pick between chase, rainbows, and alternating_blinkies.
|
||||
STARTING_ANIMATION="rainbows"
|
||||
8
Firmware/CONFIG/MQTT_CONFIG.py
Normal file
8
Firmware/CONFIG/MQTT_CONFIG.py
Normal file
@@ -0,0 +1,8 @@
|
||||
## This area of the configuration will come pre-set on your device.
|
||||
## DO NOT CHANGE THIS UNLESS INSTRUCTED TO DO SO BY AMELIA WIETTING OR TODD VOLZ
|
||||
|
||||
MQTT_USERNAME=b"USERNAME" # These need to be in BYTES
|
||||
MQTT_PASSWORD=b"PASSWORD" # These need to be in BYTES
|
||||
MQTT_SERVER=b"aask.services"
|
||||
MQTT_CLIENT_ID="test_2"
|
||||
# This was from an OTA update ;)
|
||||
10
Firmware/CONFIG/OTA_CONFIG.py
Normal file
10
Firmware/CONFIG/OTA_CONFIG.py
Normal file
@@ -0,0 +1,10 @@
|
||||
OTA_HOST = 'http://aask.services:8000'
|
||||
PROJECT_NAME = 'ftc_lights'
|
||||
FILENAMES = ['boot.py',
|
||||
'main.py',
|
||||
'CONFIG/WIFI_CONFIG.py',
|
||||
'CONFIG/MQTT_CONFIG.py',
|
||||
'CONFIG/MQTT_CONFIG.py',
|
||||
'CONFIG/OTA_CONFIG.py',
|
||||
'CONFIG/FTC_TEAM_CONFIG.py',
|
||||
'CONFIG/LED_MANAGER.py']
|
||||
4
Firmware/CONFIG/WIFI_CONFIG.py
Normal file
4
Firmware/CONFIG/WIFI_CONFIG.py
Normal file
@@ -0,0 +1,4 @@
|
||||
COUNTRY="US"
|
||||
WIFI_LIST=[["",""]]#,["Fongs Guest","Happykitty223!"]]
|
||||
MAX_WIFI_CONNECT_TIMEOUT=15
|
||||
|
||||
42
Firmware/README.md
Normal file
42
Firmware/README.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# Welcome to the 3rd Annual CyberTractorChallenge!
|
||||
|
||||
## Welcome Participants!
|
||||
|
||||
Congratulations on joining the 3rd Annual CyberTractorChallenge! We're thrilled to have you on board for this exciting event. Your participation helps drive innovation and creativity in the realm of agricultural cybersecurity.
|
||||
|
||||
## Your Challenge Badge
|
||||
|
||||
We are excited to introduce you to your custom challenge badge. This badge is not just a token of participation, but a powerful tool you can use for the competition. Here’s a quick rundown of some of its features and inner workings:
|
||||
|
||||
### Badge Overview
|
||||
|
||||
Your badge is powered by an **OLIMEX ESP32-EVB board**. This versatile board is equipped with several key capabilities that you can use utilize during the challenge:
|
||||
|
||||
- **ETHERNET:** For high-speed wired network connectivity.
|
||||
- **WIFI:** For wireless communication and IoT applications.
|
||||
- **CAN (Controller Area Network):** For robust vehicle and industrial communication, crucial in automotive and agricultural technology.
|
||||
|
||||
### Getting Started
|
||||
|
||||
1. **Power Up:** Connect your badge to a power source using a USB cable.
|
||||
2. **Connectivity:** The board is programmed using micropython so feel free to use Thonny to check out the base code.
|
||||
3. **Base Code:** We've provided a base code to get you started. This code initializes the board and sets up basic WIFI communication protocols and provides a pretty light show. The base code is provided by the Aask Ltd. FTC Fancy Lights Repo [https://github.com/Aask42/ftc_fancy_lights.git].
|
||||
|
||||
### Your Mission
|
||||
|
||||
Your mission, should you choose to accept it, is to **modify the base code to make your badge do something cool**. The possibilities are endless, and we encourage you to think outside the box. Here are a few ideas to get your creative juices flowing:
|
||||
|
||||
- **Remote Control:** Create a remote control interface using WiFi or Ethernet.
|
||||
- **Data Logging:** Implement a system to log data from the CAN bus.
|
||||
|
||||
### Resources
|
||||
|
||||
To help you get started, we've provided the following resources:
|
||||
|
||||
- **ESP32-EVB Documentation:** [https://www.olimex.com/Products/IoT/ESP32/ESP32-EVB/open-source-hardware]
|
||||
|
||||
We can't wait to see what you come up with! Good luck, and happy hacking!
|
||||
|
||||
Best Regards,
|
||||
|
||||
The CyberTractorChallenge Team
|
||||
5
Firmware/boot.py
Normal file
5
Firmware/boot.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# This file is executed on every boot (including wake-boot from deepsleep)
|
||||
#import esp
|
||||
#esp.osdebug(None)
|
||||
#import webrepl
|
||||
#webrepl.start()
|
||||
13
Firmware/helper.py
Normal file
13
Firmware/helper.py
Normal file
@@ -0,0 +1,13 @@
|
||||
def hsv_to_rgb(h, s, v):
|
||||
if s == 0.0: return (v, v, v)
|
||||
i = int(h*6.)
|
||||
f = (h*6.)-i
|
||||
p,q,t = int(255*(v*(1.-s))), int(255*(v*(1.-s*f))), int(255*(v*(1.-s*(1.-f))))
|
||||
v = int(255*v)
|
||||
i %= 6
|
||||
if i == 0: return (v, t, p)
|
||||
if i == 1: return (q, v, p)
|
||||
if i == 2: return (p, v, t)
|
||||
if i == 3: return (p, q, v)
|
||||
if i == 4: return (t, p, v)
|
||||
if i == 5: return (v, p, q)
|
||||
1016
Firmware/main.py
Normal file
1016
Firmware/main.py
Normal file
File diff suppressed because it is too large
Load Diff
59
Firmware/updates.py
Normal file
59
Firmware/updates.py
Normal file
@@ -0,0 +1,59 @@
|
||||
from CONFIG.OTA_CONFIG import OTA_HOST, PROJECT_NAME, FILENAMES
|
||||
from CONFIG.MQTT_CONFIG import MQTT_CLIENT_ID
|
||||
import uos
|
||||
import urequests
|
||||
import micropython as mp
|
||||
import gc
|
||||
|
||||
|
||||
|
||||
def update_file_replace(msg_string):
|
||||
print(f"Starting update process for {msg_string}...")
|
||||
filename = msg_string
|
||||
|
||||
mp.mem_info(1)
|
||||
gc.collect()
|
||||
|
||||
try:
|
||||
|
||||
updated = False
|
||||
print(f"Updating file {filename}")
|
||||
|
||||
for i,item in enumerate(FILENAMES):
|
||||
print(f"Seeing if {filename} is in {item}")
|
||||
|
||||
if filename in item:
|
||||
file_to_write = item
|
||||
print(f"Found filename! Simple name: {filename} Fullly Qualified: {item}")
|
||||
try:
|
||||
uos.mkdir('tmp')
|
||||
except:
|
||||
pass
|
||||
|
||||
updated = False
|
||||
file_to_write = FILENAMES[i]
|
||||
response = urequests.get(f'{OTA_HOST}/ota_updates/{MQTT_CLIENT_ID}/{filename}', timeout=5)
|
||||
response_text = response.text
|
||||
response.close()
|
||||
#print(f"Found file {filename} with {response_text}")
|
||||
# Get the file we need to write
|
||||
# Write to a tmp file
|
||||
print(f"Going to try to write to tmp/{file_to_write}")
|
||||
|
||||
with open(f'tmp/{filename}', 'w') as source_file:
|
||||
source_file.write(response_text)
|
||||
|
||||
|
||||
# Overwrite our onboard file
|
||||
with open(f'tmp/{filename}', 'r') as source_file, open(file_to_write, 'w') as target_file:
|
||||
target_file.write(source_file.read())
|
||||
|
||||
uos.remove(f'tmp/{filename}')
|
||||
|
||||
try:
|
||||
uos.rmdir('tmp')
|
||||
except:
|
||||
pass
|
||||
break
|
||||
except Exception as e:
|
||||
print(f"Exception updating file! {e}")
|
||||
Reference in New Issue
Block a user