Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 51da490

Browse files
authored
Merge pull request #442 from openweave/feature/feature-dm-in-mobile-support
Add experimental DataManagement Client support with C++ and Python
2 parents ded21fc + 4674cde commit 51da490

32 files changed

+4285
-834
lines changed

Makefile-Standalone

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,12 @@ else
233233
configure_OPTIONS +=
234234
endif
235235

236+
ifdef SCHEMA
237+
configure_OPTIONS += --with-schema=$(SCHEMA)
238+
else
239+
configure_OPTIONS +=
240+
endif
241+
236242
# If the user has asserted USE_LWIP, alter the configuration and
237243
# target tuple to use LwIP rather than the expected BSD sockets.
238244

build/config/android/WeaveProjectConfig.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
*
33
* Copyright (c) 2016-2017 Nest Labs, Inc.
4+
* Copyright (c) 2019-2020 Google LLC.
45
* All rights reserved.
56
*
67
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,4 +28,26 @@
2728
// Enable passcode encryption configuration 1
2829
#define WEAVE_CONFIG_SUPPORT_PASSCODE_CONFIG1_TEST_ONLY 1
2930

31+
#define WDM_UPDATE_MAX_ITEMS_IN_TRAIT_DIRTY_PATH_STORE 300
32+
33+
// Uncomment this for a large Tunnel MTU.
34+
//#define WEAVE_CONFIG_TUNNEL_INTERFACE_MTU (9000)
35+
36+
// Max number of Bindings per WeaveExchangeManager
37+
#define WEAVE_CONFIG_MAX_BINDINGS 8
38+
39+
#define WDM_ENFORCE_EXPIRY_TIME 1
40+
41+
#define WEAVE_CONFIG_ENABLE_WDM_UPDATE 1
42+
43+
#define WEAVE_CONFIG_LEGACY_CASE_AUTH_DELEGATE 0
44+
45+
#define WEAVE_CONFIG_LEGACY_KEY_EXPORT_DELEGATE 0
46+
47+
#define WEAVE_SYSTEM_CONFIG_PACKETBUFFER_MAXALLOC 300
48+
49+
#define WEAVE_CONFIG_ENABLE_FUNCT_ERROR_LOGGING 1
50+
51+
#define WEAVE_CONFIG_DATA_MANAGEMENT_CLIENT_EXPERIMENTAL 1
52+
3053
#endif /* WEAVEPROJECTCONFIG_H */

build/config/ios/WeaveProjectConfig.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
*
33
* Copyright (c) 2016-2017 Nest Labs, Inc.
4+
* Copyright (c) 2019-2020 Google LLC.
45
* All rights reserved.
56
*
67
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,4 +27,29 @@
2627

2728
#define INET_CONFIG_OVERRIDE_SYSTEM_TCP_USER_TIMEOUT 0
2829

30+
// Enable passcode encryption configuration 1
31+
#define WEAVE_CONFIG_SUPPORT_PASSCODE_CONFIG1_TEST_ONLY 1
32+
33+
#define WDM_UPDATE_MAX_ITEMS_IN_TRAIT_DIRTY_PATH_STORE 300
34+
35+
// Uncomment this for a large Tunnel MTU.
36+
//#define WEAVE_CONFIG_TUNNEL_INTERFACE_MTU (9000)
37+
38+
// Max number of Bindings per WeaveExchangeManager
39+
#define WEAVE_CONFIG_MAX_BINDINGS 8
40+
41+
#define WDM_ENFORCE_EXPIRY_TIME 1
42+
43+
#define WEAVE_CONFIG_ENABLE_WDM_UPDATE 1
44+
45+
#define WEAVE_CONFIG_LEGACY_CASE_AUTH_DELEGATE 0
46+
47+
#define WEAVE_CONFIG_LEGACY_KEY_EXPORT_DELEGATE 0
48+
49+
#define WEAVE_SYSTEM_CONFIG_PACKETBUFFER_MAXALLOC 300
50+
51+
#define WEAVE_CONFIG_ENABLE_FUNCT_ERROR_LOGGING 1
52+
53+
#define WEAVE_CONFIG_DATA_MANAGEMENT_CLIENT_EXPERIMENTAL 1
54+
2955
#endif /* WEAVEPROJECTCONFIG_H */

build/config/standalone/WeaveProjectConfig.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,10 @@
6565

6666
#define WEAVE_CONFIG_LEGACY_KEY_EXPORT_DELEGATE 0
6767

68+
#define WEAVE_SYSTEM_CONFIG_PACKETBUFFER_MAXALLOC 300
69+
70+
#define WEAVE_CONFIG_ENABLE_FUNCT_ERROR_LOGGING 1
71+
72+
#define WEAVE_CONFIG_DATA_MANAGEMENT_CLIENT_EXPERIMENTAL 1
73+
6874
#endif /* WEAVEPROJECTCONFIG_H */

configure.ac

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,36 @@ AC_MSG_RESULT(${use_happy_dns})
917917
AM_CONDITIONAL([WEAVE_RUN_HAPPY_DNS], [test "${use_happy_dns}" = "yes"])
918918
AC_SUBST(HAPPY_DNS,[${with_happy_dns}])
919919

920+
AC_MSG_CHECKING([checking whether to use specific schema while running data management in mobile client])
921+
AC_ARG_WITH(schema,
922+
[AS_HELP_STRING([--with-schema=SCHEMA],
923+
[Add custom schema directory for weave data management client support, where the directory needs to include
924+
pre-generated schema cpp and header files and CustomBuiltInTraitSchemaDirectory.cpp file. [default=none].])],
925+
[
926+
case "${with_schema}" in
927+
928+
no)
929+
;;
930+
931+
yes)
932+
AC_MSG_ERROR([Invalid value ${with_schema} for --with-schema])
933+
;;
934+
935+
*)
936+
use_schema=yes
937+
;;
938+
esac
939+
],
940+
[use_schema=no])
941+
942+
AC_MSG_RESULT(${use_schema})
943+
944+
AM_CONDITIONAL([WEAVE_CONFIG_CUSTOM_BUILTIN_SCHEMA_INCLUDE], [test "${use_schema}" = "yes"])
945+
AC_SUBST(WEAVE_CONFIG_CUSTOM_BUILTIN_SCHEMA_INCLUDE,[${with_schema}])
946+
if test "${use_schema}" = "yes"; then
947+
AC_DEFINE_UNQUOTED([WEAVE_CONFIG_CUSTOM_BUILTIN_SCHEMA_INCLUDE],[${WEAVE_CONFIG_CUSTOM_BUILTIN_SCHEMA_INCLUDE}/CustomBuiltInTraitSchemaDirectory.cpp],[Define custom schema directory])
948+
fi
949+
920950
#
921951
# Happy Service Test Suite
922952
#
@@ -2777,6 +2807,7 @@ AC_MSG_NOTICE([
27772807
Happy Services : ${with_happy_service}
27782808
Happy Services Test Suites : ${with_happy_test_suite}
27792809
Happy DNS Servers : ${with_happy_dns}
2810+
Schema : ${with_schema}
27802811
Treat warnings as errors : ${nl_cv_warnings_as_errors}
27812812
Build tests : ${nl_cv_build_tests}
27822813
Build long running tests : ${nl_cv_build_long_tests}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
*
3+
* Copyright (c) 2020 Google LLC.
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* @file
21+
* TraitSchemaDirectory which locate the trait schema from different trait header files
22+
* WARNING: This is experimental feature for Weave Data Management Client
23+
*/
24+
25+
// This is a .cpp file in openweave-core that includes the "built-in schema"
26+
// source file, if defined...
27+
28+
#include <Weave/Core/WeaveCore.h>
29+
30+
#if WEAVE_CONFIG_DATA_MANAGEMENT_CLIENT_EXPERIMENTAL
31+
#include <Weave/DeviceManager/TraitSchemaDirectory.h>
32+
33+
#if defined(WEAVE_CONFIG_CUSTOM_BUILTIN_SCHEMA_INCLUDE)
34+
#define DirectoryGen_(dir) #dir
35+
#define DirectoryGen(dir) DirectoryGen_(dir)
36+
#include DirectoryGen(WEAVE_CONFIG_CUSTOM_BUILTIN_SCHEMA_INCLUDE)
37+
#else
38+
#include <weave/trait/locale/LocaleSettingsTrait.h>
39+
#include <weave/trait/locale/LocaleCapabilitiesTrait.h>
40+
#include <nest/test/trait/TestCTrait.h>
41+
42+
namespace nl {
43+
namespace Weave {
44+
namespace DeviceManager {
45+
using namespace ::nl::Weave::Profiles::DataManagement_Current;
46+
47+
const TraitSchemaEngine * TraitSchemaDirectory::GetTraitSchemaEngine(uint32_t aProfileId)
48+
{
49+
if (aProfileId == ::Weave::Trait::Locale::LocaleSettingsTrait::kWeaveProfileId)
50+
{
51+
return &::Weave::Trait::Locale::LocaleSettingsTrait::TraitSchema;
52+
}
53+
if (aProfileId == ::Schema::Nest::Test::Trait::TestCTrait::kWeaveProfileId)
54+
{
55+
return &::Schema::Nest::Test::Trait::TestCTrait::TraitSchema;
56+
}
57+
if (aProfileId == ::Weave::Trait::Locale::LocaleCapabilitiesTrait::kWeaveProfileId)
58+
{
59+
return &::Weave::Trait::Locale::LocaleCapabilitiesTrait::TraitSchema;
60+
}
61+
else
62+
{
63+
WeaveLogError(DataManagement, "Schema does not exit with profile id %" PRIu32 " ", aProfileId);
64+
return NULL;
65+
}
66+
}
67+
68+
} // namespace DeviceManager
69+
} // namespace Weave
70+
} // namespace nl
71+
72+
#include <weave/trait/locale/LocaleSettingsTrait.cpp>
73+
#include <weave/trait/locale/LocaleCapabilitiesTrait.cpp>
74+
#include <nest/test/trait/TestCTrait.cpp>
75+
76+
#endif // !defined(WEAVE_CONFIG_CUSTOM_BUILTIN_SCHEMA_INCLUDE)
77+
#endif // WEAVE_CONFIG_DATA_MANAGEMENT_CLIENT_EXPERIMENTAL

src/device-manager/DeviceManager.am

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#
2-
# Copyright (c) 2014-2017 Nest Labs, Inc.
2+
# Copyright (c) 2014-2018 Nest Labs, Inc.
3+
# Copyright (c) 2019-2020 Google LLC.
34
# All rights reserved.
45
#
56
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,14 +27,16 @@
2627
# such it depends on the presense of a generalized heap (malloc el al).
2728
# In contexts where this isn't available, simply skip building the Device
2829
# Manager code altogether.
29-
30+
3031
nl_DeviceManager_sources = \
3132
$(NULL)
3233

3334
if CONFIG_HAVE_HEAP
3435

3536
nl_DeviceManager_sources += \
3637
@top_builddir@/src/device-manager/WeaveDeviceManager.cpp \
38+
@top_builddir@/src/device-manager/WeaveDataManagementClient.cpp \
39+
@top_builddir@/src/device-manager/BuiltInTraitSchemaDirectory.cpp \
3740
$(NULL)
3841

3942
if CONFIG_NETWORK_LAYER_BLE
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
*
3+
* Copyright (c) 2020 Google LLC.
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* @file
21+
* TraitSchemaDirectory which locate the trait schema from different trait header files
22+
*/
23+
24+
#ifndef TRAIT_SCHEMA_DIRECTORY_H_
25+
#define TRAIT_SCHEMA_DIRECTORY_H_
26+
27+
#include <Weave/Profiles/data-management/Current/WdmManagedNamespace.h>
28+
#include <Weave/Profiles/data-management/DataManagement.h>
29+
30+
namespace nl {
31+
namespace Weave {
32+
namespace DeviceManager {
33+
using namespace ::nl::Weave::Profiles::DataManagement_Current;
34+
35+
class TraitSchemaDirectory {
36+
public:
37+
static const nl::Weave::Profiles::DataManagement::TraitSchemaEngine * GetTraitSchemaEngine(uint32_t aProfileId);
38+
};
39+
40+
} // namespace DeviceManager
41+
} // namespace Weave
42+
} // namespace nl
43+
44+
#endif // TRAIT_SCHEMA_DIRECTORY_H_

0 commit comments

Comments
 (0)