Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
add Float number print in DataElement::Parser::ParseData
Browse files Browse the repository at this point in the history
  • Loading branch information
yunhanw-google committed May 4, 2020
1 parent 4ccba6b commit 0669aac
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
11 changes: 11 additions & 0 deletions src/lib/profiles/data-management/Current/MessageDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,17 @@ DataElement::Parser::ParseData(nl::Weave::TLV::TLVReader & aReader, int aDepth)
break;
}

case nl::Weave::TLV::kTLVType_FloatingPointNumber:
{
double value_fp;

err = aReader.Get(value_fp);
SuccessOrExit(err);

PRETTY_PRINT_SAMELINE("%lf, ", value_fp);
break;
}

case nl::Weave::TLV::kTLVType_Boolean:
{
bool value_b;
Expand Down
8 changes: 4 additions & 4 deletions src/test-apps/MockSinkTraits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ TestATraitDataSink::SetLeafData(PropertyPathHandle aLeafHandle, TLVReader &aRead
err = aReader.Get(tax);
SuccessOrExit(err);

WeaveLogDetail(DataManagement, "<< ta_x %d", tax);
WeaveLogDetail(DataManagement, "<< ta_x %lf", tax);
break;

case TestATrait::kPropertyHandle_TaI_Value:
Expand Down Expand Up @@ -1012,7 +1012,7 @@ WEAVE_ERROR TestATraitDataSink::GetLeafData(PropertyPathHandle aLeafHandle, uint
err = aWriter.Put(aTagToWrite, tax);
SuccessOrExit(err);

WeaveLogDetail(DataManagement, ">> ta_x %d", tax);
WeaveLogDetail(DataManagement, ">> ta_x %lf", tax);
break;

case TestATrait::kPropertyHandle_TaI_Value:
Expand Down Expand Up @@ -2336,7 +2336,7 @@ TestATraitUpdatableDataSink::SetLeafData(PropertyPathHandle aLeafHandle, TLVRead
err = aReader.Get(tax);
SuccessOrExit(err);

WeaveLogDetail(DataManagement, "<< ta_x %d", tax);
WeaveLogDetail(DataManagement, "<< ta_x %lf", tax);
break;

case TestATrait::kPropertyHandle_TaI_Value:
Expand Down Expand Up @@ -2590,7 +2590,7 @@ WEAVE_ERROR TestATraitUpdatableDataSink::GetLeafData(PropertyPathHandle aLeafHan
err = aWriter.Put(aTagToWrite, tax);
SuccessOrExit(err);

WeaveLogDetail(DataManagement, ">> ta_x %d", tax);
WeaveLogDetail(DataManagement, ">> ta_x %lf", tax);
break;

case TestATrait::kPropertyHandle_TaI_Value:
Expand Down
4 changes: 2 additions & 2 deletions src/test-apps/MockSinkTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class TestATraitUpdatableDataSink : public MockTraitUpdatableDataSink
bool tav;
char taw[20];
// boxed float
int16_t tax;
double tax;

bool nullified_path[Schema::Nest::Test::Trait::TestATrait::kPropertyHandle_TaJ_Value_SaB];
uint32_t mTestCounter = 0;
Expand Down Expand Up @@ -320,7 +320,7 @@ class TestATraitDataSink : public MockTraitDataSink, public MockTraitDataSourceD
bool tav;
char taw[20];
// boxed float
int16_t tax;
double tax;

bool nullified_path[Schema::Nest::Test::Trait::TestATrait::kPropertyHandle_TaJ_Value_SaB];
};
Expand Down
6 changes: 3 additions & 3 deletions src/test-apps/MockSourceTraits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ TestATraitDataSource::TestATraitDataSource():
tat = 1000;
tau = -1000;
tav = true;
tax = 800;
tax = 800.1;

for (size_t i = 0; i < 4; i++) {
tai_map[i] = 100 + i;
Expand Down Expand Up @@ -1061,7 +1061,7 @@ TestATraitDataSource::SetLeafData(PropertyPathHandle aLeafHandle, TLVReader &aRe
err = aReader.Get(tax);
SuccessOrExit(err);

WeaveLogDetail(DataManagement, "<< ta_x %d", tax);
WeaveLogDetail(DataManagement, "<< ta_x %lf", tax);
break;

case TestATrait::kPropertyHandle_TaI_Value:
Expand Down Expand Up @@ -1302,7 +1302,7 @@ WEAVE_ERROR TestATraitDataSource::GetLeafData(PropertyPathHandle aLeafHandle, ui
err = aWriter.Put(aTagToWrite, tax);
SuccessOrExit(err);

WeaveLogDetail(DataManagement, ">> ta_x %d", tax);
WeaveLogDetail(DataManagement, ">> ta_x %lf", tax);
break;

case TestATrait::kPropertyHandle_TaI_Value:
Expand Down
2 changes: 1 addition & 1 deletion src/test-apps/MockSourceTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class TestATraitDataSource :
bool tav;
char *taw = "boxedstring";
// boxed float
int16_t tax;
double tax;

bool nullified_path[Schema::Nest::Test::Trait::TestATrait::kPropertyHandle_TaJ_Value_SaB];

Expand Down

0 comments on commit 0669aac

Please sign in to comment.