3 * Copyright (c) 2020 Project CHIP Authors
4 * Copyright (c) 2013-2017 Nest Labs, Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 #include "ChipDeviceController-ScriptDevicePairingDelegate.h"
22 #include <transport/RendezvousSessionDelegate.h>
25 namespace Controller {
27 void ScriptDevicePairingDelegate::SetWifiCredential(const char * ssid, const char * password)
29 strncpy(mWifiSSID, ssid, sizeof(mWifiSSID));
30 strncpy(mWifiPassword, password, sizeof(mWifiPassword));
34 void ScriptDevicePairingDelegate::SetThreadCredential(uint8_t channel, uint16_t panId,
35 uint8_t (&masterKey)[chip::DeviceLayer::Internal::kThreadMasterKeyLength])
38 mThreadInfo.ThreadChannel = channel;
39 mThreadInfo.ThreadPANId = panId;
40 memcpy(mThreadInfo.ThreadMasterKey, masterKey, sizeof(masterKey));
44 void ScriptDevicePairingDelegate::OnNetworkCredentialsRequested(RendezvousDeviceCredentialsDelegate * callback)
46 if (mMode == Mode::Wifi)
47 callback->SendNetworkCredentials(mWifiSSID, mWifiPassword);
49 callback->SendThreadCredentials(mThreadInfo);
52 void ScriptDevicePairingDelegate::OnOperationalCredentialsRequested(const char * csr, size_t csr_length,
53 RendezvousDeviceCredentialsDelegate * callback)
55 // TODO: Implement this
56 ChipLogDetail(Controller, "ScriptDevicePairingDelegate::OnOperationalCredentialsRequested\n");
59 void ScriptDevicePairingDelegate::SetKeyExchangeCallback(DevicePairingDelegate_OnPairingCompleteFunct callback)
61 mOnPairingCompleteCallback = callback;
64 void ScriptDevicePairingDelegate::OnPairingComplete(CHIP_ERROR error)
66 if (mOnPairingCompleteCallback != nullptr)
68 mOnPairingCompleteCallback(error);
72 } // namespace Controller