Image

Image

Search This Blog

Friday, August 04, 2023

Generate pseudo-random, incremental serial numbers for motherboards

 

@echo off

    setlocal enableextensions disabledelayedexpansion

 

for /f "tokens=1,* delims=:" %%a in ('

        findstr /l /b /c:":::persist:::" "%~f0"

') do set "%%~b"

if not defined savedValue (

        set "savedValue=%random%" && ( call :persist.write savedValue )

)

    set /a savedValue=%savedValue%+1  && ( call :persist.write savedValue )

    ;;echo DEBUG: Recorded data %savedValue%

    set ss=DW173878110%savedValue%

    set bs=BTDN8389450%savedValue%

    set su=00020003000400050006000700080i%savedValue%

AMIDEWINx64.EXE /CM "My Corporation" /BM "My Corporation" /BV J83500-205 /BP NUC7i7DNB  /SM "My Corporation" /SV J85489-205 /SP NUC7i7DNHE /SS %ss% /BS %bs% /SU %su%

    timeout 10 /nobreak >nul

goto :eof

 

:persist.write varName

    if "%~1"=="" goto :eof

    for %%a in ("%temp%\%~nx0.%random%%random%%random%.tmp") do (

        findstr /l /v /b /c:":::persist::: %~1=" "%~f0" > "%%~fa"

        >"%~f0" (

            type "%%~fa"

            setlocal enabledelayedexpansion

            echo(:::persist::: %~1=!%~1!

            endlocal

        )

        del /q "%%~fa"

    )

    goto :eof

 

Friday, May 05, 2023

Pingresults

Ping a host once every X seconds and save the result in a csv:

 

 

@echo off
SETLOCAL

if [%1]==[/?] goto :help

::Set the address to ping
set address=%1
if [%1]==[] goto :fatal

::Set the destination filename
set filename=%2
if [%2]==[] set filename=pingres.csv

::Set delay between pings (seconds)
set delay=%3
if [%3]==[] set delay=30

:: some info
echo.
echo Running %0 %address% %filename% %delay% - press "Q" for at least %delay%s to quit.
echo.

:: Prepare csv header
echo Time, Target, Lag > %filename%

:loop
::Ping
for /F "tokens=7 delims== " %%l in ('ping -n 1 %address%^|findstr /i "time="') do set lag=%%l

::echo Current ping for %address%: %ping%
<nul set /p =.

::Set Timestamp
set curTime= %date:~0,4%/%DATE:~5,2%/%DATE:~8,3%-%time:~0,2%:%time:~3,2%:%time:~6,2%

::Write in .csv
echo %curTime%, %address%, %lag% >> %filename%

::delay
timeout /T %delay% /nobreak >nul

::keypress
choice /c QWERTY /d Y /t 1 /n >nul
if %errorlevel%==1 ( exit /B 0)

goto :loop

:help
echo.
echo Usage: %0 target resultfile delay
echo if not specified, resultfile is "pingres.csv" and delay is 30s

:fatal
echo.
echo You need to provide at least the hostname/IP of the target
echo type %0 /? for help
exit /B 1

ENDLOCAL

Sunday, April 09, 2023

Stop a service and wait for it to stop

 

@echo off
:: echo without NewLine
 <nul set /p =Please wait. Stopping Service...
 :: request stop service
sc stop "service we need to stop" >nul
:: wait up to 30 seconds for the service to stop
set a=1
set tmout=30
:retry
:: is it stopped ?
sc query "service we need to stop" | find "STOPPED"
if errorlevel 1 (
:: echo dots on the same line
 <nul set /p =.
 timeout 1 /nobreak >nul
 set /a a += 1
if %%a%% lss %%tmout%%  goto retry
)
:: allow one second to see the messages
timeout 1 /nobreak >nul

Friday, March 31, 2023

Reset ILO password without OS

If you have an OS installed is simple, just use hponcfg and you can change the password as explained in https://blog.toma.guru/2015/04/hp-ilo-linux-reset-password.html but if no OS is available, then hope is not lost, you can use the iLO Physical Presence Button.

On RX2800 Itanium iLO Physical Presence Button is hidden behind the small red hole

 

As stated on https://support.hpe.com/hpesc/public/docDisplay?docId=c02728748

The iLO 3 physical presence button enables to reset iLO 3 and reset the user-specific values to factory default values. A momentary press causes a soft reset of iLO 3 when the button is released. The iLO 3 Physical Presence button enables to reset iLO, enter TPM physical presence mode, and enter security override mode.

  • A momentary press of the button resets iLO and clears any security override or TPM physical presence mode that were initiated by this button.

  • A greater than 4 seconds less than 8 seconds, press of the button places the system in physical presence mode for up to 15 minutes.

  • A greater than 8 seconds less than 12 seconds, press of this button places iLO into security override mode for up to 15 minutes. Security override mode enables to enter iLO without being challenged for a password enabling to set up users.

    The UID LED blinks once after holding the button for 4 seconds and once after holding the button for 8 seconds to help gauge how long the button press has been held.

 

 

Sunday, December 18, 2022

Verify if the files refered by a variable in another files exists

If the file does not exist, rename the referencing file in *.BAD

SETLOCAL ENABLEDELAYEDEXPANSION 
::use local variables
set di=c:\temp
for %%f in (%di%\*.ctl) do ( 
::look in every file that ends in .ctl
for /f "tokens=1,* delims==" %%a in ('findstr /i "object_name=" "%%f"') do (
::get the name of the second file from the variable "object_name"
if not exist "%di%\%%b"(
 
::if the second file does not exist
move /y "%%f" "%%f.BAD" >>%di%\script_report.log 
::rename the .ctl file in .bad and let a trace in a logfile

                                             )  

                                                                                                                         )
                                           )
ENDLOCAL

 

 

type aaa.ctl:

[...]

 object_name=File.txt

[...]

Sunday, October 16, 2022

17

 another one. soon is already 20 :)

Sunday, July 17, 2022

Intel AMT revisited

 The old article refers to using the Intel AMT SDK and Real VNC Plus for connecting to the remote console, but a better solution is to use meshcommander - this allows you to control all the available devices in your local network form one place.

In order to install meshcommander, only NodeJS and the corresponding npm is needed, so it all resumes to:

mkdir ~/.meshcommander
cd ~/.meshcommander
npm install meshcommander 
 
then, to start, 
cd ~/.meshcommander/node_modules/meshcommander

node meshcommander
[--any (default is 127.0.0.1) --port (default is 3000)] 

and you can use the web console (http://localhost:3000):


 

 


Friday, June 24, 2022

EliteBook ambientlight sensor

Map keycode e033 (or any other key you choose) to the following command that toggles the sensor on or off:

echo $((1 - $(cat /sys/devices/platform/hp-wmi/als))) | sudo tee -a /sys/devices/platform/hp-wmi/als

Saturday, April 23, 2022

HiSilicon Hi3516Ev200 debrick

 HiSilicon Hi3516Ev200 camera gets bricked if tried to update the OpenIPC from the web interface running on :85, as the mtd block erase crashes the system during the process.

Download the latest build from github, unpack it and put it on the tftp directory.

wget https://github.com/OpenIPC/firmware/releases/download/latest/openipc.hi3516ev200-br.tgz | tar -zvx /tmp/tftboot

Set the local IP as 192.168.1.254

Start tftp server:   in.tftpd -L -vvvv -a 192.168.1.254:69 -s /tmp/tftpboot 

Connect the USBSerial adapter and configure minicom speed at 115200bps.


Connect power to the HiSilicon board and press CTRL+C

At the prompt, type:

setenv bootargs 'mem=${osmem:-32M} console=ttyAMA0,115200 panic=20 root=/dev/mtdblock3 rootfstype=squashfs init=/init mtdparts=hi_sfc:256k(boot),64k(env),2048k(kernel),5120k(rootfs),-(rootfs_data)'
setenv bootcmd 'setenv setargs setenv bootargs ${bootargs}; run setargs; sf probe 0; sf read 0x42000000 0x50000 0x200000; bootm 0x42000000'
setenv uk 'mw.b 0x42000000 ff 1000000; tftp 0x42000000 uImage.${soc} && sf probe 0; sf erase 0x50000 0x200000; sf write 0x42000000 0x50000 ${filesize}'
setenv ur 'mw.b 0x42000000 ff 1000000; tftp 0x42000000 rootfs.squashfs.${soc} && sf probe 0; sf erase 0x250000 0x500000; sf write 0x42000000 0x250000 ${filesize}'
setenv soc hi3516ev200
setenv osmem 32M
setenv totalmem 64M
setenv ipaddr 192.168.1.10
setenv serverip 192.168.1.254
saveenv
run uk; run ur; reset  
 
Enjoy!

Saturday, October 16, 2021

16

 and going...

Tuesday, June 01, 2021

Digium phone stuck on Contacting sip:proxy@IP:5060


Any normal/softphone works perfectly, but Sangoma (Digium) phones uses an SSL certificate to encrypt phone configuration messages. That certificate expired on May 28th, 2021. The certificate is embedded in the DPMA blob, so it can't be renewed.

Basically  this is the cost of putting binary blobs on your server :(

The solution is to download a new binary blob from digium and to replace the existing one in /usr/lib/asterisk/modules

check https://my.digium.com/en/docs/DPMA/dpma-download for the right DPMA module.


# cd /root
# wget http://downloads.digium.com/pub/telephony/res_digium_phone/asterisk-13.0/x86-32/

res_digium_phone-13.0_current-x86_32.tar.gz
# tar
res_digium_phone-13.0_current-x86_32.tar.gz        

# cp /root/res_digium_phone-13.0_current-x86_32/res_digium_phone.so /usr/lib/asterisk/modules


 # asterisk -rx "module reload res_digium_phone.so"

 

 

Wednesday, March 17, 2021

ESP Scale with calibration and tare

 #include "HX711.h"

#include "Wire.h"

#include "Adafruit_SSD1306.h"

#include "ESP8266WiFi.h"

#include "EEPROM.h"

#include "ESP8266httpUpdate.h"


#define SCREEN_WIDTH 128 

#define SCREEN_HEIGHT 32 

#define OLED_RESET     -1 

#define SCREEN_ADDRESS 0x3C 


#define upd_version "1"

#define upd_reboot true

#define upd_server "10.11.12.13"

#define upd_file "/update/scaleupd.php"


const int LOADCELL_DOUT_PIN = D4;

const int LOADCELL_SCK_PIN = D3;

const int TarePin = D5;

const int OverPin = D6;

const int GoodPin = D7;

const int UnderPin = D8;


int CalEepromAdress = 101;

int TarEepromAdress = 111;


float known_mass = 500;

float readValue = 0;

float calValue = 6192.2;// overrided by EEPROM or/and boot calibration

float tareValue = 472; // overrided by EEPROM or/and manual tare


const char* ssid = "myWiFi";

const char* password = "53cr37p4ssw0rd"; 


HX711 scale;

WiFiClient client;

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); //oled display uses std wire lib - for nodemcu SCL is D1(4), SDA is D2(5) (see pins_arduino.h)


void setup() {

  Serial.begin(115200);

  Serial.println("\nStarting...");

  display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);

  display.clearDisplay();

  display.setTextSize(2);             

  display.setTextColor(SSD1306_WHITE);

  display.setCursor(0, 0);

  display.println("Press to  Calibrate");

  display.display(); 


  pinMode(TarePin, INPUT_PULLUP);

  pinMode(OverPin, OUTPUT);

  pinMode(GoodPin, OUTPUT);

  pinMode(UnderPin, OUTPUT);

  

  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);

  delay(200); 

  scale.set_scale();

  scale.set_scale(calValue); 

  scale.tare();

 

  int wificnt = 0;

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED && wificnt < 10) {

   Serial.print (".");

   wificnt ++;

   delay(200);

  } //try 20sec to connect to Wifi in order to perform OTA update

  ESPhttpUpdate.rebootOnUpdate(upd_reboot);

  t_httpUpdate_return ret = ESPhttpUpdate.update(upd_server, 80, upd_file, upd_version);


  EEPROM.begin(512);

  EEPROM.get(CalEepromAdress, calValue);

  EEPROM.get(TarEepromAdress, tareValue);

 delay(2000); //Giving two sec to perform calibration at boot

  if(digitalRead(TarePin) == LOW){

   Serial.println("\nIn Calibration...");

   scale.set_scale();

   scale.tare();

   digitalWrite(UnderPin, HIGH); //turning all leds ON

   digitalWrite(OverPin, HIGH);

   digitalWrite(GoodPin, HIGH);

   display.clearDisplay();

   display.setCursor(0,0); 

   display.print("Calibrate with "); display.println(known_mass);

   display.display();      

   Serial.print("Calibrate with "); Serial.println(known_mass);

   delay(2000); //Two more seconds to release the button

   while (digitalRead(TarePin) == HIGH){ delay(200); Serial.print("."); } //Wait for the button to be pushed, after putting the calibrated weight on the scale

    calValue = (scale.get_units(10)) / known_mass;

    EEPROM.put(CalEepromAdress, calValue); //Save the calibration to EEPROM

    display.clearDisplay();

    display.setCursor(0,0); 

    display.print("Calibrated to "); display.println(calValue);

    display.display();

    Serial.print("\nCalibrated to "); Serial.println(calValue);

    scale.set_scale(calValue);

    delay(1000);

  }

  

  tareValue = (scale.get_units(20)); //Perform an initial tare

  scale.set_offset(tareValue);

  scale.tare();EEPROM.put(TarEepromAdress, tareValue); //Save TARE into EEPROM - not really needed here

  EEPROM.end();

 

}


void loop() {

 display.clearDisplay();

 

 if(digitalRead(TarePin) == LOW){ //if button pressed - perform tare

  Serial.println("\nTare...");

  digitalWrite(UnderPin, HIGH); //turn all leds on

  digitalWrite(GoodPin, HIGH);

  digitalWrite(OverPin, HIGH);

  

  tareValue = (scale.get_units(20)); 

  scale.set_offset(tareValue);

  display.clearDisplay();

  display.setTextSize(2);            

  display.setCursor(0,0);  

  display.print(" TARE to  "); display.println(tareValue);

  display.display(); 

  Serial.print("TARE to "); Serial.println(tareValue);

 } //end of TARE


 readValue = (scale.get_units(10) - tareValue);

 //readValue = (scale.read_average(20) - tareValue);

 Serial.println(readValue);


 display.clearDisplay();

 display.setTextSize(4);

 display.setCursor(5, 0);

 display.print(readValue); 

 display.setTextSize(2);

 display.setCursor(116, 17);

 display.println("g");

 display.display(); 


 digitalWrite(UnderPin, LOW); //turn all leds off

 digitalWrite(GoodPin, LOW);

 digitalWrite(OverPin, LOW);


 if(readValue < 3.49){

  digitalWrite(UnderPin, HIGH); //Red Led - below 3.5g 

 }

 if(readValue > 3.48 && readValue < 3.80){

  digitalWrite(GoodPin, HIGH); //Green Led - OK

 }

 if(readValue > 3.79){

  digitalWrite(OverPin, HIGH); //Blue Led - too heavy

 }  

//  delay(100);

}

 


 

Wednesday, February 03, 2021

ESP Scale pushing to server

 include "HX711.h"

#include "ESP8266WiFi.h"

#include "EEPROM.h"

#include "ESP8266httpUpdate.h"


#define upd_version "6a"

#define upd_reboot true

#define upd_server "123.45.67.89"

#define upd_file "/update/index.php"


const int LOADCELL_DOUT_PIN = D4;

const int LOADCELL_SCK_PIN = D3;


int CalEepromAdress = 101;

int TarEepromAdress = 111;

int DevEepromAdress = 121;


float calibrationValue = 442.06;// See ScaleCalibrate.ino for this. override by EEPROM

float tareValue = 472; // override by EEPROM

String thisScale = "LC000"; // override by EEPROM


char server[] = "123.45.67.90";

String uploadfile = "process.php";

String postVariable = "data=";

const char* ssid = "MyWiFi";

const char* password = "MyP@ssword";


HX711 scale;

WiFiClient client;

ADC_MODE(ADC_VCC);


void setup() {

//  Serial.begin(115200);

 

  EEPROM.begin(512);

  EEPROM.get(CalEepromAdress, calibrationValue);

  EEPROM.get(TarEepromAdress, tareValue);

  EEPROM.get(DevEepromAdress, thisScale);

  EEPROM.end();

 

  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);

  scale.set_scale(calibrationValue); 

  

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {

   delay(200);

  }


  ESPhttpUpdate.rebootOnUpdate(upd_reboot);

  t_httpUpdate_return ret = ESPhttpUpdate.update(upd_server, 80, upd_file, upd_version);


}


void loop() {

  String postData = postVariable + thisScale + "," + ESP.getVcc() + "," + (scale.get_units(10) - tareValue) + "," + upd_version;


  if (client.connect(server, 80)) {

    client.print("POST /");

    client.print(uploadfile);

    client.println(" HTTP/1.1");

    client.print("Host: ");

    client.println (server);

    client.println("Content-Type: application/x-www-form-urlencoded");

    client.print("Content-Length: ");

    client.println(postData.length());

    client.println();

    client.print(postData);

 }

  if (client.connected()) {

      client.stop();

  }

  scale.power_down();

  ESP.deepSleep(300e6);

}

Saturday, January 02, 2021

ESP OTA update - server side

 <?php

date_default_timezone_set('America/New_York');

header('Content-type: text/plain; charset=utf8', true);

 

$pattern = ".php";

$debuglog = "/var/log/ESP8266-ESPUpdate.log";

 

//update files must be named "LoadCell-$Version_number.bin"

foreach(glob('./bin/LoadCell*.{bin}', GLOB_BRACE) as $filename){

     $filenm = pathinfo($filename, PATHINFO_FILENAME);

     $arr = explode('-', $filenm);

     $upd_version  = $arr[ count($arr) -1 ];

     error_log("\n".'['.date('Y-M-d H:m:s').'] Filename: '.$filename.' Shortname: '.$filenm.' Version: '.$upd_version."\n", 3, $debuglog);

}

 

function check_header($name, $value = false) {

    if(!isset($_SERVER[$name])) {

        return false;

    }

    if($value && $_SERVER[$name] != $value) {

        return false;

    }

    return true;

}

 

function sendFile($path) {

    header($_SERVER["SERVER_PROTOCOL"].' 200 OK', true, 200);

    header('Content-Type: application/octet-stream', true);

    header('Content-Disposition: attachment; filename='.basename($path));

    header('Content-Length: '.filesize($path), true);

    header('x-MD5: '.md5_file($path), true);

    readfile($path);

}

 

if(!check_header('HTTP_USER_AGENT', 'ESP8266-http-Update'))

{

    header($_SERVER["SERVER_PROTOCOL"].' 403 Forbidden', true, 403);

    echo "only for ESP8266 updater! (UA)\n";

    error_log("\n".'['.date('YYYY-MM-dd HH:mm:ss').'] Not correct user_agent.\n\n', 3, $debuglog);

    exit();

}

 

if(

    !check_header('HTTP_X_ESP8266_STA_MAC') ||

    !check_header('HTTP_X_ESP8266_AP_MAC') ||

    !check_header('HTTP_X_ESP8266_FREE_SPACE') ||

    !check_header('HTTP_X_ESP8266_SKETCH_SIZE') ||

    !check_header('HTTP_X_ESP8266_SKETCH_MD5') ||

    !check_header('HTTP_X_ESP8266_CHIP_SIZE') ||

    !check_header('HTTP_X_ESP8266_SDK_VERSION')

) {

    header($_SERVER["SERVER_PROTOCOL"].' 403 Forbidden', true, 403);

    echo "only for ESP8266 updater! (header)\n";

    error_log("\n".'['.date('Y-M-d H:m:s').'] Not correct headers.\n\n', 3, $debuglog);

    exit();

}

 

//    foreach (getallheaders() as $name => $value) {

//    error_log("\n".'['.date('Y-M-d H:m:s').'] Header_name: '.$name.": \t".$value, 3, $debuglog);

//    }

 

if (($_SERVER['HTTP_X_ESP8266_VERSION']) < $upd_version && $_SERVER["HTTP_X_ESP8266_SKETCH_MD5"] != md5_file($filename)) {

    sendFile($filename);

    error_log("\n".'['.date('Y-M-d H:m:s').'] NEED UPDATE! ', 3, $debuglog);

    error_log("\n".'['.date('Y-M-d H:m:s').'] Ver on server: '.($upd_version).' Ver remote: '.($_SERVER['HTTP_X_ESP8266_VERSION']), 3, $debuglog);

    error_log("\n".'['.date('Y-M-d H:m:s').'] MD5 on server: '.(md5_file($filename)).' Value remote: '.($_SERVER['HTTP_X_ESP8266_SKETCH_MD5'])."\n", 3, $debuglog);

} else {

    error_log("\n".'['.date('Y-M-d H:m:s').'] NO NEED. Ver equal, small or same MD5', 3, $debuglog);

    error_log("\n".'['.date('Y-M-d H:m:s').'] Ver on server: '.($upd_version).' Ver remote: '.($_SERVER['HTTP_X_ESP8266_VERSION']), 3, $debuglog);

    error_log("\n".'['.date('Y-M-d H:m:s').'] MD5 on server: '.(md5_file($filename)).' Value remote: '.($_SERVER['HTTP_X_ESP8266_SKETCH_MD5'])."\n", 3, $debuglog);

}

 

?>

Wednesday, December 02, 2020

ESP WiFi sniffer with OLED and http upload

#include "ESP8266WiFi.h"
#include "oled.h"
ADC_MODE(ADC_VCC);
OLED Display=OLED(D1,D2);
int RawPort = A0;
char server[] = "192.168.1.101";
String uploadfile = "wifi.php";
String postVariable = "WiFi=";
const char* ssid = "MyWiFi";
const char* password = "P@55w0rd";
String total = "";
void setup() {
//  Serial.begin(115200);
//  Serial.println("");
  Display.begin();
  Display.setTTYMode(true);
  pinMode(LED_BUILTIN, OUTPUT);
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);
  Display.print("Battery: ");
  Display.print(ESP.getVcc());
//  Display.print("\n\rSetup done");
}
void loop() {
//  int Batt = ESP.getVcc();
//  Serial.print("Battery voltage is: "+Batt);
//  Display.print(ESP.getVcc());
//  Serial.print("Wifi scan...");
  Display.set_contrast(128);
  Display.print("\n\rScan...");
  int n = WiFi.scanNetworks();
//  Serial.println(" done");
  Display.println(" done");
  if (n == 0) {
//    Serial.println("No Networks Found");
    Display.printf("No Networks Found");
    digitalWrite(LED_BUILTIN, LOW);
  }
  else {
//    Serial.print(n);
//    Serial.println(" Networks found");
    digitalWrite(LED_BUILTIN, HIGH);
    Display.set_contrast(8);
    Display.printf("%d networks found",n);
    String nr = String(n) + " APs detected. ";
    for (int i = 0; i < n; ++i) {
//      Serial.print(i + 1);
//      Serial.print(": ");
//      Serial.print(WiFi.SSID(i));
//      Serial.print(" RSSI: ");
//      Serial.print(WiFi.RSSI(i)); 
//      Serial.print(" MAC: ");
//      Serial.print(WiFi.BSSIDstr(i));
//      Serial.print(" Enc: ");
//      Serial.println(encType(i));
    Display.println();
    Display.print(i + 1);
    Display.print(": ");
    Display.print(WiFi.SSID(i));
    Display.print(" (");
    Display.print(WiFi.RSSI(i));
    Display.println(")");
    Display.print("   ");
    Display.print(WiFi.BSSIDstr(i));
    total = total+String(i+1)+": "+String(WiFi.SSID(i))+" "+String(WiFi.BSSIDstr(i))+" "+String(WiFi.RSSI(i))+"db "+String(encType(i))+". ";
    delay(500);
    }
 
    WiFi.scanDelete();
    delay (500);
    Display.println("\n\rSleep for 1min...");
    
    WiFiClient client;
    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {
     delay(500);
    }
    
    
    String postData = postVariable + nr + total;
//    Serial.print("Transmitted data: ");
//    Serial.println(postData);
    
    if (client.connect(server, 80)) {
     client.print("POST /");
     client.print(uploadfile);
     client.println(" HTTP/1.1");
     client.print("Host: ");
     client.println (server);
     client.println("Content-Type: application/x-www-form-urlencoded");
     client.print("Content-Length: ");
     client.println(postData.length());
     client.println();
     client.print(postData);
    }
    if (client.connected()) {
      client.stop();
    }
//   Serial.println("Sleeping ");
   Display.set_power(false);
//   delay(10000);
   ESP.deepSleep(6e+7); // 60 sec  
  }
}
// Readable Encryption Type
String encType(int id){
String type;
  if(WiFi.encryptionType(id) == ENC_TYPE_WEP){ type=" WEP";
  }else if(WiFi.encryptionType(id) == ENC_TYPE_TKIP){ type="WPA-TKIP";    
  }else if(WiFi.encryptionType(id) == ENC_TYPE_CCMP){ type="WPA2-CCMP";    
  }else if(WiFi.encryptionType(id) == ENC_TYPE_AUTO){ type="WPA-WPA2";    
  }else if(WiFi.encryptionType(id) == ENC_TYPE_NONE){ type="OPEN";    
  }
  return type;
}




$cat wifi.php
<?php
$file = fopen("/var/www/html/wifi.txt", "a+") or die("Unable to open file!");
date_default_timezone_set("America/New_York");
$time = date('Y-m-d_H:i:s');
$read = $_POST["WiFi"];
$data = "{$time} - {$read}\n";
fwrite($file, $data);
fclose($file);
?>




Blog Archive