[Ovmsdev] OVMS Server 3.0.001-14-g54850ef

Mark Webb-Johnson mark at webb-johnson.net
Mon Mar 16 16:59:06 HKT 2020

A big update to the v3 OVMS Server.

I re-factored the ApiV2 plugin to move all the connection information to Core, and made it shareable between modules. This includes virtualising the actions to receive and transmit data from connections. The advantage here is that vehicles and apps no longer need to use the same protocol. So for example, this should allow an HTTP API App to connect to a v2 api vehicle. The HTTP API has been held back for some time because of this, but it will also affect MQTT connections.

If anyone is using ‘db’ style function callbacks, please note the new ‘Db’ standardised prefix (before some were db and others were Db - messy).

A lot of little bug fixes and cleanups were made at the same time. I hope it hasn’t broken anything.

The first use of #1 is to implement websockets for apiv2. The standard server now supports this as ‘ws://api.openvehicles.com:6867/apiv2' <ws://api.openvehicles.com:6867/apiv2'> and ‘wss://api.openvehicles.com:6870/apiv2' <wss://api.openvehicles.com:6870/apiv2'>. For example:

% wsta -p 60 --ping-msg 'A' -I wss://api.openvehicles.com:6870/apiv2/
WebSocket upgrade request
Host: api.openvehicles.com:6870
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: UWfgAzvxoM/cyT35flkuIA==
Origin: https://api.openvehicles.com

WebSocket upgrade response
101 Switching Protocols
Upgrade: WebSocket
Connection: Upgrade
Sec-WebSocket-Accept: lHNFo4fdGzWc/GfTq7bJXm7jamw=

Connected to wss://api.openvehicles.com:6870/apiv2/

MP-A 1 <username> <password> DEMO
MP-S 1 <username> DEMO DEMO CAR2 CAR3 CAR4 ...

It works by picking up the HTTP 'GET /apiv2/ HTTP/1.1’ line as the first line of the protocol negotiation (where it was expecting MP-C, MP-A, etc). If found, it will switch to handshake a websocket connection, and from then onwards websocket messages are simply apiv2 lines (without the CRLF). When combined with SSL and crypto 0x31 authentication, it is pretty cool (as seen above).

You will need to include the perl library Protocol::WebSocket (from cpan/package/etc).

I also extended the crypto 0x31 mechanism to send the list of accessible vehicle IDs (as well as the selected vehicle ID). This should be very useful for Apps and Cars to be able to auto-discover the available vehicles on the account. Remember that ‘*’ can be used to auto-select the first vehicle on the account. So you can send ‘MP-A 1 <username> <password> *’, and get back a connection to the first vehicle plus a list of alternatives vehicles available.

This has been a lot of work putting together the pieces for something more interesting. More on that in a subsequent mailing (but you can probably guess)...

Regards, Mark.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvehicles.com/pipermail/ovmsdev/attachments/20200316/d6513a8c/attachment.html>

More information about the OvmsDev mailing list