• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wirenboard / wb-mqtt-serial / 2

29 Dec 2025 12:28PM UTC coverage: 76.817% (+4.0%) from 72.836%
2

Pull #1045

github

54aa0c
pgasheev
up changelog
Pull Request #1045: Fix firmware version in WB-M1W2 template

6873 of 9161 branches covered (75.02%)

12966 of 16879 relevant lines covered (76.82%)

1651.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

15.38
/src/confed_schema_generator.cpp
1
#include "confed_schema_generator.h"
2

3
#include <wblib/wbmqtt.h>
4

5
#include "json_common.h"
6

7
namespace
8
{
9
    //  {
10
    //      "type": "string",
11
    //      "enum": [ VALUE ],
12
    //      "default": VALUE,
13
    //      "options": { "hidden": true }
14
    //  }
15
    Json::Value MakeHiddenProperty(const std::string& value)
×
16
    {
17
        Json::Value res;
×
18
        res["type"] = "string";
×
19
        res["default"] = value;
×
20
        MakeArray("enum", res).append(value);
×
21
        res["options"]["hidden"] = true;
×
22
        return res;
×
23
    }
24

25
    //  {
26
    //      "properties": {
27
    //          "protocol": {
28
    //              "type": "string",
29
    //              "options": {
30
    //                  "hidden": true
31
    //              }
32
    //          }
33
    //      }
34
    //  }
35
    Json::Value MakeProtocolProperty()
×
36
    {
37
        Json::Value r;
×
38
        r["properties"]["protocol"]["type"] = "string";
×
39
        r["properties"]["protocol"]["options"]["hidden"] = true;
×
40
        return r;
×
41
    }
42

43
    //  {
44
    //      "allOf": [
45
    //          { "$ref": PROTOCOL_PARAMETERS }
46
    //      ],
47
    //      "format": "groups",
48
    //      "device": DEVICE_TEMPLATE,
49
    //      "properties": {
50
    //          "device_type": DEVICE_TYPE
51
    //      },
52
    //      "required": ["device_type", "slave_id"]
53
    //  }
54
    Json::Value MakeDeviceWithGroupsTemplateSchema(TDeviceTemplate& deviceTemplate,
×
55
                                                   TSerialDeviceFactory& deviceFactory,
56
                                                   const Json::Value& commonDeviceSchema)
57
    {
58
        auto protocol = GetProtocolName(deviceTemplate.GetTemplate());
×
59
        auto res = commonDeviceSchema;
×
60
        if (!deviceFactory.GetProtocol(protocol)->SupportsBroadcast()) {
×
61
            res["required"].append("slave_id");
×
62
        }
63

64
        auto& allOf = MakeArray("allOf", res);
×
65
        Append(allOf)["$ref"] = deviceFactory.GetCommonDeviceSchemaRef(protocol);
×
66
        allOf.append(MakeProtocolProperty());
×
67

68
        res["format"] = "groups";
×
69
        res["device"] = deviceTemplate.GetTemplate();
×
70
        res["properties"]["device_type"] = MakeHiddenProperty(deviceTemplate.Type);
×
71
        return res;
×
72
    }
73

74
}
75

76
void AddUnitTypes(Json::Value& schema)
×
77
{
78
    auto& values = MakeArray("enum_values", schema["definitions"]["units"]["options"]);
×
79
    for (const auto& unit: WBMQTT::TControl::GetUnitTypes()) {
×
80
        values.append(unit);
×
81
    }
82
}
83

84
void AddTranslations(Json::Value& translations, const Json::Value& deviceSchema)
118✔
85
{
86
    const auto& tr = deviceSchema["translations"];
118✔
87
    for (auto it = tr.begin(); it != tr.end(); ++it) {
354✔
88
        for (auto msgIt = it->begin(); msgIt != it->end(); ++msgIt) {
19,588✔
89
            translations[it.name()][msgIt.name()] = *msgIt;
19,352✔
90
        }
91
    }
92
}
118✔
93

94
Json::Value GenerateSchemaForConfed(TDeviceTemplate& deviceTemplate,
×
95
                                    TSerialDeviceFactory& deviceFactory,
96
                                    const Json::Value& commonDeviceSchema)
97
{
98
    auto schema = deviceTemplate.WithSubdevices()
×
99
                      ? Json::Value(Json::objectValue)
100
                      : MakeDeviceWithGroupsTemplateSchema(deviceTemplate, deviceFactory, commonDeviceSchema);
×
101
    AddUnitTypes(schema);
×
102
    return schema;
×
103
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc