DeltaVetal26 / SteVe-OCPP-HTTP-Client

Basic HTTP client for sending commands remotely to the Steve OCPP control panel
10 stars 8 forks source link

How to use it? #5

Open 204maker opened 2 years ago

204maker commented 2 years ago

How do I use the script with a computer running on Windows 10?

204maker commented 2 years ago

What information needs to be on the "youraddress" line on the curl command?

DeltaVetal26 commented 2 years ago

Hi, @204maker

Sorry for the long answer. Your address is the address where this script is located.

For example: 'curl "http://localhost/main.php?key=1234&ChargeBoxID=Ecc029&cmd=getConnectorState&ConnectorID=2"' 'curl "http://localhost:8090/main.php?key=1234&ChargeBoxID=Ecc029&cmd=getConnectorState&ConnectorID=2"' 'curl "http://mydomain.com/main.php?key=1234&ChargeBoxID=Ecc029&cmd=getConnectorState&ConnectorID=2"' 'curl "http://192.168.1.1:8090/main.php?key=1234&ChargeBoxID=Ecc029&cmd=getConnectorState&ConnectorID=2"'

I have hosted this script on a web host. To run php scripts on your own computer, you must have a local web server or php interpreter installed.

https://stackoverflow.com/questions/8580273/how-to-run-php-files-on-my-computer

Apache or XAMPP are one common choice. Next, you place main.php in a folder (for XAMPP, the path is described there), and specify 'localhost' in your address.

DeltaVetal26 commented 2 years ago

@204maker,

Instruction (checked on my PC):

  1. Download XAMPP (7.3.31) (WebServer for PC): https://www.apachefriends.org/download.html Select V7.3.31, here PHP version 7, version 8 is not currently supported with this script.

1

  1. Install XAMPP. If you only need a web server to run this script, leave only PHP and Apache in the parameters. If you need databases, you can choose the rest.

2

  1. Start XAMPP. In the XAMPP panel, on the Apache line, click Start. Most likely, the log will indicate that port 80 is busy by another application. To do this, you should change the Apache port. In the Apache line, click "Config", "Apache (httpd.conf)". In the file, we are looking for all the settings where port 80 is indicated (there are two of them): 'Listen 80' - change to 'Listen 8080' 'ServerName localhost:80' - change to 'ServerName localhost:8080' Save.

Changed the web server port from 80 to 8080.

  1. Put the configured script 'main.php' in your web server folder. On the XAMPP panel on the "Explorer" button, the "htdocs" folder. We put our script there.

  2. Launch Apache (Start). If it has started, it will light up green.

  3. You can refer to the script through cmd or a browser. In "youraddress" we specify "localhost:8080"

Example: 'curl "http://localhost:8080/main.php?key=1234&ChargeBoxID=Ecc029&cmd=getConnectorState&ConnectorID=2"' Should return the state of the plug.

204maker commented 2 years ago

Thank you @DeltaVetal26. It worked! The step-by-step instructions were super helpful. Thanks a lot.

DeltaVetal26 commented 2 years ago

@204maker , You are welcome. I'm glad it worked out ;)

vinz-uts commented 2 years ago

Hi. I'm trying to use the main.php script to simulate REST request to steve, but I'm new in php and I've some problems. Can anyone help me to understand how to run this script? I'm using Linux, I've already installed php and curl, and I downloaded the main.php file (now it is in my /home folder). My pc is 192.168.1.10, whereas steve is running on another pc on my local network (IP: 192.168.1.12) and I would to run the main.php script to simulate a start transaction using:

> curl "http://youraddress/main.php?key=YourKey&ChargeBoxID=001&cmd=RemoteStartTransaction&ConnectorID=2&idTag=ABCDE"

what is the <youraddress> that I've to use? Have I to use my ip address, like:

> curl "http://192.168.1.10/main.php?key=YourKey&ChargeBoxID=001&cmd=RemoteStartTransaction&ConnectorID=2&idTag=ABCDE"

? I've modified the parameters in main.php as follow:

$steveServerAddres = 'http://192.168.1.12:8080';
  $steveLogin = 'admin';
  $stevePass = '1234';
  $authKey = '123456789abc';                                <--   random value or it must be equal to something?
  $ocppProtocol = 'JSON'; // or JSON
  $ocppVersion = 'v1.6';  // or 1.6
  $supervision = 'steve';
  // Only for SOAP use - charge point endpoint url
  // Write here your charge point endpoint url
  $endpointURL = 'http://localhost:9090/ocpp'; // (ex: http://localhost:9090/ocpp)          <--      who is it?

Does YourKey have to match with authKey?

Thanks for your help, I'm very confused about it!