2022-12-27 09:32:52 +05:30
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (c) 2020-2022 Project CHIP Authors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
mod dev_att;
|
|
|
|
use matter::core::{self, CommissioningData};
|
|
|
|
use matter::data_model::cluster_basic_information::BasicInfoConfig;
|
|
|
|
use matter::data_model::device_types::device_type_add_on_off_light;
|
2023-01-08 12:27:27 +05:30
|
|
|
use matter::secure_channel::spake2p::VerifierData;
|
2022-12-27 09:32:52 +05:30
|
|
|
|
|
|
|
fn main() {
|
|
|
|
env_logger::init();
|
2023-01-08 12:27:27 +05:30
|
|
|
let comm_data = CommissioningData {
|
2022-12-27 09:32:52 +05:30
|
|
|
// TODO: Hard-coded for now
|
2023-01-08 12:27:27 +05:30
|
|
|
verifier: VerifierData::new_with_pw(123456),
|
2022-12-27 09:32:52 +05:30
|
|
|
discriminator: 250,
|
|
|
|
};
|
|
|
|
|
|
|
|
// vid/pid should match those in the DAC
|
|
|
|
let dev_info = BasicInfoConfig {
|
|
|
|
vid: 0xFFF1,
|
2023-02-08 19:11:01 +05:30
|
|
|
pid: 0x8000,
|
2022-12-27 09:32:52 +05:30
|
|
|
hw_ver: 2,
|
|
|
|
sw_ver: 1,
|
2023-01-13 11:11:23 +05:30
|
|
|
sw_ver_str: "1".to_string(),
|
2023-01-12 16:56:02 +05:30
|
|
|
serial_no: "aabbccdd".to_string(),
|
2023-01-10 13:14:20 +01:00
|
|
|
device_name: "OnOff Light".to_string(),
|
2022-12-27 09:32:52 +05:30
|
|
|
};
|
|
|
|
let dev_att = Box::new(dev_att::HardCodedDevAtt::new());
|
|
|
|
|
2023-01-12 18:32:53 +05:30
|
|
|
let mut matter = core::Matter::new(dev_info, dev_att, comm_data).unwrap();
|
2022-12-27 09:32:52 +05:30
|
|
|
let dm = matter.get_data_model();
|
|
|
|
{
|
|
|
|
let mut node = dm.node.write().unwrap();
|
|
|
|
let endpoint = device_type_add_on_off_light(&mut node).unwrap();
|
|
|
|
println!("Added OnOff Light Device type at endpoint id: {}", endpoint);
|
|
|
|
println!("Data Model now is: {}", node);
|
|
|
|
}
|
|
|
|
|
|
|
|
matter.start_daemon().unwrap();
|
|
|
|
}
|