Actually works now
This commit is contained in:
parent
e9fb10d791
commit
ecf8dcb015
35
Makefile
Normal file
35
Makefile
Normal file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
# When this baud does not work, try 115200
|
||||
FLASH_BAUD := 250000
|
||||
|
||||
# Image to flash
|
||||
FLASH_IMAGE := sumofirmware.bin
|
||||
|
||||
# Try to automatically find the serialport
|
||||
SERIAL_PORT := $(shell find /dev -iname "tty*usb*")
|
||||
|
||||
all: erase flash delay config update reset
|
||||
|
||||
delay:
|
||||
sleep 3
|
||||
|
||||
reset:
|
||||
esptool.py -p $(SERIAL_PORT) --after hard_reset read_mac
|
||||
|
||||
update:
|
||||
ampy -d 0.5 -p $(SERIAL_PORT) put main.py
|
||||
ampy -d 0.5 -p $(SERIAL_PORT) put boot.py
|
||||
|
||||
config:
|
||||
ampy -d 0.5 -p $(SERIAL_PORT) put config.json
|
||||
|
||||
erase:
|
||||
esptool.py -p $(SERIAL_PORT) -b $(FLASH_BAUD) erase_flash
|
||||
|
||||
flash:
|
||||
esptool.py -p $(SERIAL_PORT) -b $(FLASH_BAUD) write_flash --flash_size=detect -fm dio 0 $(FLASH_IMAGE)
|
||||
|
||||
serial:
|
||||
picocom --baud 115200 -q $(SERIAL_PORT)
|
||||
|
5
README.md
Normal file
5
README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# SumoRobot Remote firmware
|
||||
|
||||
Uses stock MicroPython firmware running on ESP8266 Wemos D1 Arduino or D1 Mini
|
||||
|
||||
* https://micropython.org/download/ESP8266_GENERIC/
|
3
boot.py
3
boot.py
@ -13,6 +13,7 @@ with open("config.json", "r") as config_file:
|
||||
|
||||
|
||||
remoteName = "Remote-"+config["remote-id"]
|
||||
print("remoteName", remoteName)
|
||||
|
||||
ap_if = network.WLAN(network.AP_IF)
|
||||
ap_if.active(False)
|
||||
@ -24,6 +25,7 @@ wlan.config(dhcp_hostname=remoteName)
|
||||
# If not already connected
|
||||
if not wlan.isconnected():
|
||||
# Scan for WiFi networks
|
||||
print("Scan")
|
||||
networks = wlan.scan()
|
||||
# Go trough all scanned WiFi networks
|
||||
for network in networks:
|
||||
@ -32,6 +34,7 @@ if not wlan.isconnected():
|
||||
# Check if the SSID is in the config file
|
||||
if ssid in config["wifis"].keys():
|
||||
# Start to connect to the pre-configured network
|
||||
print("Connecting")
|
||||
wlan.connect(ssid, config["wifis"][ssid])
|
||||
break
|
||||
|
||||
|
5
main.py
5
main.py
@ -18,11 +18,14 @@ while True:
|
||||
try:
|
||||
sockaddr = socket.getaddrinfo('sumo-%s' % config["remote-id"], 44444)[0][-1]
|
||||
except OSError:
|
||||
print("failed to resolve sumo-%s" % config["remote-id"])
|
||||
sleep_ms(500)
|
||||
else:
|
||||
break
|
||||
|
||||
# sockaddr = "192.168.1.255", 44444
|
||||
#sockaddr = "100.101.100.70", 44444
|
||||
|
||||
print("Sending packets to", sockaddr)
|
||||
|
||||
while True:
|
||||
msg = "%d:%d:%d" % (adc.read()-calibration, not forward.value(), not backward.value())
|
||||
|
Loading…
Reference in New Issue
Block a user