Skip to content

Commit 218159b

Browse files
committed
Rename web_mqtt to web_ocpp
- remove mqtt protocol specific state - remove keepalive - remove credit_flow logic - bind client_id param from URL - handle/parse/decode OCPP JSON message and log it
1 parent e78dbf9 commit 218159b

12 files changed

+397
-335
lines changed

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
11
test/config_schema_SUITE_data/schema/
2+
.DS_Store
3+
.sw?
4+
.*.sw?
5+
*.beam
6+
/.erlang.mk/
7+
/cover/
8+
/deps/
9+
/doc/
10+
/ebin/
11+
/escript/
12+
/escript.lock
13+
/logs/
14+
/plugins/
15+
/plugins.lock
16+
/sbin/
17+
/sbin.lock
18+
19+
/rabbitmq_web_ocpp.d
20+
21+
/.bazelrc
22+
/bazel-*

CODE_OF_CONDUCT.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

CONTRIBUTING.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

Makefile

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
PROJECT = rabbitmq_web_mqtt
2-
PROJECT_DESCRIPTION = RabbitMQ MQTT-over-WebSockets adapter
3-
PROJECT_MOD = rabbit_web_mqtt_app
1+
PROJECT = rabbitmq_web_ocpp
2+
PROJECT_DESCRIPTION = RabbitMQ OCPP-J-to-AMQP adapter
3+
PROJECT_MOD = rabbit_web_ocpp_app
44

55
define PROJECT_ENV
66
[
7-
{tcp_config, [{port, 15675}]},
7+
{tcp_config, [{port, 19520}]},
88
{ssl_config, []},
99
{num_tcp_acceptors, 10},
1010
{num_ssl_acceptors, 10},
@@ -13,30 +13,22 @@ define PROJECT_ENV
1313
]
1414
endef
1515

16-
# We do not need QUIC as dependency of emqtt.
17-
BUILD_WITHOUT_QUIC=1
18-
export BUILD_WITHOUT_QUIC
19-
2016
LOCAL_DEPS = ssl
21-
DEPS = rabbit cowboy rabbitmq_mqtt
22-
TEST_DEPS = emqtt rabbitmq_ct_helpers rabbitmq_ct_client_helpers rabbitmq_management rabbitmq_stomp rabbitmq_consistent_hash_exchange
17+
DEPS = rabbit cowboy
18+
TEST_DEPS = rabbitmq_ct_helpers rabbitmq_ct_client_helpers rabbitmq_management rabbitmq_stomp rabbitmq_consistent_hash_exchange
2319

24-
PLT_APPS += rabbitmqctl elixir cowlib
20+
PLT_APPS += rabbitmq_cli elixir cowlib
2521

2622
# FIXME: Add Ranch as a BUILD_DEPS to be sure the correct version is picked.
2723
# See rabbitmq-components.mk.
2824
BUILD_DEPS += ranch
2925

30-
dep_emqtt = git https://github.com/emqx/emqtt.git 1.11.0
31-
3226
DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk
3327
DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk
3428

35-
include ../../rabbitmq-components.mk
36-
include ../../erlang.mk
37-
38-
# We are using mqtt_shared_SUITE from rabbitmq_mqtt.
39-
CT_OPTS += -pa ../rabbitmq_mqtt/test/
29+
# The monorepo structure of RabbitMQ does not work for OOT plugins.
30+
DEPS_DIR ?= $(abspath ../rabbitmq-server/deps)
31+
ERLANG_MK_TMP ?= $(abspath ./.erlang.mk)
4032

41-
test-build::
42-
$(verbose) $(MAKE) -C ../rabbitmq_mqtt test-dir
33+
include ../rabbitmq-server/rabbitmq-components.mk
34+
include ../rabbitmq-server/erlang.mk

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
# RabbitMQ Web MQTT plugin
1+
# RabbitMQ Web OCPP plugin
22

3-
This plugin provides support for MQTT-over-WebSockets to RabbitMQ.
3+
This plugin provides is a thin translator layer for OCPP-over-WebSockets to RabbitMQ AMQP protocol. Both version `1.6J` and `2.x` should be supported as the base JSON format array was kept backwards compatible, even tho many of the action names and payload are changed.
44

55
## Installation
66

7-
This plugin ships with modern versions of RabbitMQ.
7+
This plugin works only with modern versions of RabbitMQ 4.x based on AMQP 1.0.
88
Like all plugins, it [must be enabled](https://www.rabbitmq.com/plugins.html) before it can be used:
99

1010
``` bash
1111
# this might require sudo
12-
rabbitmq-plugins enable rabbitmq_web_mqtt
12+
rabbitmq-plugins enable rabbitmq_web_ocpp
1313
```
1414

1515
## Documentation
1616

17-
Please refer to the [RabbitMQ Web MQTT guide](https://www.rabbitmq.com/web-mqtt.html).
17+
For all configuration options, please refer to the nearly identical plugin, [RabbitMQ Web MQTT guide](https://www.rabbitmq.com/web-mqtt.html).
1818

1919

2020
## Building From Source

include/rabbit_web_ocpp.hrl

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
%% This Source Code Form is subject to the terms of the Mozilla Public
2+
%% License, v. 2.0. If a copy of the MPL was not distributed with this
3+
%% file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
%%
5+
%% Copyright (c) 2025 VAMPIRE BYTE SRL. All Rights Reserved.
6+
%%
7+
8+
-type option(T) :: undefined | T.
9+
10+
%% WebSocket Subprotocol Name Registry
11+
%% https://www.iana.org/assignments/websocket/websocket.xml
12+
-define(OCPP_SUPPORTED_PROTOCOLS, [<<"ocpp1.2">>, <<"ocpp1.5">>, <<"ocpp1.6">>, <<"ocpp2.0">>, <<"ocpp2.0.1">>, <<"ocpp2.1">>]).
13+
14+
-define(OCPP_PROTO_V12, ocpp12).
15+
-define(OCPP_PROTO_V15, ocpp15).
16+
-define(OCPP_PROTO_V16, ocpp16).
17+
-define(OCPP_PROTO_V20, ocpp20).
18+
-define(OCPP_PROTO_V201, ocpp201).
19+
-define(OCPP_PROTO_V21, ocpp21).
20+
21+
-type ocpp_protocol_version_atom() ::
22+
?OCPP_PROTO_V12
23+
| ?OCPP_PROTO_V15
24+
| ?OCPP_PROTO_V16
25+
| ?OCPP_PROTO_V20
26+
| ?OCPP_PROTO_V201
27+
| ?OCPP_PROTO_V21.
28+
29+
-define(OCPP_MESSAGE_TYPE_CALL, 2). % Request
30+
-define(OCPP_MESSAGE_TYPE_CALLRESULT, 3). % Response success
31+
-define(OCPP_MESSAGE_TYPE_CALLERROR, 4). % Response error
32+
-define(OCPP_MESSAGE_TYPE_CALLRESULTERROR, 5). % OCPP 2.1 only
33+
-define(OCPP_MESSAGE_TYPE_SEND, 6). % OCPP 2.1 only
34+
35+
-define(ITEMS,
36+
[pid,
37+
protocol,
38+
host,
39+
port,
40+
peer_host,
41+
peer_port,
42+
ssl,
43+
ssl_protocol,
44+
ssl_key_exchange,
45+
ssl_cipher,
46+
ssl_hash,
47+
vhost,
48+
user
49+
]).
50+
51+
-define(INFO_ITEMS,
52+
?ITEMS ++
53+
[
54+
client_id,
55+
conn_name,
56+
user_property,
57+
connection_state,
58+
ssl_login_name,
59+
recv_cnt,
60+
recv_oct,
61+
send_cnt,
62+
send_oct,
63+
send_pend,
64+
clean_sess,
65+
will_msg,
66+
retainer_pid,
67+
exchange,
68+
prefetch,
69+
messages_unconfirmed,
70+
messages_unacknowledged
71+
]).
72+
73+
%% Connection opened or closed.
74+
-define(EVENT_KEYS,
75+
?ITEMS ++
76+
[name,
77+
client_properties,
78+
peer_cert_issuer,
79+
peer_cert_subject,
80+
peer_cert_validity,
81+
auth_mechanism,
82+
timeout,
83+
frame_max,
84+
channel_max,
85+
connected_at,
86+
node,
87+
user_who_performed_action
88+
]).
89+
90+
-define(SIMPLE_METRICS,
91+
[pid,
92+
recv_oct,
93+
send_oct,
94+
reductions]).
95+
-define(OTHER_METRICS,
96+
[recv_cnt,
97+
send_cnt,
98+
send_pend,
99+
garbage_collection,
100+
state]).

0 commit comments

Comments
 (0)