@@ -571,15 +571,16 @@ Example header data:
571
571
572
572
::
573
573
574
- [HTTP_USER_AGENT] => ESP8266-http-Update
575
- [HTTP_X_ESP8266_STA_MAC] => 18:FE:AA:AA:AA:AA
576
- [HTTP_X_ESP8266_AP_MAC] => 1A:FE:AA:AA:AA:AA
577
- [HTTP_X_ESP8266_FREE_SPACE] => 671744
578
- [HTTP_X_ESP8266_SKETCH_SIZE] => 373940
579
- [HTTP_X_ESP8266_SKETCH_MD5] => a56f8ef78a0bebd812f62067daf1408a
580
- [HTTP_X_ESP8266_CHIP_SIZE] => 4194304
581
- [HTTP_X_ESP8266_SDK_VERSION] => 1.3.0
582
- [HTTP_X_ESP8266_VERSION] => DOOR-7-g14f53a19
574
+ [User-Agent] => ESP8266-http-Update
575
+ [x-ESP8266-STA-MAC] => 18:FE:AA:AA:AA:AA
576
+ [x-ESP8266-AP-MAC] => 1A:FE:AA:AA:AA:AA
577
+ [x-ESP8266-free-space] => 671744
578
+ [x-ESP8266-sketch-size] => 373940
579
+ [x-ESP8266-sketch-md5] => a56f8ef78a0bebd812f62067daf1408a
580
+ [x-ESP8266-chip-size] => 4194304
581
+ [x-ESP8266-sdk-version] => 1.3.0
582
+ [x-ESP8266-version] => DOOR-7-g14f53a19
583
+ [x-ESP8266-mode] => sketch
583
584
584
585
With this information the script now can check if an update is needed. It is also possible to deliver different binaries based on the MAC address, as in the following example:
585
586
@@ -608,20 +609,20 @@ With this information the script now can check if an update is needed. It is als
608
609
readfile($path);
609
610
}
610
611
611
- if(!check_header('HTTP_USER_AGENT ', 'ESP8266-http-Update')) {
612
+ if(!check_header('User-Agent ', 'ESP8266-http-Update')) {
612
613
header($_SERVER["SERVER_PROTOCOL"].' 403 Forbidden', true, 403);
613
614
echo "only for ESP8266 updater!\n";
614
615
exit();
615
616
}
616
617
617
618
if(
618
- !check_header('HTTP_X_ESP8266_STA_MAC ') ||
619
- !check_header('HTTP_X_ESP8266_AP_MAC ') ||
620
- !check_header('HTTP_X_ESP8266_FREE_SPACE ') ||
621
- !check_header('HTTP_X_ESP8266_SKETCH_SIZE ') ||
622
- !check_header('HTTP_X_ESP8266_SKETCH_MD5 ') ||
623
- !check_header('HTTP_X_ESP8266_CHIP_SIZE ') ||
624
- !check_header('HTTP_X_ESP8266_SDK_VERSION ')
619
+ !check_header('x-ESP8266-STA-MAC ') ||
620
+ !check_header('x-ESP8266-AP-MAC ') ||
621
+ !check_header('x-ESP8266-free-space ') ||
622
+ !check_header('x-ESP8266-sketch-size ') ||
623
+ !check_header('x-ESP8266-sketch-md5 ') ||
624
+ !check_header('x-ESP8266-chip-size ') ||
625
+ !check_header('x-ESP8266-sdk-version ')
625
626
) {
626
627
header($_SERVER["SERVER_PROTOCOL"].' 403 Forbidden', true, 403);
627
628
echo "only for ESP8266 updater! (header)\n";
@@ -633,17 +634,17 @@ With this information the script now can check if an update is needed. It is als
633
634
"18:FE:AA:AA:AA:BB" => "TEMP-1.0.0"
634
635
);
635
636
636
- if(!isset($db[$_SERVER['HTTP_X_ESP8266_STA_MAC ']])) {
637
+ if(!isset($db[$_SERVER['x-ESP8266-STA-MAC ']])) {
637
638
header($_SERVER["SERVER_PROTOCOL"].' 500 ESP MAC not configured for updates', true, 500);
638
639
}
639
640
640
- $localBinary = "./bin/".$db[$_SERVER['HTTP_X_ESP8266_STA_MAC ']].".bin";
641
+ $localBinary = "./bin/".$db[$_SERVER['x-ESP8266-STA-MAC ']].".bin";
641
642
642
643
// Check if version has been set and does not match, if not, check if
643
644
// MD5 hash between local binary and ESP8266 binary do not match if not.
644
645
// then no update has been found.
645
- if((!check_header('HTTP_X_ESP8266_SDK_VERSION ') && $db[$_SERVER['HTTP_X_ESP8266_STA_MAC ']] != $_SERVER['HTTP_X_ESP8266_VERSION '])
646
- || $_SERVER["HTTP_X_ESP8266_SKETCH_MD5 "] != md5_file($localBinary)) {
646
+ if((!check_header('x-ESP8266-sdk-version ') && $db[$_SERVER['x-ESP8266-STA-MAC ']] != $_SERVER['x-ESP8266-version '])
647
+ || $_SERVER["x-ESP8266-sketch-md5 "] != md5_file($localBinary)) {
647
648
sendFile($localBinary);
648
649
} else {
649
650
header($_SERVER["SERVER_PROTOCOL"].' 304 Not Modified', true, 304);
0 commit comments