// Compile production configuration/URL policy functions against hardware and // NVS doubles. Hardware acceptance remains a separate COM6 check. const fs=require('fs'),path=require('path'); const base=path.resolve(__dirname,'..'); const json=path.join(process.env.IDF_PATH||'E:/Codex/toolchains/esp-idf-v5.5.1','components/json/cJSON'); const source=fs.readFileSync(path.join(base,'main/device_control.c'),'utf8'); const apply=source.slice(source.indexOf('static esp_err_t apply_config('),source.indexOf('static cJSON *diagnostics(')); const ota=fs.readFileSync(path.join(base,'main/device_ota.c'),'utf8'); const url=ota.slice(ota.indexOf('static bool same_origin_download('),ota.indexOf('static esp_err_t download(')); process.stdout.write(fs.readFileSync(path.join(json,'cJSON.h'),'utf8')+'\n'+fs.readFileSync(path.join(json,'cJSON.c'),'utf8').replace('#include "cJSON.h"','')+` #include #include #include typedef int esp_err_t; typedef int nvs_handle_t; #define ESP_OK 0 #define ESP_FAIL -1 #define ESP_ERR_INVALID_RESPONSE 1 #define ESP_ERR_NOT_SUPPORTED 2 #define NVS_READWRITE 1 static int64_t applied_revision; static char device_display_name[97], stored_name[97], staged_name[97]; static int read_error; static int power_error; static int device_power_apply(const char *mode,bool held){return power_error;} static int hardware_volume=70,stored=-1,staged=-1,codec_error,commit_error,commits; static int volc_hal_get_device_volume(void){return hardware_volume;} static int volc_hal_set_device_volume(int n){if(codec_error)return -1;hardware_volume=n;return 0;} static int nvs_open(const char *s,int mode,int *n){*n=1;return 0;} static int nvs_get_i32(int n,const char *k,int32_t *v){*v=stored;return stored<0?-1:0;} static int nvs_set_i32(int n,const char *k,int32_t v){staged=v;return 0;} static int nvs_commit(int n){if(commit_error)return -1;commits++;stored=staged;strcpy(stored_name,staged_name);return 0;} static int nvs_set_str(int n,const char *k,const char *s){strcpy(staged_name,s);return 0;} static int nvs_get_str(int n,const char *k,char *out,size_t *size){if(read_error)return -1;size_t len=strlen(stored_name)+1;if(*size