Skip to content

Commit

Permalink
Pull request project-chip#158: Cherry-Pick UIC-2508 added data type fix
Browse files Browse the repository at this point in the history
Merge in WMN_TOOLS/matter from cherry-pick/uic_fix_data_type to silabs_1.0

Squashed commit of the following:

commit 9cdecc8d62f9aae0bfcdd38a632183db700193c2
Author: Dereje Wassie <Dereje.Wassie@silabs.com>
Date:   Fri Oct 7 13:27:14 2022 +0000

    Pull request project-chip#154: UIC-2508 added data type fix

    Merge in WMN_TOOLS/matter from bugfix/uic-2508_fix_attribute_read_data_type_error to silabs

    Squashed commit of the following:

    commit 8bddd9c5ebc3a679e42488660b3eb6f727524030
    Author: Dereje Wassie <Dereje.Wassie@silabs.com>
    Date:   Fri Oct 7 14:53:23 2022 +0200

        UIC-2508 added data type fix
  • Loading branch information
mkardous-silabs authored and jmartinez-silabs committed Oct 7, 2022
1 parent 3410a66 commit 733deac
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
* sections of the MSLA applicable to Source Code.
*
******************************************************************************/

#include "app/data-model/NullObject.h"

// Default translation
template <typename T>
std::optional<T> from_json(const nlohmann::json & value)
{
return std::nullopt;
}

/***************************** Simple types Convertes **************/

template<> inline
Expand All @@ -40,7 +39,86 @@ std::optional<std::string> from_json(const nlohmann::json & value)
return value;
}


template <>
inline std::optional<uint8_t> from_json(const nlohmann::json & value)
{
return value;
}
template <>
inline std::optional<uint16_t> from_json(const nlohmann::json & value)
{
return value;
}
template <>
inline std::optional<uint32_t> from_json(const nlohmann::json & value)
{
return value;
}
template <>
inline std::optional<uint64_t> from_json(const nlohmann::json & value)
{
return value;
}
template <>
inline std::optional<chip::app::DataModel::Nullable<int>> from_json(const nlohmann::json & value)
{
if (value.is_null())
{
return std::nullopt;
}
else
{
return chip::app::DataModel::Nullable<int>(value);
}
}
template <>
inline std::optional<chip::app::DataModel::Nullable<uint8_t>> from_json(const nlohmann::json & value)
{
if (value.is_null())
{
return std::nullopt;
}
else
{
return chip::app::DataModel::Nullable<uint8_t>(value);
}
}
template <>
inline std::optional<chip::app::DataModel::Nullable<uint16_t>> from_json(const nlohmann::json & value)
{
if (value.is_null())
{
return std::nullopt;
}
else
{
return chip::app::DataModel::Nullable<uint16_t>(value);
}
}
template <>
inline std::optional<chip::app::DataModel::Nullable<uint32_t>> from_json(const nlohmann::json & value)
{
if (value.is_null())
{
return std::nullopt;
}
else
{
return chip::app::DataModel::Nullable<uint32_t>(value);
}
}
template <>
inline std::optional<chip::app::DataModel::Nullable<uint64_t>> from_json(const nlohmann::json & value)
{
if (value.is_null())
{
return std::nullopt;
}
else
{
return chip::app::DataModel::Nullable<uint64_t>(value);
}
}
/***************************** Bitmap Convertes **************/
//{{#zcl_clusters}}
//{{#zcl_bitmaps}}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 733deac

Please sign in to comment.