Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example for remoteStopTransaction / remoteStartTransaction #22

Closed
zelix25 opened this issue Nov 23, 2022 · 3 comments
Closed

Example for remoteStopTransaction / remoteStartTransaction #22

zelix25 opened this issue Nov 23, 2022 · 3 comments

Comments

@zelix25
Copy link

zelix25 commented Nov 23, 2022

Hello, could you explain to me which function I must use to carry out the remoteStopTransaction / remoteStartTransaction commands via the central server?
I can't figure out how it works...

Thanks

@mikuso
Copy link
Owner

mikuso commented Nov 23, 2022

Hi,

It sounds like you're talking specifically about OCPP version 1.6 ?

RemoteStartTransaction and RemoteStopTransaction are calls sent from the server to the client.

Here's an example of how to set up an OCPP1.6 server which sends a RemoteStartTransaction request whenever a client connects:

const {RPCServer} = require('ocpp-rpc');

const server = new RPCServer({
    protocols: ['ocpp1.6'], // server accepts ocpp1.6 subprotocol
});

server.on('client', async (client) => {

    try {
        const response = await client.call('RemoteStartTransaction', {
            connectorId: 1, // start on connector 1
            idTag: 'XXXXXXXX', // using an idTag with identity 'XXXXXXXX'
        });

        if (response.status === 'Accepted') {
            console.log('Remote start worked!');
        } else {
            console.log('Remote start rejected.');
        }

    } catch (err) {
        console.log('Remote start errored:', err.message);
    }

});
    
server.listen(80); // listen on port 80

@zelix25
Copy link
Author

zelix25 commented Nov 23, 2022

Thank you for this quick response.
Indeed I am on ocpp 1.6.
I will try with your code thank you very much

@zelix25
Copy link
Author

zelix25 commented Nov 24, 2022

It's good, thank you 👍

@zelix25 zelix25 closed this as completed Nov 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants