Skip to content

Commit

Permalink
bugs in esp32 firmware updater
Browse files Browse the repository at this point in the history
  • Loading branch information
pat1 committed Apr 22, 2024
1 parent f2adc90 commit 000ef77
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions python/firmware_updater/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def index(request):
def update(request,name):

sta_mac = request.META.get('HTTP_X_ESP8266_STA_MAC')
if sta_mac is None: sta_mac = request.META.get('HTTP_X_ESP32_STA_MAC' )
ap_mac = request.META.get('HTTP_X_ESP8266_AP_MAC' )
if ap_mac is None: ap_mac = request.META.get('HTTP_X_ESP32_AP_MAC' )
free_space = request.META.get('HTTP_X_ESP8266_FREE_SPACE')
if free_space is None: free_space = request.META.get('HTTP_X_ESP32_FREE_SPACE')
Expand All @@ -47,7 +49,7 @@ def update(request,name):
chip_size = request.META.get('HTTP_X_ESP8266_CHIP_SIZE')
if chip_size is None: chip_size = request.META.get('HTTP_X_ESP32_CHIP_SIZE')
sdk_version= request.META.get('HTTP_X_ESP8266_SDK_VERSION')
if sdk_version is None: sdk_version= request.META.get('HTTP_X_ES32_SDK_VERSION')
if sdk_version is None: sdk_version= request.META.get('HTTP_X_ESP32_SDK_VERSION')

print("firmware name:",name)
print("sta_mac,ap_mac,free_space,sketch_size,sketch_md5,chip_size,sdk_version")
Expand All @@ -61,11 +63,12 @@ def update(request,name):
or sdk_version is None :
# or sketch_md5 is None\

print("403 Forbidden only for ESP8266/ESP32 updater!")
return HttpResponse("403 Forbidden only for ESP8266/ESP32 updater! (header)",status=403)


if (request.META.get('HTTP_USER_AGENT') != 'ESP8266-http-Update'
or request.META.get('HTTP_USER_AGENT') != 'ESP32-http-Update'):
and request.META.get('HTTP_USER_AGENT') != 'ESP32-http-Update'):
print("403 Forbidden only for ESP8266/ESP32 updater!")
return HttpResponse("403 Forbidden only for ESP8266/ESP32 updater!",status=403)

Expand All @@ -75,14 +78,17 @@ def update(request,name):
print(' 500 no version for ESP firmware name')
return HttpResponse(' 500 no version for ESP firmware name',status=500)

#check date (version)
try:
#check date (version)
swversion=json.loads(request.META.get('HTTP_X_ESP8266_VERSION'))
if swversion is None: swversion=json.loads(request.META.get('HTTP_X_ESP32_VERSION'))
swdate = dateutil.parser.parse(swversion["ver"])
except:
print(' 300 No valid version!')
return HttpResponse(' 300 No valid version!',status=300)
try:
swversion = json.loads(request.META.get('HTTP_X_ESP32_VERSION'))
swdate = dateutil.parser.parse(swversion["ver"])
except:
print(' 300 No valid version!')
return HttpResponse(' 300 No valid version!',status=300)

try:
print("user: ",swversion["user"])
Expand Down

0 comments on commit 000ef77

Please sign in to comment.