blob: cc740e8223cc1714aa87d20553c67225c19b4647 [file] [log] [blame]
Vitaly Buka87eb7882015-10-27 22:23:49 -07001// Copyright 2015 The Weave Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "src/privet/device_ui_kind.h"
6
Paul Westbrookc0781082015-12-09 01:15:06 -08007#include <unordered_map>
8
Vitaly Buka87eb7882015-10-27 22:23:49 -07009#include <base/logging.h>
10
11namespace weave {
12namespace privet {
13
14std::string GetDeviceUiKind(const std::string& manifest_id) {
Paul Westbrookc0781082015-12-09 01:15:06 -080015 // Map of device short id to ui device kind
16 static const std::unordered_map<std::string, std::string> device_kind_map = {
Vitaly Buka34668e72015-12-15 14:46:47 -080017 // clang-format off
Paul Westbrookc0781082015-12-09 01:15:06 -080018 {"AC", "accessPoint"},
19 {"AK", "aggregator"},
20 {"AM", "camera"},
21 {"AB", "developmentBoard"},
22 {"AH", "acHeating"},
23 {"AI", "light"},
24 {"AO", "lock"},
25 {"AE", "printer"},
26 {"AF", "scanner"},
27 {"AD", "speaker"},
28 {"AL", "storage"},
29 {"AJ", "toy"},
30 {"AA", "vendor"},
Vitaly Buka34668e72015-12-15 14:46:47 -080031 {"AN", "video"},
32 // clang-format on
Paul Westbrookc0781082015-12-09 01:15:06 -080033 };
34
Vitaly Buka87eb7882015-10-27 22:23:49 -070035 CHECK_EQ(5u, manifest_id.size());
Paul Westbrookc0781082015-12-09 01:15:06 -080036 std::string short_id = manifest_id.substr(0, 2);
37
38 auto iter = device_kind_map.find(short_id);
39 if (iter != device_kind_map.end())
40 return iter->second;
41
Vitaly Buka87eb7882015-10-27 22:23:49 -070042 LOG(FATAL) << "Invalid model id: " << manifest_id;
43 return std::string();
44}
45
46} // namespace privet
47} // namespace weave