Skip to content

Commit

Permalink
Merge branch 'release/0.4.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
corbin-phipps committed May 11, 2023
2 parents bac5dff + fb9becf commit cb0a472
Show file tree
Hide file tree
Showing 43 changed files with 1,292 additions and 201 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ MESSAGE(STATUS "using build environment '${NOF_BUILD_ENVIRONMENT}'")

project(nearobject-framework
LANGUAGES CXX
VERSION 0.4.7
VERSION 0.4.8
)

# Conditional inclusion of OS-dependent source trees.
Expand Down
43 changes: 28 additions & 15 deletions lib/nearobject/serialization/UwbConfigurationJsonSerializer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@
void
uwb::protocol::fira::to_json(nlohmann::json& json, const UwbConfiguration& uwbConfiguration)
{
json = nlohmann::json{
{ "DeviceRole", uwbConfiguration.GetDeviceRole().value() },
{ "MultiNodeMode", uwbConfiguration.GetMultiNodeMode().value() },
{ "ControllerMacAddress", uwbConfiguration.GetControllerMacAddress().value() },
{ "ControleeShortMacAddress", uwbConfiguration.GetControleeShortMacAddress().value() },
};
if (uwbConfiguration.GetDeviceRole().has_value()) {
json["DeviceRole"] = uwbConfiguration.GetDeviceRole().value();
}
if (uwbConfiguration.GetMultiNodeMode().has_value()) {
json["MultiNodeMode"] = uwbConfiguration.GetMultiNodeMode().value();
}
if (uwbConfiguration.GetControllerMacAddress().has_value()) {
json["ControllerMacAddress"] = uwbConfiguration.GetControllerMacAddress().value();
}
if (uwbConfiguration.GetControleeShortMacAddress().has_value()) {
json["ControleeShortMacAddress"] = uwbConfiguration.GetControleeShortMacAddress().value();
}
}

void
Expand All @@ -26,15 +32,22 @@ uwb::protocol::fira::from_json(const nlohmann::json& json, UwbConfiguration& uwb
uwb::protocol::fira::MultiNodeMode multiNodeMode;
uwb::UwbMacAddress controllerMacAddress;
uwb::UwbMacAddress controleeShortMacAddress;
json.at("DeviceRole").get_to(deviceRole);
json.at("MultiNodeMode").get_to(multiNodeMode);
json.at("ControllerMacAddress").get_to(controllerMacAddress);
json.at("ControleeShortMacAddress").get_to(controleeShortMacAddress);

builder.SetDeviceRole(deviceRole);
builder.SetMultiNodeMode(multiNodeMode);
builder.SetMacAddressController(controllerMacAddress);
builder.SetMacAddressControleeShort(controleeShortMacAddress);
if (json.contains("DeviceRole")) {
json.at("DeviceRole").get_to(deviceRole);
builder.SetDeviceRole(deviceRole);
}
if (json.contains("MultiNodeMode")) {
json.at("MultiNodeMode").get_to(multiNodeMode);
builder.SetMultiNodeMode(multiNodeMode);
}
if (json.contains("ControllerMacAddress")) {
json.at("ControllerMacAddress").get_to(controllerMacAddress);
builder.SetMacAddressController(controllerMacAddress);
}
if (json.contains("ControleeShortMacAddress")) {
json.at("ControleeShortMacAddress").get_to(controleeShortMacAddress);
builder.SetMacAddressControleeShort(controleeShortMacAddress);
}

uwbConfiguration = std::move(builder);
}
4 changes: 2 additions & 2 deletions windows/tools/OobSimulator/App.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!-- Copyright (c) Microsoft Corporation and Contributors. -->
<!-- Licensed under the MIT License. -->

<Application
x:Class="OobSimulator.App"
Expand All @@ -12,7 +11,8 @@
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<!-- Other merged dictionaries here -->
</ResourceDictionary.MergedDictionaries>
<!-- Other app resources here -->
<!-- Taken from https://github.com/microsoft/WinUI-Gallery/blob/4be881445a729d844d181543a1895ccb373952f4/WinUIGallery/App.xaml#L147 -->
<x:String x:Key="GitHubIconPath">M21.7999992370605,0L19.220495223999,0.26007080078125 16.81787109375,1.00595712661743 14.6436157226563,2.18616962432861 12.7492189407349,3.74921894073486 11.1861696243286,5.64361572265625 10.0059566497803,7.81787109375 9.26007080078125,10.2204961776733 9,12.8000001907349 9.65248012542725,16.8459720611572 11.4694375991821,20.3591785430908 14.2401514053345,23.1291217803955 17.7539005279541,24.9453010559082 18.4305686950684,24.8080005645752 18.6273498535156,24.3296756744385 18.6207065582275,23.4247951507568 18.609375,21.9468746185303 16.4340572357178,22.0373229980469 15.1187467575073,21.4822216033936 14.4708204269409,20.7821025848389 14.2976503372192,20.4375 13.8297338485718,19.5214366912842 13.3685493469238,18.947265625 12.8765497207642,18.5656261444092 12.3995819091797,18.1091804504395 12.4844465255737,17.87890625 12.7874250411987,17.7974605560303 12.9647998809814,17.7875003814697 13.8134965896606,18.0311241149902 14.4276065826416,18.4802703857422 14.8007507324219,18.9127178192139 14.926549911499,19.1062507629395 15.8880548477173,20.1437015533447 16.9443283081055,20.494140625 17.9229640960693,20.416259765625 18.6515502929688,20.1687507629395 18.9645938873291,19.1242198944092 19.4640502929688,18.4593753814697 17.3543262481689,18.0241260528564 15.4833002090454,17.014066696167 14.1450357437134,15.1450166702271 13.6336002349854,12.1328001022339 13.9853601455688,10.2268438339233 14.9500007629395,8.69764995574951 14.7027282714844,7.54188776016235 14.7441072463989,6.53565359115601 15.0765495300293,5.30859994888306 15.2825078964233,5.28076791763306 15.9191312789917,5.34375619888306 17.0145378112793,5.71729135513306 18.596851348877,6.62109994888306 21.799976348877,6.19062519073486 25.004674911499,6.62265014648438 26.5845413208008,5.71818733215332 27.6791000366211,5.34472513198853 28.315746307373,5.28210020065308 28.5218753814697,5.31015014648438 28.8556652069092,6.53784370422363 28.8976573944092,7.5438346862793 28.6499996185303,8.69764995574951 29.6154251098633,10.2268533706665 29.9656257629395,12.1328001022339 29.453296661377,15.1497011184692 28.1123065948486,17.0164012908936 26.2366523742676,18.020601272583 24.120325088501,18.4500007629395 24.7275562286377,19.3355484008789 24.9890747070313,20.8187503814697 24.9804744720459,23.0584030151367 24.9718742370605,24.3312511444092 25.1693305969238,24.8128852844238 25.8531246185303,24.9453010559082 29.3641395568848,23.1273632049561 32.1326217651367,20.3568344116211 33.948070526123,16.8442134857178 34.5999984741211,12.8000001907349 34.3399276733398,10.2204961776733 33.5940399169922,7.81787109375 32.4138298034668,5.64361572265625 30.8507804870605,3.74921894073486 28.9563827514648,2.18616962432861 26.7821273803711,1.00595712661743 24.3795032501221,0.26007080078125 21.7999992370605,0z</x:String>
</ResourceDictionary>
</Application.Resources>
</Application>
9 changes: 4 additions & 5 deletions windows/tools/OobSimulator/App.xaml.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"

#include "App.xaml.h"
#include "MainPage.xaml.h"
#include "MainWindow.xaml.h"

using namespace winrt;
Expand All @@ -14,9 +14,6 @@ using namespace Microsoft::UI::Xaml::Navigation;
using namespace OobSimulator;
using namespace OobSimulator::implementation;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
Expand All @@ -40,8 +37,10 @@ App::App()
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
void
App::OnLaunched(LaunchActivatedEventArgs const&)
App::OnLaunched(LaunchActivatedEventArgs const& e)
{
auto mainPage = make<MainPage>();
window = make<MainWindow>();
window.Content(mainPage);
window.Activate();
}
8 changes: 5 additions & 3 deletions windows/tools/OobSimulator/App.xaml.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#pragma once
#ifndef APP_XAML_H
#define APP_XAML_H

#include "App.xaml.g.h"

Expand All @@ -12,9 +12,11 @@ struct App : AppT<App>
App();

void
OnLaunched(Microsoft::UI::Xaml::LaunchActivatedEventArgs const&);
OnLaunched(Microsoft::UI::Xaml::LaunchActivatedEventArgs const &);

private:
winrt::Microsoft::UI::Xaml::Window window{ nullptr };
};
} // namespace winrt::OobSimulator::implementation

#endif // APP_XAML_H
28 changes: 28 additions & 0 deletions windows/tools/OobSimulator/BindableBase.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// clang-format off
#include "pch.h"
#include "BindableBase.h"
#include "BindableBase.g.cpp"
// clang-format on

using namespace winrt::Microsoft::UI::Xaml::Data;

namespace winrt::OobSimulator::implementation
{
void
BindableBase::RaisePropertyChanged(hstring const& propertyName)
{
m_propertyChanged(*this, PropertyChangedEventArgs(propertyName));
}

winrt::event_token
BindableBase::PropertyChanged(PropertyChangedEventHandler const& handler)
{
return m_propertyChanged.add(handler);
}

void
BindableBase::PropertyChanged(winrt::event_token const& token) noexcept
{
m_propertyChanged.remove(token);
}
} // namespace winrt::OobSimulator::implementation
29 changes: 29 additions & 0 deletions windows/tools/OobSimulator/BindableBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef BINDABLE_BASE_H
#define BINDABLE_BASE_H

#include "BindableBase.g.h"

namespace winrt::OobSimulator::implementation
{
struct BindableBase : BindableBaseT<BindableBase>
{
void
RaisePropertyChanged(hstring const& propertyName);
winrt::event_token
PropertyChanged(winrt::Microsoft::UI::Xaml::Data::PropertyChangedEventHandler const& handler);
void
PropertyChanged(winrt::event_token const& token) noexcept;

private:
event<winrt::Microsoft::UI::Xaml::Data::PropertyChangedEventHandler> m_propertyChanged;
};
} // namespace winrt::OobSimulator::implementation

namespace winrt::OobSimulator::factory_implementation
{
struct BindableBase : BindableBaseT<BindableBase, implementation::BindableBase>
{
};
} // namespace winrt::OobSimulator::factory_implementation

#endif // BINDABLE_BASE_H
15 changes: 15 additions & 0 deletions windows/tools/OobSimulator/BindableBase.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// BindableBase.idl

namespace OobSimulator
{
// clang-format off
[default_interface]
unsealed runtimeclass BindableBase : Microsoft.UI.Xaml.DependencyObject, Microsoft.UI.Xaml.Data.INotifyPropertyChanged
// clang-format on
{
BindableBase();
// clang-format off
protected void RaisePropertyChanged(String propertyName);
// clang-format on
}
} // namespace OobSimulator
61 changes: 61 additions & 0 deletions windows/tools/OobSimulator/DelegateCommand.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// clang-format off
#include "pch.h"
#include "DelegateCommand.h"
// clang-format on

using namespace winrt::Windows::Foundation;

namespace winrt::OobSimulator::implementation
{
DelegateCommand::DelegateCommand(std::function<void(IInspectable)> const& execute, std::function<bool(IInspectable)> const& canExecute)
{
if (!execute) {
throw winrt::hresult_invalid_argument(L"execute");
}

m_executeDelegate = execute;
m_canExecuteDelegate = canExecute;
}

void
DelegateCommand::Execute(IInspectable const& parameter)
{
if (m_executeDelegate) {
m_executeDelegate(parameter);
}
}

bool
DelegateCommand::CanExecute(IInspectable const& parameter)
{
if (!m_canExecuteDelegate) {
return true;
}

bool canExecute = m_canExecuteDelegate(parameter);
if (m_lastCanExecute != canExecute) {
m_lastCanExecute = canExecute;
RaiseCanExecuteChanged();
}

return m_lastCanExecute;
}

winrt::event_token
DelegateCommand::CanExecuteChanged(EventHandler<IInspectable> const& handler)
{
return m_canExecuteChanged.add(handler);
}

void
DelegateCommand::CanExecuteChanged(winrt::event_token const& token)
{
m_canExecuteChanged.remove(token);
}

void
DelegateCommand::RaiseCanExecuteChanged()
{
m_canExecuteChanged(*this, IInspectable());
}
} // namespace winrt::OobSimulator::implementation
37 changes: 37 additions & 0 deletions windows/tools/OobSimulator/DelegateCommand.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef DELEGATE_COMMAND_H
#define DELEGATE_COMMAND_H

#include "DelegateCommand.g.h"
#include <functional>

namespace winrt::OobSimulator::implementation
{
struct DelegateCommand : DelegateCommandT<DelegateCommand>
{
DelegateCommand(std::function<void(winrt::Windows::Foundation::IInspectable)> const& execute, std::function<bool(winrt::Windows::Foundation::IInspectable)> const& canExecute = nullptr);

void
Execute(winrt::Windows::Foundation::IInspectable const& parameter);

bool
CanExecute(winrt::Windows::Foundation::IInspectable const& parameter);

winrt::event_token
CanExecuteChanged(winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable> const& handler);

void
CanExecuteChanged(winrt::event_token const& token);

void
RaiseCanExecuteChanged();

private:
std::function<void(winrt::Windows::Foundation::IInspectable)> m_executeDelegate;
std::function<bool(winrt::Windows::Foundation::IInspectable)> m_canExecuteDelegate;
bool m_lastCanExecute = true;

winrt::event<winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable>> m_canExecuteChanged;
};
} // namespace winrt::OobSimulator::implementation

#endif // DELEGATE_COMMAND_H
9 changes: 9 additions & 0 deletions windows/tools/OobSimulator/DelegateCommand.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// DelegateCommand.idl

namespace OobSimulator
{
runtimeclass DelegateCommand : Microsoft.UI.Xaml.DependencyObject, Microsoft.UI.Xaml.Input.ICommand
{
void RaiseCanExecuteChanged();
}
} // namespace OobSimulator
6 changes: 6 additions & 0 deletions windows/tools/OobSimulator/Globals.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// clang-format off
#include "pch.h"
#include "Globals.h"
// clang-format on

HWND g_hwnd = nullptr;
8 changes: 8 additions & 0 deletions windows/tools/OobSimulator/Globals.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef GLOBALS_H
#define GLOBALS_H

#include <Windows.h>

extern HWND g_hwnd;

#endif // GLOBALS_H
16 changes: 16 additions & 0 deletions windows/tools/OobSimulator/MainPage.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

namespace OobSimulator
{
[default_interface]
runtimeclass MainPage : Microsoft.UI.Xaml.Controls.Page
{
MainPage();

Double NavViewCompactModeThresholdWidth
{
get;
};
}
}
38 changes: 38 additions & 0 deletions windows/tools/OobSimulator/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!-- Copyright (c) Microsoft Corporation and Contributors. -->
<!-- Licensed under the MIT License. -->

<Page
x:Class="OobSimulator.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:OobSimulator"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<muxc:NavigationView x:Name="NavView" Loaded="NavView_Loaded" ItemInvoked="NavView_ItemInvoked" BackRequested="NavView_BackRequested" PaneDisplayMode="Top" AlwaysShowHeader="False">
<muxc:NavigationView.MenuItems>
<muxc:NavigationViewItemHeader Content="UWB" />
<muxc:NavigationViewItemSeparator />
<muxc:NavigationViewItem Tag="uwbsessiondata" Content="Session Data Generator">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xE928;" />
</NavigationViewItem.Icon>
</muxc:NavigationViewItem>
</muxc:NavigationView.MenuItems>
<ScrollViewer>
<Frame x:Name="ContentFrame" IsTabStop="True" NavigationFailed="ContentFrame_NavigationFailed" Navigated="ContentFrame_Navigated"/>
</ScrollViewer>
</muxc:NavigationView>

<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{x:Bind NavViewCompactModeThresholdWidth}" />
</VisualState.StateTriggers>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Page>
Loading

0 comments on commit cb0a472

Please sign in to comment.