• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // 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 
7 #include <unordered_map>
8 
9 #include <base/logging.h>
10 
11 namespace weave {
12 namespace privet {
13 
GetDeviceUiKind(const std::string & manifest_id)14 std::string GetDeviceUiKind(const std::string& manifest_id) {
15   // Map of device short id to ui device kind
16   static const std::unordered_map<std::string, std::string> device_kind_map = {
17     // clang-format off
18     {"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"},
31     {"AN", "video"},
32     // clang-format on
33   };
34 
35   CHECK_EQ(5u, manifest_id.size());
36   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 
42   LOG(FATAL) << "Invalid model id: " << manifest_id;
43   return std::string();
44 }
45 
46 }  // namespace privet
47 }  // namespace weave
48