Skip to content

Commit 0ab97af

Browse files
authored
Victron Blue Smart Charger (#634)
1 parent 09b8f81 commit 0ab97af

File tree

6 files changed

+221
-15
lines changed

6 files changed

+221
-15
lines changed

docs/devices/VICTRON_BSC.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Victron Energy Blue Smart Charger
2+
3+
|Model Id|[VICTBSC](https://github.com/theengs/decoder/blob/development/src/devices/VICTRON_BSC_json.h)|
4+
|-|-|
5+
|Brand|Victron Energy|
6+
|Model|Blue Smart Charger|
7+
|Short Description|Various Blue Smart Charger models|
8+
|Communication|BLE broadcast|
9+
|Frequency|2.4Ghz|
10+
|Power Source|AC mains|
11+
|Exchanged Data|device state, voltage battery 1, current battery 1, voltage battery 2, current battery 2, voltage battery 3, current battery 3, temperature, current ac, error code|
12+
|Encrypted|Yes|

src/decoder.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,12 @@ class TheengsDecoder {
165165
SPHT,
166166
SERVICE_DATA,
167167
UT363BT,
168-
VICTSBP_ENCR,
169-
VICTSBP,
168+
VICTBSC_ENCR,
169+
VICTBSC,
170170
VICTORIONXS_ENCR,
171171
VICTORIONXS,
172+
VICTSBP_ENCR,
173+
VICTSBP,
172174
SE_RHT,
173175
SE_TEMP,
174176
SE_TPROBE,

src/devices.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,12 @@
115115
#include "devices/SensorP_HT_json.h"
116116
#include "devices/ServiceData_json.h"
117117
#include "devices/UT363BT_json.h"
118-
#include "devices/VICTRON_SBP_ENCR_json.h"
119-
#include "devices/VICTRON_SBP_json.h"
118+
#include "devices/VICTRON_BSC_ENCR_json.h"
119+
#include "devices/VICTRON_BSC_json.h"
120120
#include "devices/VICTRON_ORIONXS_ENCR_json.h"
121121
#include "devices/VICTRON_ORIONXS_json.h"
122+
#include "devices/VICTRON_SBP_ENCR_json.h"
123+
#include "devices/VICTRON_SBP_json.h"
122124
#include "devices/SE_RHT_json.h"
123125
#include "devices/SE_TEMP_json.h"
124126
#include "devices/SE_TPROBE_json.h"
@@ -255,10 +257,12 @@ const char* _devices[][2] = {
255257
{_SensorPush_HT_json, _SensorPush_HT_json_props},
256258
{_ServiceData_json, _ServiceData_json_props},
257259
{_UT363BT_json, _UT363BT_json_props},
258-
{_VICTSBP_ENCR_json, _VICTSBP_ENCR_json_props},
259-
{_VICTSBP_json, _VICTSBP_json_props},
260+
{_VICTBSC_ENCR_json, _VICTBSC_ENCR_json_props},
261+
{_VICTBSC_json, _VICTBSC_json_props},
260262
{_VICTORIONXS_ENCR_json, _VICTORIONXS_ENCR_json_props},
261263
{_VICTORIONXS_json, _VICTORIONXS_json_props},
264+
{_VICTSBP_ENCR_json, _VICTSBP_ENCR_json_props},
265+
{_VICTSBP_json, _VICTSBP_json_props},
262266
{_SE_RHT_json, _SE_RHT_json_props},
263267
{_SE_TEMP_json, _SE_TEMP_json_props},
264268
{_SE_TPROBE_json, _SE_TPROBE_json_props},
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const char* _VICTBSC_ENCR_json = "{\"brand\":\"Victron Energy\",\"model\":\"Blue Smart Charger encrypted\",\"model_id\":\"VICTBSC_ENCR\",\"tag\":\"140003\",\"condition\":[\"manufacturerdata\",\"=\",46,\"index\",0,\"e10210\",\"&\",\"manufacturerdata\",\"index\",12,\"08\"],\"properties\":{\"cipher\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",20,26]},\"ctr\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",14,4,true]},\"mic\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",18,2]}}}";
2+
/*R""""(
3+
{
4+
"brand":"Victron Energy",
5+
"model":"Blue Smart Charger encrypted",
6+
"model_id":"VICTBSC_ENCR",
7+
"tag":"140003",
8+
"condition":["manufacturerdata", "=", 46, "index", 0, "e10210", "&", "manufacturerdata", "index", 12, "08"],
9+
"properties":{
10+
"cipher":{
11+
"decoder":["string_from_hex_data", "manufacturerdata", 20, 26]
12+
},
13+
"ctr":{
14+
"decoder":["string_from_hex_data", "manufacturerdata", 14, 4, true]
15+
},
16+
"mic":{
17+
"decoder":["string_from_hex_data", "manufacturerdata", 18, 2]
18+
}
19+
}
20+
})"""";*/
21+
22+
const char* _VICTBSC_ENCR_json_props = "{\"properties\":{\"cipher\":{\"unit\":\"hex\",\"name\":\"ciphertext\"},\"ctr\":{\"unit\":\"hex\",\"name\":\"counter\"},\"mic\":{\"unit\":\"hex\",\"name\":\"message integrity check\"}}}";
23+
/*R""""(
24+
{
25+
"properties":{
26+
"cipher":{
27+
"unit":"hex",
28+
"name":"ciphertext"
29+
},
30+
"ctr":{
31+
"unit":"hex",
32+
"name":"counter"
33+
},
34+
"mic":{
35+
"unit":"hex",
36+
"name":"message integrity check"
37+
}
38+
}
39+
})"""";*/

src/devices/VICTRON_BSC_json.h

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
const char* _VICTBSC_json = "{\"brand\":\"Victron Energy\",\"model\":\"Blue Smart Charger\",\"model_id\":\"VICTBSC\",\"tag\":\"1400\",\"condition\":[\"manufacturerdata\",\"=\",46,\"index\",0,\"e10211\",\"&\",\"manufacturerdata\",\"index\",12,\"08ffff\"],\"properties\":{\"device_state\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",20,2]},\"_device_state\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",20,2],\"lookup\":[\"00\",\"off\",\"01\",\"low power\",\"02\",\"fault\",\"03\",\"bulk\",\"04\",\"absorption\",\"05\",\"float\",\"06\",\"storage\",\"07\",\"equalize manual\",\"09\",\"inverting\",\"0b\",\"power supply\",\"f5\",\"starting up\",\"f6\",\"repeated absorption\",\"f7\",\"recondition\",\"f8\",\"battery safe\",\"f9\",\"active\",\"fc\",\"external control\",\"ff\",\"N/A\"]},\"volt_batt_1\":{\"condition\":[\"manufacturerdata\",24,\"!\",\"ffff\"],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",24,4,true,false],\"post_proc\":[\"&\",8191,\"/\",100]},\"current_batt_1\":{\"condition\":[\"manufacturerdata\",26,\"!\",\"ffff\"],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",26,4,true,false],\"post_proc\":[\">\",5,\"&\",2047,\"/\",10]},\"volt_batt_2\":{\"condition\":[\"manufacturerdata\",30,\"!\",\"ffff\"],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",30,4,true,false],\"post_proc\":[\"&\",8191,\"/\",100]},\"current_batt_2\":{\"condition\":[\"manufacturerdata\",32,\"!\",\"ffff\"],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",32,4,true,false],\"post_proc\":[\">\",5,\"&\",2047,\"/\",10]},\"volt_batt_3\":{\"condition\":[\"manufacturerdata\",36,\"!\",\"ffff\"],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",36,4,true,false],\"post_proc\":[\"&\",8191,\"/\",100]},\"current_batt_3\":{\"condition\":[\"manufacturerdata\",38,\"!\",\"ffff\"],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",38,4,true,false],\"post_proc\":[\">\",5,\"&\",2047,\"/\",10]},\"tempc\":{\"condition\":[\"manufacturerdata\",42,\"!\",\"ff\"],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",42,2],\"post_proc\":[\"&\",127,\"-\",40]},\"current_ac\":{\"condition\":[\"manufacturerdata\",44,\"!\",\"ff\"],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",42,4,false,false],\"post_proc\":[\"&\",511,\"/\",10]},\"error_code\":{\"condition\":[\"manufacturerdata\",22,\"!\",\"ff\"],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",22,2]}}}";
2+
/*R""""(
3+
{
4+
"brand":"Victron Energy",
5+
"model":"Blue Smart Charger",
6+
"model_id":"VICTBSC",
7+
"tag":"1400",
8+
"condition":["manufacturerdata", "=", 46, "index", 0, "e10211", "&", "manufacturerdata", "index", 12, "08ffff"],
9+
"properties":{
10+
"device_state":{
11+
"decoder":["value_from_hex_data", "manufacturerdata", 20, 2]
12+
},
13+
"_device_state":{
14+
"decoder":["string_from_hex_data", "manufacturerdata", 20, 2],
15+
"lookup":["00", "off",
16+
"01", "low power",
17+
"02", "fault",
18+
"03", "bulk",
19+
"04", "absorption",
20+
"05", "float",
21+
"06", "storage",
22+
"07", "equalize manual",
23+
"09", "inverting",
24+
"0b", "power supply",
25+
"f5", "starting up",
26+
"f6", "repeated absorption",
27+
"f7", "recondition",
28+
"f8", "battery safe",
29+
"f9", "active",
30+
"fc", "external control",
31+
"ff", "N/A"]
32+
},
33+
"volt_batt_1":{
34+
"condition":["manufacturerdata", 24, "!", "ffff"],
35+
"decoder":["value_from_hex_data", "manufacturerdata", 24, 4, true, false],
36+
"post_proc":["&", 8191, "/", 100]
37+
},
38+
"current_batt_1":{
39+
"condition":["manufacturerdata", 26, "!", "ffff"],
40+
"decoder":["value_from_hex_data", "manufacturerdata", 26, 4, true, false],
41+
"post_proc":[">", 5, "&", 2047, "/", 10]
42+
},
43+
"volt_batt_2":{
44+
"condition":["manufacturerdata", 30, "!", "ffff"],
45+
"decoder":["value_from_hex_data", "manufacturerdata", 30, 4, true, false],
46+
"post_proc":["&", 8191, "/", 100]
47+
},
48+
"current_batt_2":{
49+
"condition":["manufacturerdata", 32, "!", "ffff"],
50+
"decoder":["value_from_hex_data", "manufacturerdata", 32, 4, true, false],
51+
"post_proc":[">", 5, "&", 2047, "/", 10]
52+
},
53+
"volt_batt_3":{
54+
"condition":["manufacturerdata", 36, "!", "ffff"],
55+
"decoder":["value_from_hex_data", "manufacturerdata", 36, 4, true, false],
56+
"post_proc":["&", 8191, "/", 100]
57+
},
58+
"current_batt_3":{
59+
"condition":["manufacturerdata", 38, "!", "ffff"],
60+
"decoder":["value_from_hex_data", "manufacturerdata", 38, 4, true, false],
61+
"post_proc":[">", 5, "&", 2047, "/", 10]
62+
},
63+
"tempc":{
64+
"condition":["manufacturerdata", 42, "!", "ff"],
65+
"decoder":["value_from_hex_data", "manufacturerdata", 42, 2],
66+
"post_proc":["&", 127, "-", 40]
67+
},
68+
"current_ac":{
69+
"condition":["manufacturerdata", 44, "!", "ff"],
70+
"decoder":["value_from_hex_data", "manufacturerdata", 42, 4, false, false],
71+
"post_proc":["&", 511, "/", 10]
72+
},
73+
"error_code":{
74+
"condition":["manufacturerdata", 22, "!", "ff"],
75+
"decoder":["value_from_hex_data", "manufacturerdata", 22, 2]
76+
}
77+
}
78+
})"""";*/
79+
80+
const char* _VICTBSC_json_props = "{\"properties\":{\"device_state\":{\"unit\":\"string\",\"name\":\"device state\"},\"volt_batt_1\":{\"unit\":\"V\",\"name\":\"voltage\"},\"current_batt_1\":{\"unit\":\"A\",\"name\":\"current\"},\"volt_batt_2\":{\"unit\":\"V\",\"name\":\"voltage\"},\"current_batt_2\":{\"unit\":\"A\",\"name\":\"current\"},\"volt_batt_3\":{\"unit\":\"V\",\"name\":\"voltage\"},\"current_batt_3\":{\"unit\":\"A\",\"name\":\"current\"},\"tempc\":{\"unit\":\"°C\",\"name\":\"temperature\"},\"current_ac\":{\"unit\":\"A\",\"name\":\"current\"},\"error_code\":{\"unit\":\"int\",\"name\":\"error code\"}}}";
81+
/*R""""(
82+
{
83+
"properties":{
84+
"device_state":{
85+
"unit":"string",
86+
"name":"device state"
87+
},
88+
"volt_batt_1": {
89+
"unit": "V",
90+
"name": "voltage"
91+
},
92+
"current_batt_1": {
93+
"unit": "A",
94+
"name": "current"
95+
},
96+
"volt_batt_2": {
97+
"unit": "V",
98+
"name": "voltage"
99+
},
100+
"current_batt_2": {
101+
"unit": "A",
102+
"name": "current"
103+
},
104+
"volt_batt_3": {
105+
"unit": "V",
106+
"name": "voltage"
107+
},
108+
"current_batt_3": {
109+
"unit": "A",
110+
"name": "current"
111+
},
112+
"tempc": {
113+
"unit": "°C",
114+
"name": "temperature"
115+
},
116+
"current_ac": {
117+
"unit": "A",
118+
"name": "current"
119+
},
120+
"error_code":{
121+
"unit":"int",
122+
"name":"error code"
123+
}
124+
}
125+
})"""";*/

tests/BLE/test_ble.cpp

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@ const char* expected_mfg[] = {
212212
"{\"brand\":\"Victron Energy\",\"model\":\"Smart BatteryProtect\",\"model_id\":\"VICTSBP\",\"type\":\"ENRG\",\"track\":true,\"device_state\":\"off\",\"output_state\":\"off\",\"volt_in\":12.79,\"volt_out\":0.11,\"error_code\":0,\"alarm_reason\":0,\"warning_reason\":0}",
213213
"{\"brand\":\"Victron Energy\",\"model\":\"Orion XS encrypted\",\"model_id\":\"VICTORIONXS_ENCR\",\"type\":\"ENRG\",\"encr\":3,\"cipher\":\"79c9ab28f6e6be3a02d5842a6a0e\",\"ctr\":\"5f1f\",\"mic\":\"40\"}",
214214
"{\"brand\":\"Victron Energy\",\"model\":\"Orion XS\",\"model_id\":\"VICTORIONXS\",\"type\":\"ENRG\",\"track\":true,\"device_state\":\"off\",\"volt_out\":12.7,\"current_out\":0,\"volt_in\":0.1,\"current_in\":0,\"error_code\":0}",
215+
"{\"brand\":\"Victron Energy\",\"model\":\"Blue Smart Charger encrypted\",\"model_id\":\"VICTBSC_ENCR\",\"type\":\"ENRG\",\"encr\":3,\"cipher\":\"131cccaa386a0168502ced882e\",\"ctr\":\"3408\",\"mic\":\"00\"}",
216+
"{\"brand\":\"Victron Energy\",\"model\":\"Blue Smart Charger\",\"model_id\":\"VICTBSC\",\"type\":\"ENRG\",\"device_state\":\"absorption\",\"volt_batt_1\":14.01,\"current_batt_1\":10,\"error_code\":0}",
217+
"{\"brand\":\"Victron Energy\",\"model\":\"Blue Smart Charger\",\"model_id\":\"VICTBSC\",\"type\":\"ENRG\",\"device_state\":\"bulk\",\"volt_batt_1\":13.07,\"current_batt_1\":3,\"error_code\":0}",
218+
"{\"brand\":\"Victron Energy\",\"model\":\"Blue Smart Charger\",\"model_id\":\"VICTBSC\",\"type\":\"ENRG\",\"device_state\":\"storage\",\"volt_batt_1\":13.5,\"current_batt_1\":0.5,\"tempc\":21,\"tempf\":69.8,\"error_code\":0}",
219+
"{\"brand\":\"Victron Energy\",\"model\":\"Blue Smart Charger\",\"model_id\":\"VICTBSC\",\"type\":\"ENRG\",\"device_state\":\"absorption\",\"volt_batt_1\":14.2,\"current_batt_1\":0,\"error_code\":0}",
220+
"{\"brand\":\"Victron Energy\",\"model\":\"Blue Smart Charger\",\"model_id\":\"VICTBSC\",\"type\":\"ENRG\",\"device_state\":\"bulk\",\"volt_batt_1\":14.07,\"current_batt_1\":15,\"error_code\":0}",
221+
"{\"brand\":\"Victron Energy\",\"model\":\"Blue Smart Charger\",\"model_id\":\"VICTBSC\",\"type\":\"ENRG\",\"device_state\":\"absorption\",\"volt_batt_1\":14.19,\"current_batt_1\":0.3,\"error_code\":0}",
222+
"{\"brand\":\"Victron Energy\",\"model\":\"Blue Smart Charger\",\"model_id\":\"VICTBSC\",\"type\":\"ENRG\",\"device_state\":\"power supply\",\"volt_batt_1\":14.57,\"current_batt_1\":0,\"error_code\":0}",
215223
};
216224

217225
const char* expected_name_uuid_mfgsvcdata[] = {
@@ -757,15 +765,23 @@ const char* test_mfgdata[][3] = {
757765
{"H5055", "GVH5055", "d596c100648f221500ffff3f00221500ffff3f000000"},
758766
{"H5055", "GVH5055", "d596c1006441221700ffff3f00221500ffff3f000000"},
759767
{"H5055", "GVH5055", "d596c1006401201a00ffff3100221600ffff3f000000"},
760-
{"Victron Smart Battery Protect ENC", "", "e1021000b0a309a82cdaf581a6631c3ddfccaa081fad4da6f4"},
761-
{"Victron Smart Battery Protect", "", "e1021100b0a309ffffda0000000000000000050a0008000000"},
762-
{"Victron Smart Battery Protect", "", "e1021100b0a309ffffdaf90100000000001b051b0500000000"},
763-
{"Victron Smart Battery Protect", "", "e1021100b0a309ffffda00000000000000fc040b0008000000"},
764-
{"Victron Smart Battery Protect", "", "e1021100b0a309ffffdaf9010000000000f004f00400000000"},
765-
{"Victron Smart Battery Protect", "", "e1021100b0a309ffffda00000000000000fa040c0004000000"},
766-
{"Victron Smart Battery Protect", "", "e1021100b0a309ffffda00000000000000ff040b0004000000"},
767-
{"Victron Orion XS ENC", "", "e1021000f0a30f5f1f4079c9ab28f6e6be3a02d5842a6a0e"},
768-
{"Victron Orion XS", "", "e1021100f0a30fffff400000f60400000a00000081000000"},
768+
{"Victron Smart Battery Protect ENCR", "", "e1021000b0a309a82cdaf581a6631c3ddfccaa081fad4da6f4"},
769+
{"Victron Smart Battery Protect", "", "e1021100b0a309ffffda0000000000000000050a0008000000"},
770+
{"Victron Smart Battery Protect", "", "e1021100b0a309ffffdaf90100000000001b051b0500000000"},
771+
{"Victron Smart Battery Protect", "", "e1021100b0a309ffffda00000000000000fc040b0008000000"},
772+
{"Victron Smart Battery Protect", "", "e1021100b0a309ffffdaf9010000000000f004f00400000000"},
773+
{"Victron Smart Battery Protect", "", "e1021100b0a309ffffda00000000000000fa040c0004000000"},
774+
{"Victron Smart Battery Protect", "", "e1021100b0a309ffffda00000000000000ff040b0004000000"},
775+
{"Victron Orion XS ENCR", "", "e1021000f0a30f5f1f4079c9ab28f6e6be3a02d5842a6a0e"},
776+
{"Victron Orion XS", "", "e1021100f0a30fffff400000f60400000a00000081000000"},
777+
{"Victron Orion Blue Smart Charger ENCR", "", "e10210002ca308340800131cccaa386a0168502ced882e"},
778+
{"Victron Orion Blue Smart Charger", "", "e102110038a308ffffcc040079850cffffffffffffffff"},
779+
{"Victron Orion Blue Smart Charger", "", "e102110038a308ffffcc03001bc503ffffffffffffffff"},
780+
{"Victron Orion Blue Smart Charger", "", "e10211002ca308ffff00060046a500ffffffffffffbdff"},
781+
{"Victron Orion Blue Smart Charger", "", "e10211002ca308ffff0004008c0500ffffffffffffffff"},
782+
{"Victron Orion Blue Smart Charger", "", "e10211002ca308ffff0003007fc512ffffffffffffffff"},
783+
{"Victron Orion Blue Smart Charger", "", "e10211002ca308ffff0004008b6500ffffffffffffffff"},
784+
{"Victron Orion Blue Smart Charger", "", "e102110038a308ffffcc0b00b10500ffffffffffffffff"},
769785
};
770786

771787
TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
@@ -961,6 +977,14 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
961977
TheengsDecoder::BLE_ID_NUM::VICTSBP,
962978
TheengsDecoder::BLE_ID_NUM::VICTORIONXS_ENCR,
963979
TheengsDecoder::BLE_ID_NUM::VICTORIONXS,
980+
TheengsDecoder::BLE_ID_NUM::VICTBSC_ENCR,
981+
TheengsDecoder::BLE_ID_NUM::VICTBSC,
982+
TheengsDecoder::BLE_ID_NUM::VICTBSC,
983+
TheengsDecoder::BLE_ID_NUM::VICTBSC,
984+
TheengsDecoder::BLE_ID_NUM::VICTBSC,
985+
TheengsDecoder::BLE_ID_NUM::VICTBSC,
986+
TheengsDecoder::BLE_ID_NUM::VICTBSC,
987+
TheengsDecoder::BLE_ID_NUM::VICTBSC,
964988
};
965989

966990
// uuid test input [test name] [device name] [uuid] [manufacturer data] [service data]

0 commit comments

Comments
 (0)