Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ class ConnectivityManager

struct ThreadPollingConfig;

#if WEAVE_DEVICE_CONFIG_ENABLE_SYSTEM_MANAGED_NETWORK
// System managed network
WEAVE_ERROR ProvisionSystemManagedNetwork(void);
#endif // WEAVE_DEVICE_CONFIG_ENABLE_SYSTEM_MANAGED_NETWORK

// WiFi station methods
WiFiStationMode GetWiFiStationMode(void);
WEAVE_ERROR SetWiFiStationMode(WiFiStationMode val);
Expand Down Expand Up @@ -255,6 +260,13 @@ namespace nl {
namespace Weave {
namespace DeviceLayer {

#if WEAVE_DEVICE_CONFIG_ENABLE_SYSTEM_MANAGED_NETWORK
inline WEAVE_ERROR ConnectivityManager::ProvisionSystemManagedNetwork(void)
{
return static_cast<ImplClass*>(this)->_ProvisionSystemManagedNetwork();
}
#endif // WEAVE_DEVICE_CONFIG_ENABLE_SYSTEM_MANAGED_NETWORK

inline ConnectivityManager::WiFiStationMode ConnectivityManager::GetWiFiStationMode(void)
{
return static_cast<ImplClass*>(this)->_GetWiFiStationMode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,18 @@
#define WEAVE_DEVICE_CONFIG_THREAD_CONNECTIVITY_TIMEOUT 30000
#endif

// -------------------- Misc Network Configuration --------------------

/**
* WEAVE_DEVICE_CONFIG_ENABLE_SYSTEM_MANAGED_NETWORK
*
* Enable support for system managed network
*/
#ifndef WEAVE_DEVICE_CONFIG_ENABLE_SYSTEM_MANAGED_NETWORK
#define WEAVE_DEVICE_CONFIG_ENABLE_SYSTEM_MANAGED_NETWORK 0
#endif


// -------------------- Tunnel Configuration --------------------

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ enum
{
kThreadNetworkId = 1,
kWiFiStationNetworkId = 2,
kSystemManagedNetworkId = 3,
};

class DeviceNetworkInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,19 @@ WEAVE_ERROR GenericNetworkProvisioningServerImpl<ImplClass>::HandleAddUpdateNetw

#endif // WEAVE_DEVICE_CONFIG_ENABLE_THREAD

#if WEAVE_DEVICE_CONFIG_ENABLE_SYSTEM_MANAGED_NETWORK

case kNetworkType_SystemManaged:

err = ConnectivityMgr().ProvisionSystemManagedNetwork();
VerifyOrExit(err == WEAVE_NO_ERROR, SendStatusReport(kWeaveProfile_NetworkProvisioning, 0, err));

netId = kSystemManagedNetworkId;

break;

#endif // WEAVE_DEVICE_CONFIG_ENABLE_SYSTEM_MANAGED_NETWORK

default:

WeaveLogProgress(DeviceLayer, "%sUnsupported network type: %d", sLogPrefix, netInfo.NetworkType);
Expand Down
5 changes: 5 additions & 0 deletions src/device-manager/python/openweave/WeaveDeviceMgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

NetworkType_WiFi = 1
NetworkType_Thread = 2
NetworkType_SystemManaged = 3

WiFiMode_AdHoc = 1
WiFiMode_Managed = 2
Expand Down Expand Up @@ -1301,6 +1302,8 @@ def NetworkTypeToString(val):
return "WiFi"
if (val == NetworkType_Thread):
return "Thread"
if (val == NetworkType_SystemManaged):
return "SystemManaged"
if (val != None):
return "UNKNOWN (" + str(val)+ ")"
return None
Expand All @@ -1313,6 +1316,8 @@ def ParseNetworkType(val):
return NetworkType_WiFi
if (val == "thread"):
return NetworkType_Thread
if (val == "system"):
return NetworkType_SystemManaged
raise Exception("Invalid network type: " + str(val))

def WiFiModeToString(val):
Expand Down
28 changes: 28 additions & 0 deletions src/device-manager/python/weave-device-mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ def __init__(self, rendezvousAddr=None):
'passive-rendezvous',
'remote-passive-rendezvous',
'reconnect',
'add-system-managed-network',
'scan-networks',
'add-wifi-network',
'add-thread-network',
Expand Down Expand Up @@ -1027,6 +1028,33 @@ def do_close(self, line):
except WeaveStack.WeaveStackException as ex:
print(str(ex))

def do_addsystemmanagednetwork(self, line):
"""
add-system-managed-network

Provision a system managed network.
"""

args = shlex.split(line)

if (len(args) != 0):
print("Usage:")
self.do_help('add-system-managed-network')
return

networkInfo = WeaveDeviceMgr.NetworkInfo(
networkType = WeaveDeviceMgr.NetworkType_SystemManaged)

try:
addResult = self.devMgr.AddNetwork(networkInfo)
except WeaveStack.WeaveStackException as ex:
print(str(ex))
return

self.lastNetworkId = addResult

print("Add system managed network complete (network id = " + str(addResult) + ")")

def do_enableconnectionmonitor(self, line):
"""
enable-connection-monitor [ <interval> <timeout> ]
Expand Down
3 changes: 2 additions & 1 deletion src/lib/profiles/network-provisioning/NetworkProvisioning.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ enum NetworkType
kNetworkType_NotSpecified = -1,

kNetworkType_WiFi = 1,
kNetworkType_Thread = 2
kNetworkType_Thread = 2,
kNetworkType_SystemManaged = 3,
};

/**
Expand Down