mirror of
https://github.com/skot/ESP-Miner.git
synced 2025-03-29 11:11:45 +01:00
Merge branch 'master' into swarm-mobile-1
This commit is contained in:
commit
8c5fe50912
8
.github/workflows/build.yml
vendored
8
.github/workflows/build.yml
vendored
@ -11,7 +11,7 @@ jobs:
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
node-version: '22.11.0'
|
||||
- name: Build web dist
|
||||
working-directory: ./main/http_server/axe-os
|
||||
run: |
|
||||
@ -32,17 +32,17 @@ jobs:
|
||||
- name: "Create factory/merged image"
|
||||
run: "./merge_bin.sh ./esp-miner-merged.bin"
|
||||
- name: upload esp-miner-merged.bin
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: esp-miner-factory.bin
|
||||
path: ./esp-miner-merged.bin
|
||||
- name: upload esp-miner.bin
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: esp-miner-ota.bin
|
||||
path: ./build/esp-miner.bin
|
||||
- name: upload www.bin
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: www.bin
|
||||
path: ./build/www.bin
|
||||
|
8
.github/workflows/release-beta.yml
vendored
8
.github/workflows/release-beta.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
node-version: '22.11.0'
|
||||
- name: Build web dist
|
||||
working-directory: ./main/http_server/axe-os
|
||||
run: |
|
||||
@ -36,17 +36,17 @@ jobs:
|
||||
- name: "Create factory/merged image"
|
||||
run: "./merge_bin.sh ./esp-miner-merged.bin"
|
||||
- name: upload esp-miner-merged.bin
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: esp-miner-factory.bin
|
||||
path: ./esp-miner-merged.bin
|
||||
- name: upload esp-miner.bin
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: esp-miner.bin
|
||||
path: ./build/esp-miner.bin
|
||||
- name: upload www.bin
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: www.bin
|
||||
path: ./build/www.bin
|
||||
|
2
.github/workflows/release-factory-beta.yml
vendored
2
.github/workflows/release-factory-beta.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
node-version: '22.11.0'
|
||||
- name: Build web dist
|
||||
working-directory: ./main/http_server/axe-os
|
||||
run: |
|
||||
|
2
.github/workflows/release-factory.yml
vendored
2
.github/workflows/release-factory.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
node-version: '22.11.0'
|
||||
- name: Build web dist
|
||||
working-directory: ./main/http_server/axe-os
|
||||
run: |
|
||||
|
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
node-version: '22.11.0'
|
||||
- name: Build web dist
|
||||
working-directory: ./main/http_server/axe-os
|
||||
run: |
|
||||
@ -36,17 +36,17 @@ jobs:
|
||||
- name: "Create factory/merged image"
|
||||
run: "./merge_bin.sh ./esp-miner-merged.bin"
|
||||
- name: upload esp-miner-merged.bin
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: esp-miner-factory.bin
|
||||
path: ./esp-miner-merged.bin
|
||||
- name: upload esp-miner.bin
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: esp-miner.bin
|
||||
path: ./build/esp-miner.bin
|
||||
- name: upload www.bin
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: www.bin
|
||||
path: ./build/www.bin
|
||||
|
@ -58,9 +58,13 @@ static void event_handler(void * arg, esp_event_base_t event_base, int32_t event
|
||||
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
|
||||
esp_wifi_connect();
|
||||
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
|
||||
|
||||
//lookup the exact reason code
|
||||
wifi_event_sta_disconnected_t* event = (wifi_event_sta_disconnected_t*) event_data;
|
||||
if (event->reason == WIFI_REASON_ROAMING) {
|
||||
ESP_LOGI(TAG, "We are roaming, nothing to do");
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Could not connect to '%s' [rssi %d]: reason %d", event->ssid, event->rssi, event->reason);
|
||||
|
||||
// Wait a little
|
||||
|
@ -183,7 +183,7 @@
|
||||
<tr>
|
||||
<td>URL:</td>
|
||||
<td style="word-break: break-all;">
|
||||
<a style="text-decoration: underline;" [href]="(quickLink$ | async) || info.stratumURL"
|
||||
<a style="text-decoration: underline;" [href]="(quickLink$ | async)"
|
||||
target="_blank">{{info.stratumURL}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -207,44 +207,12 @@ export class HomeComponent {
|
||||
}))
|
||||
|
||||
this.quickLink$ = this.info$.pipe(
|
||||
map(info => {
|
||||
if (info.stratumURL.includes('public-pool.io')) {
|
||||
const address = info.stratumUser.split('.')[0]
|
||||
return `https://web.public-pool.io/#/app/${address}`;
|
||||
} else if (info.stratumURL.includes('ocean.xyz')) {
|
||||
const address = info.stratumUser.split('.')[0]
|
||||
return `https://ocean.xyz/stats/${address}`;
|
||||
} else if (info.stratumURL.includes('solo.d-central.tech')) {
|
||||
const address = info.stratumUser.split('.')[0]
|
||||
return `https://solo.d-central.tech/#/app/${address}`;
|
||||
} else if (/solo[46]?.ckpool.org/.test(info.stratumURL)) {
|
||||
const address = info.stratumUser.split('.')[0]
|
||||
return `https://solo.ckpool.org/users/${address}`;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
})
|
||||
)
|
||||
map(info => this.getQuickLink(info.stratumURL, info.stratumUser))
|
||||
);
|
||||
|
||||
this.fallbackQuickLink$ = this.info$.pipe(
|
||||
map(info => {
|
||||
if (info.fallbackStratumURL.includes('public-pool.io')) {
|
||||
const address = info.fallbackStratumUser.split('.')[0]
|
||||
return `https://web.public-pool.io/#/app/${address}`;
|
||||
} else if (info.fallbackStratumURL.includes('ocean.xyz')) {
|
||||
const address = info.fallbackStratumUser.split('.')[0]
|
||||
return `https://ocean.xyz/stats/${address}`;
|
||||
} else if (info.fallbackStratumURL.includes('solo.d-central.tech')) {
|
||||
const address = info.fallbackStratumUser.split('.')[0]
|
||||
return `https://solo.d-central.tech/#/app/${address}`;
|
||||
} else if (/solo[46]?.ckpool.org/.test(info.fallbackStratumURL)) {
|
||||
const address = info.fallbackStratumUser.split('.')[0]
|
||||
return `https://solostats.ckpool.org/users/${address}`;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
})
|
||||
)
|
||||
map(info => this.getQuickLink(info.fallbackStratumURL, info.fallbackStratumUser))
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@ -253,5 +221,20 @@ export class HomeComponent {
|
||||
const sum = data.reduce((sum, value) => sum + value, 0);
|
||||
return sum / data.length;
|
||||
}
|
||||
|
||||
private getQuickLink(stratumURL: string, stratumUser: string): string | undefined {
|
||||
const address = stratumUser.split('.')[0];
|
||||
|
||||
if (stratumURL.includes('public-pool.io')) {
|
||||
return `https://web.public-pool.io/#/app/${address}`;
|
||||
} else if (stratumURL.includes('ocean.xyz')) {
|
||||
return `https://ocean.xyz/stats/${address}`;
|
||||
} else if (stratumURL.includes('solo.d-central.tech')) {
|
||||
return `https://solo.d-central.tech/#/app/${address}`;
|
||||
} else if (/solo[46]?.ckpool.org/.test(stratumURL)) {
|
||||
return `https://solostats.ckpool.org/users/${address}`;
|
||||
}
|
||||
return stratumURL.startsWith('http') ? stratumURL : `http://${stratumURL}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@
|
||||
</h2>
|
||||
|
||||
<div *ngIf="showLogs" id="logs" #scrollContainer>
|
||||
<div *ngFor="let log of logs">₿ {{log | ANSI}}</div>
|
||||
<div *ngFor="let log of logs" [ngClass]="log.className">₿ {{log.text | ANSI}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -8,6 +8,14 @@
|
||||
>div {
|
||||
max-width: 100%;
|
||||
line-break: anywhere;
|
||||
|
||||
font-family: 'Courier New', Courier, monospace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ansi-red { color: #ff0000; }
|
||||
.ansi-green { color: #00ff00; }
|
||||
.ansi-yellow { color: #ffff00; }
|
||||
.ansi-blue { color: #0000ff; }
|
||||
.ansi-magenta { color: #ff00ff; }
|
||||
.ansi-cyan { color: #00ffff; }
|
||||
.ansi-white { color: #ffffff; }
|
||||
|
@ -14,7 +14,7 @@ export class LogsComponent implements OnDestroy, AfterViewChecked {
|
||||
@ViewChild('scrollContainer') private scrollContainer!: ElementRef;
|
||||
public info$: Observable<ISystemInfo>;
|
||||
|
||||
public logs: string[] = [];
|
||||
public logs: { className: string, text: string }[] = [];
|
||||
|
||||
private websocketSubscription?: Subscription;
|
||||
|
||||
@ -55,7 +55,24 @@ export class LogsComponent implements OnDestroy, AfterViewChecked {
|
||||
if (this.showLogs) {
|
||||
this.websocketSubscription = this.websocketService.ws$.subscribe({
|
||||
next: (val) => {
|
||||
this.logs.push(val);
|
||||
const matches = val.matchAll(/\[(\d+;\d+)m(.*?)(?=\[|\n|$)/g);
|
||||
let className = 'ansi-white'; // default color
|
||||
|
||||
for (const match of matches) {
|
||||
const colorCode = match[1].split(';')[1];
|
||||
switch (colorCode) {
|
||||
case '31': className = 'ansi-red'; break;
|
||||
case '32': className = 'ansi-green'; break;
|
||||
case '33': className = 'ansi-yellow'; break;
|
||||
case '34': className = 'ansi-blue'; break;
|
||||
case '35': className = 'ansi-magenta'; break;
|
||||
case '36': className = 'ansi-cyan'; break;
|
||||
case '37': className = 'ansi-white'; break;
|
||||
}
|
||||
}
|
||||
|
||||
this.logs.push({ className, text: val });
|
||||
|
||||
if (this.logs.length > 256) {
|
||||
this.logs.shift();
|
||||
}
|
||||
|
@ -38,7 +38,10 @@
|
||||
</tr>
|
||||
<ng-container *ngFor="let axe of swarm">
|
||||
<tr>
|
||||
<td><a [href]="'http://'+axe.IP" target="_blank">{{axe.IP}}</a></td>
|
||||
<td>
|
||||
<a class="text-primary" [href]="'http://'+axe.IP" target="_blank">{{axe.IP}}</a>
|
||||
<div class="text-xs">{{axe.hostname}}</div>
|
||||
</td>
|
||||
<td>{{axe.hashRate * 1000000000 | hashSuffix}}</td>
|
||||
<td>{{axe.uptimeSeconds | dateAgo}}</td>
|
||||
<td>{{axe.sharesAccepted | number: '1.0-0'}}</td>
|
||||
|
@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { ToastrService } from 'ngx-toastr';
|
||||
import { BehaviorSubject, catchError, combineLatest, debounce, debounceTime, forkJoin, from, interval, map, mergeAll, mergeMap, Observable, of, startWith, switchMap, take, timeout, toArray } from 'rxjs';
|
||||
import { catchError, from, map, mergeMap, of, take, timeout, toArray } from 'rxjs';
|
||||
import { LocalStorageService } from 'src/app/local-storage.service';
|
||||
import { SystemService } from 'src/app/services/system.service';
|
||||
const REFRESH_TIME_SECONDS = 30;
|
||||
@ -42,7 +42,7 @@ export class SwarmComponent implements OnInit, OnDestroy {
|
||||
|
||||
ngOnInit(): void {
|
||||
const swarmData = this.localStorageService.getObject(SWARM_DATA);
|
||||
console.log(swarmData);
|
||||
|
||||
if (swarmData == null) {
|
||||
this.scanNetwork();
|
||||
//this.swarm$ = this.scanNetwork('192.168.1.23', '255.255.255.0').pipe(take(1));
|
||||
@ -53,7 +53,6 @@ export class SwarmComponent implements OnInit, OnDestroy {
|
||||
this.refreshIntervalRef = window.setInterval(() => {
|
||||
this.refreshIntervalTime --;
|
||||
if(this.refreshIntervalTime <= 0){
|
||||
this.refreshIntervalTime = REFRESH_TIME_SECONDS;
|
||||
this.refreshList();
|
||||
}
|
||||
}, 1000);
|
||||
@ -61,6 +60,7 @@ export class SwarmComponent implements OnInit, OnDestroy {
|
||||
|
||||
ngOnDestroy(): void {
|
||||
window.clearInterval(this.refreshIntervalRef);
|
||||
this.form.reset();
|
||||
}
|
||||
|
||||
|
||||
@ -101,12 +101,15 @@ export class SwarmComponent implements OnInit, OnDestroy {
|
||||
return []; // Return an empty result or handle as desired
|
||||
})
|
||||
),
|
||||
256 // Limit concurrency to avoid overload
|
||||
128 // Limit concurrency to avoid overload
|
||||
),
|
||||
toArray() // Collect all results into a single array
|
||||
).pipe(take(1)).subscribe({
|
||||
next: (result) => {
|
||||
this.swarm = result;
|
||||
// Merge new results with existing swarm entries
|
||||
const existingIps = new Set(this.swarm.map(item => item.IP));
|
||||
const newItems = result.filter(item => !existingIps.has(item.IP));
|
||||
this.swarm = [...this.swarm, ...newItems].sort(this.sortByIp.bind(this));
|
||||
this.localStorageService.setObject(SWARM_DATA, this.swarm);
|
||||
},
|
||||
complete: () => {
|
||||
@ -117,10 +120,17 @@ export class SwarmComponent implements OnInit, OnDestroy {
|
||||
|
||||
public add() {
|
||||
const newIp = this.form.value.manualAddIp;
|
||||
|
||||
// Check if IP already exists
|
||||
if (this.swarm.some(item => item.IP === newIp)) {
|
||||
this.toastr.warning('This IP address already exists in the swarm', 'Duplicate Entry');
|
||||
return;
|
||||
}
|
||||
|
||||
this.systemService.getInfo(`http://${newIp}`).subscribe((res) => {
|
||||
if (res.ASICModel) {
|
||||
this.swarm.push({ IP: newIp, ...res });
|
||||
this.swarm = this.swarm.sort(this.sortByIp.bind(this));
|
||||
this.localStorageService.setObject(SWARM_DATA, this.swarm);
|
||||
}
|
||||
});
|
||||
@ -132,10 +142,16 @@ export class SwarmComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
public restart(axe: any) {
|
||||
this.systemService.restart(`http://${axe.IP}`).subscribe(res => {
|
||||
|
||||
this.systemService.restart(`http://${axe.IP}`).pipe(
|
||||
catchError(error => {
|
||||
this.toastr.error('Failed to restart device', 'Error');
|
||||
return of(null);
|
||||
})
|
||||
).subscribe(res => {
|
||||
if (res !== null) {
|
||||
this.toastr.success('Bitaxe restarted', 'Success');
|
||||
}
|
||||
});
|
||||
this.toastr.success('Success!', 'Bitaxe restarted');
|
||||
}
|
||||
|
||||
public remove(axeOs: any) {
|
||||
@ -144,6 +160,7 @@ export class SwarmComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
public refreshList() {
|
||||
this.refreshIntervalTime = REFRESH_TIME_SECONDS;
|
||||
const ips = this.swarm.map(axeOs => axeOs.IP);
|
||||
|
||||
from(ips).pipe(
|
||||
@ -157,15 +174,16 @@ export class SwarmComponent implements OnInit, OnDestroy {
|
||||
}),
|
||||
timeout(5000),
|
||||
catchError(error => {
|
||||
this.toastr.error('Error', 'Failed to get info from ' + ipAddr + ' - ' + error);
|
||||
return of(this.swarm.find(axeOs => axeOs.IP == ipAddr));
|
||||
})
|
||||
),
|
||||
256 // Limit concurrency to avoid overload
|
||||
128 // Limit concurrency to avoid overload
|
||||
),
|
||||
toArray() // Collect all results into a single array
|
||||
).pipe(take(1)).subscribe({
|
||||
next: (result) => {
|
||||
this.swarm = result;
|
||||
this.swarm = result.sort(this.sortByIp.bind(this));
|
||||
this.localStorageService.setObject(SWARM_DATA, this.swarm);
|
||||
},
|
||||
complete: () => {
|
||||
@ -174,4 +192,8 @@ export class SwarmComponent implements OnInit, OnDestroy {
|
||||
|
||||
}
|
||||
|
||||
private sortByIp(a: any, b: any): number {
|
||||
return this.ipToInt(a.IP) - this.ipToInt(b.IP);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -114,14 +114,27 @@ static esp_err_t set_content_type_from_file(httpd_req_t * req, const char * file
|
||||
}
|
||||
return httpd_resp_set_type(req, type);
|
||||
}
|
||||
|
||||
static esp_err_t set_cors_headers(httpd_req_t * req)
|
||||
{
|
||||
esp_err_t err;
|
||||
|
||||
return httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*") == ESP_OK &&
|
||||
httpd_resp_set_hdr(req, "Access-Control-Allow-Methods", "GET, POST, PUT, PATCH, DELETE, OPTIONS") == ESP_OK &&
|
||||
httpd_resp_set_hdr(req, "Access-Control-Allow-Headers", "Content-Type") == ESP_OK
|
||||
? ESP_OK
|
||||
: ESP_FAIL;
|
||||
err = httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
||||
if (err != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
err = httpd_resp_set_hdr(req, "Access-Control-Allow-Methods", "GET, POST, PUT, PATCH, DELETE, OPTIONS");
|
||||
if (err != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
err = httpd_resp_set_hdr(req, "Access-Control-Allow-Headers", "Content-Type");
|
||||
if (err != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
/* Recovery handler */
|
||||
@ -181,7 +194,7 @@ static esp_err_t rest_common_get_handler(httpd_req_t * req)
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
/* Respond with 500 Internal Server Error */
|
||||
httpd_resp_send_err(req, HTTPD_500_INTERNAL_SERVER_ERROR, "Failed to send file");
|
||||
return ESP_FAIL;
|
||||
return ESP_OK;
|
||||
}
|
||||
}
|
||||
} while (read_bytes > 0);
|
||||
@ -193,13 +206,12 @@ static esp_err_t rest_common_get_handler(httpd_req_t * req)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
static esp_err_t handle_options_request(httpd_req_t * req)
|
||||
{
|
||||
// Set CORS headers for OPTIONS request
|
||||
if (set_cors_headers(req) != ESP_OK) {
|
||||
httpd_resp_send_500(req);
|
||||
return ESP_FAIL;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
// Send a blank response for OPTIONS request
|
||||
@ -213,7 +225,7 @@ static esp_err_t PATCH_update_settings(httpd_req_t * req)
|
||||
// Set CORS headers
|
||||
if (set_cors_headers(req) != ESP_OK) {
|
||||
httpd_resp_send_500(req);
|
||||
return ESP_FAIL;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
int total_len = req->content_len;
|
||||
@ -223,14 +235,14 @@ static esp_err_t PATCH_update_settings(httpd_req_t * req)
|
||||
if (total_len >= SCRATCH_BUFSIZE) {
|
||||
/* Respond with 500 Internal Server Error */
|
||||
httpd_resp_send_err(req, HTTPD_500_INTERNAL_SERVER_ERROR, "content too long");
|
||||
return ESP_FAIL;
|
||||
return ESP_OK;
|
||||
}
|
||||
while (cur_len < total_len) {
|
||||
received = httpd_req_recv(req, buf + cur_len, total_len);
|
||||
if (received <= 0) {
|
||||
/* Respond with 500 Internal Server Error */
|
||||
httpd_resp_send_err(req, HTTPD_500_INTERNAL_SERVER_ERROR, "Failed to post control value");
|
||||
return ESP_FAIL;
|
||||
return ESP_OK;
|
||||
}
|
||||
cur_len += received;
|
||||
}
|
||||
@ -238,6 +250,11 @@ static esp_err_t PATCH_update_settings(httpd_req_t * req)
|
||||
|
||||
cJSON * root = cJSON_Parse(buf);
|
||||
cJSON * item;
|
||||
if (root == NULL) {
|
||||
httpd_resp_send_err(req, HTTPD_400_BAD_REQUEST, "Invalid JSON");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if ((item = cJSON_GetObjectItem(root, "stratumURL")) != NULL) {
|
||||
nvs_config_set_string(NVS_CONFIG_STRATUM_URL, item->valuestring);
|
||||
}
|
||||
@ -303,6 +320,12 @@ static esp_err_t PATCH_update_settings(httpd_req_t * req)
|
||||
|
||||
static esp_err_t POST_restart(httpd_req_t * req)
|
||||
{
|
||||
// Set CORS headers
|
||||
if (set_cors_headers(req) != ESP_OK) {
|
||||
httpd_resp_send_500(req);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Restarting System because of API Request");
|
||||
|
||||
// Send HTTP response before restarting
|
||||
@ -319,7 +342,6 @@ static esp_err_t POST_restart(httpd_req_t * req)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
/* Simple handler for getting system handler */
|
||||
static esp_err_t GET_system_info(httpd_req_t * req)
|
||||
{
|
||||
@ -328,7 +350,7 @@ static esp_err_t GET_system_info(httpd_req_t * req)
|
||||
// Set CORS headers
|
||||
if (set_cors_headers(req) != ESP_OK) {
|
||||
httpd_resp_send_500(req);
|
||||
return ESP_FAIL;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -694,6 +716,10 @@ esp_err_t start_rest_server(void * pvParameters)
|
||||
.uri = "/api/system/restart", .method = HTTP_POST, .handler = POST_restart, .user_ctx = rest_context};
|
||||
httpd_register_uri_handler(server, &system_restart_uri);
|
||||
|
||||
httpd_uri_t system_restart_options_uri = {
|
||||
.uri = "/api/system/restart", .method = HTTP_OPTIONS, .handler = handle_options_request, .user_ctx = NULL};
|
||||
httpd_register_uri_handler(server, &system_restart_options_uri);
|
||||
|
||||
httpd_uri_t update_system_settings_uri = {
|
||||
.uri = "/api/system", .method = HTTP_PATCH, .handler = PATCH_update_settings, .user_ctx = rest_context};
|
||||
httpd_register_uri_handler(server, &update_system_settings_uri);
|
||||
|
Loading…
x
Reference in New Issue
Block a user