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

Commit a27730c

Browse files
committed
Merge branch 'master' of github.com:openweave/openweave-core
2 parents 52ea55b + 9726ae3 commit a27730c

21 files changed

+81
-69
lines changed

src/ble/BLEEndPoint.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <Weave/Support/logging/WeaveLogging.h>
3939
#include <Weave/Support/CodeUtils.h>
4040
#include <Weave/Support/FlagUtils.hpp>
41+
#include <Weave/Support/WeaveFaultInjection.h>
4142

4243
#include <BleLayer/BLEEndPoint.h>
4344
#include <BleLayer/BleLayer.h>
@@ -764,6 +765,17 @@ BLE_ERROR BLEEndPoint::SendNextMessage()
764765
data = NULL; // Ownership passed to fragmenter's tx buf on PrepareNextFragment success.
765766

766767
// Send first message fragment over the air.
768+
WEAVE_FAULT_INJECT(nl::Weave::FaultInjection::kFault_WOBLESend,
769+
{
770+
if (mRole == kBleRole_Central)
771+
{
772+
err = BLE_ERROR_GATT_WRITE_FAILED;
773+
} else {
774+
err = BLE_ERROR_GATT_INDICATE_FAILED;
775+
}
776+
ExitNow();
777+
}
778+
);
767779
err = SendCharacteristic(mWoBle.TxPacket());
768780
SuccessOrExit(err);
769781

src/lib/profiles/data-management/Current/MessageDef.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
*
3+
* Copyright (c) 2018 Google LLC.
34
* Copyright (c) 2016-2017 Nest Labs, Inc.
45
* All rights reserved.
56
*
@@ -47,6 +48,10 @@
4748

4849
#include <stdio.h>
4950

51+
using namespace ::nl;
52+
using namespace ::nl::Weave;
53+
using namespace ::nl::Weave::TLV;
54+
5055
#ifndef MIN
5156
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
5257
#endif
@@ -2741,13 +2746,19 @@ WEAVE_ERROR StatusList::Parser::CheckSchemaValidity(void) const
27412746

27422747
while (WEAVE_NO_ERROR == (err = reader.Next()))
27432748
{
2749+
TLVType type;
2750+
uint64_t tag;
2751+
27442752
// TODO: The spec says the StatusList should be an array of arrays, but in
27452753
// the current implementation it's an array of structures. The array of
27462754
// arrays is less intuitive but more space efficient.
2747-
VerifyOrExit(nl::Weave::TLV::AnonymousTag == reader.GetTag(), err = WEAVE_ERROR_INVALID_TLV_TAG);
27482755

2749-
VerifyOrExit((nl::Weave::TLV::kTLVType_Structure == reader.GetType() ||
2750-
nl::Weave::TLV::kTLVType_Array), err = WEAVE_ERROR_WRONG_TLV_TYPE);
2756+
tag = reader.GetTag();
2757+
VerifyOrExit(nl::Weave::TLV::AnonymousTag == tag, err = WEAVE_ERROR_INVALID_TLV_TAG);
2758+
2759+
type = reader.GetType();
2760+
VerifyOrExit((nl::Weave::TLV::kTLVType_Structure == type ||
2761+
nl::Weave::TLV::kTLVType_Array == type), err = WEAVE_ERROR_WRONG_TLV_TYPE);
27512762

27522763
{
27532764
StatusElement::Parser status;

src/lib/profiles/data-management/Current/SubscriptionClient.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,7 @@ WEAVE_ERROR SubscriptionClient::EndSubscription()
832832
switch (mCurrentState)
833833
{
834834
case kState_Subscribing:
835+
case kState_Resubscribe_Holdoff:
835836
// fall through
836837
case kState_Subscribing_IdAssigned:
837838

src/lib/profiles/data-management/Current/SubscriptionClient.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ class SubscriptionClient
295295
bool IsEstablishedIdle() { return (mCurrentState == kState_SubscriptionEstablished_Idle); }
296296
bool IsFree() { return (mCurrentState == kState_Free); }
297297
bool IsAborting() { return (mCurrentState == kState_Aborting); }
298+
bool IsInResubscribeHoldoff() { return (mCurrentState == kState_Resubscribe_Holdoff); }
298299

299300
void IndicateActivity(void);
300301

src/lib/profiles/data-management/Legacy/ProfileDatabase.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ WEAVE_ERROR EncodePath(TLVWriter &aWriter,
429429
const uint64_t &aTag,
430430
uint32_t aProfileId,
431431
const uint64_t &aInstanceId,
432-
uint16_t aPathLen,
432+
uint32_t aPathLen,
433433
...)
434434
{
435435
WEAVE_ERROR err = WEAVE_NO_ERROR;
@@ -451,7 +451,7 @@ WEAVE_ERROR EncodePath(TLVWriter &aWriter,
451451

452452
va_start(pathTags, aPathLen);
453453

454-
for (int i = 0; i < aPathLen; i++)
454+
for (uint32_t i = 0; i < aPathLen; i++)
455455
{
456456
err = aWriter.PutNull(va_arg(pathTags, uint64_t));
457457

@@ -517,7 +517,7 @@ WEAVE_ERROR EncodePath(TLVWriter &aWriter,
517517
uint32_t aProfileId,
518518
const uint32_t aInstanceIdLen,
519519
const uint8_t *aInstanceId,
520-
uint16_t aPathLen,
520+
uint32_t aPathLen,
521521
...)
522522
{
523523
WEAVE_ERROR err = WEAVE_NO_ERROR;
@@ -539,7 +539,7 @@ WEAVE_ERROR EncodePath(TLVWriter &aWriter,
539539

540540
va_start(pathTags, aPathLen);
541541

542-
for (int i = 0; i < aPathLen; i++)
542+
for (uint32_t i = 0; i < aPathLen; i++)
543543
{
544544
err = aWriter.PutNull(va_arg(pathTags, uint64_t));
545545

@@ -598,7 +598,7 @@ WEAVE_ERROR EncodePath(TLVWriter &aWriter,
598598
const uint64_t &aTag,
599599
uint32_t aProfileId,
600600
const char *aInstanceId,
601-
uint16_t aPathLen,
601+
uint32_t aPathLen,
602602
...)
603603
{
604604
WEAVE_ERROR err = WEAVE_NO_ERROR;
@@ -620,7 +620,7 @@ WEAVE_ERROR EncodePath(TLVWriter &aWriter,
620620

621621
va_start(pathTags, aPathLen);
622622

623-
for (int i = 0; i < aPathLen; i++)
623+
for (uint32_t i = 0; i < aPathLen; i++)
624624
{
625625
err = aWriter.PutNull(va_arg(pathTags, uint64_t));
626626

@@ -679,7 +679,7 @@ WEAVE_ERROR EncodeDeprecatedPath(TLVWriter &aWriter,
679679
const uint64_t &aTag,
680680
uint32_t aProfileId,
681681
const uint64_t &aInstanceId,
682-
uint16_t aPathLen,
682+
uint32_t aPathLen,
683683
...)
684684
{
685685
WEAVE_ERROR err = WEAVE_NO_ERROR;
@@ -709,7 +709,7 @@ WEAVE_ERROR EncodeDeprecatedPath(TLVWriter &aWriter,
709709

710710
va_start(pathTags, aPathLen);
711711

712-
for (int i = 0; i < aPathLen; i++)
712+
for (uint32_t i = 0; i < aPathLen; i++)
713713
{
714714
err = aWriter.PutNull(va_arg(pathTags, uint64_t));
715715

@@ -768,7 +768,7 @@ WEAVE_ERROR EncodeDeprecatedPath(TLVWriter &aWriter,
768768
const uint64_t &aTag,
769769
uint32_t aProfileId,
770770
const char *aInstanceId,
771-
uint16_t aPathLen,
771+
uint32_t aPathLen,
772772
...)
773773
{
774774
WEAVE_ERROR err = WEAVE_NO_ERROR;
@@ -798,7 +798,7 @@ WEAVE_ERROR EncodeDeprecatedPath(TLVWriter &aWriter,
798798

799799
va_start(pathTags, aPathLen);
800800

801-
for (int i = 0; i < aPathLen; i++)
801+
for (uint32_t i = 0; i < aPathLen; i++)
802802
{
803803
err = aWriter.PutNull(va_arg(pathTags, uint64_t));
804804

src/lib/profiles/data-management/Legacy/ProfileDatabase.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,22 +386,22 @@ namespace WeaveMakeManagedNamespaceIdentifier(DataManagement, kWeaveManagedNames
386386
const uint64_t &aTag,
387387
uint32_t aProfileId,
388388
const uint64_t &aInstanceId,
389-
uint16_t aPathLen,
389+
uint32_t aPathLen,
390390
...);
391391

392392
WEAVE_ERROR EncodePath(nl::Weave::TLV::TLVWriter &aWriter,
393393
const uint64_t &aTag,
394394
uint32_t aProfileId,
395395
const uint32_t aInstanceIdLen,
396396
const uint8_t *aInstanceId,
397-
uint16_t aPathLen,
397+
uint32_t aPathLen,
398398
...);
399399

400400
WEAVE_ERROR EncodePath(nl::Weave::TLV::TLVWriter &aWriter,
401401
const uint64_t &aTag,
402402
uint32_t aProfileId,
403403
const char *aInstanceId,
404-
uint16_t aPathLen,
404+
uint32_t aPathLen,
405405
...);
406406

407407
/*
@@ -414,14 +414,14 @@ namespace WeaveMakeManagedNamespaceIdentifier(DataManagement, kWeaveManagedNames
414414
const uint64_t &aTag,
415415
uint32_t aProfileId,
416416
const uint64_t &aInstanceId,
417-
uint16_t aPathLen,
417+
uint32_t aPathLen,
418418
...);
419419

420420
WEAVE_ERROR EncodeDeprecatedPath(nl::Weave::TLV::TLVWriter &aWriter,
421421
const uint64_t &aTag,
422422
uint32_t aProfileId,
423423
const char *aInstanceId,
424-
uint16_t aPathLen,
424+
uint32_t aPathLen,
425425
...);
426426

427427
/**

src/lib/support/WeaveFaultInjection.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ static const nl::FaultInjection::Name sFaultNames[] = {
7474
"TunnelQueueFull",
7575
"TunnelPacketDropByPolicy",
7676
#endif // WEAVE_CONFIG_ENABLE_TUNNELING
77+
#if CONFIG_NETWORK_LAYER_BLE
78+
"WOBLESend",
79+
#endif // CONFIG_NETWORK_LAYER_BLE
7780
};
7881

7982

src/lib/support/WeaveFaultInjection.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ typedef enum
9292
kFault_TunnelQueueFull, /**< Trigger a WEAVE_ERROR_TUNNEL_SERVICE_QUEUE_FULL when enqueueing a packet in the Tunnel queue */
9393
kFault_TunnelPacketDropByPolicy, /**< Trigger an explicit drop of the packet as if done by an application policy */
9494
#endif // WEAVE_CONFIG_ENABLE_TUNNELING
95+
#if CONFIG_NETWORK_LAYER_BLE
96+
kFault_WOBLESend, /**< Inject a GATT error when sending the first fragment of a Weave message over BLE */
97+
#endif // CONFIG_NETWORK_LAYER_BLE
9598
kFault_NumItems,
9699
} Id;
97100

src/test-apps/MockWdmNodeOptions.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
*
3+
* Copyright (c) 2018 Google LLC.
34
* Copyright (c) 2018 Nest Labs, Inc.
45
* All rights reserved.
56
*
@@ -515,7 +516,7 @@ bool MockWdmNodeOptions::HandleOption(const char *progName, OptionSet *optSet, i
515516
}
516517
case kToolOpt_WdmUpdateNumberOfTraits:
517518
{
518-
int tmp;
519+
uint32_t tmp;
519520

520521
if ((!ParseInt(arg, tmp)) || (tmp < 1) || (tmp > mWdmUpdateMaxNumberOfTraits))
521522
{

src/test-apps/TestDataManagement.cpp

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ static OptionSet *gToolOptionSets[] =
151151
} \
152152
} while (0)
153153

154-
WEAVE_ERROR ValidatePath(TLVReader &aReader,
155-
const uint64_t &aTag,
156-
uint32_t aProfileId,
157-
const uint64_t &aInstanceId,
158-
uint16_t aPathLen,
159-
...)
154+
static WEAVE_ERROR ValidatePath(TLVReader &aReader,
155+
const uint64_t &aTag,
156+
uint32_t aProfileId,
157+
const uint64_t &aInstanceId,
158+
uint32_t aPathLen,
159+
...)
160160
{
161161
WEAVE_ERROR err;
162162

@@ -237,7 +237,7 @@ WEAVE_ERROR ValidatePath(TLVReader &aReader,
237237

238238
// now, the residual path elements, if any
239239

240-
for (int i = 0; i < aPathLen; i++)
240+
for (uint32_t i = 0; i < aPathLen; i++)
241241
{
242242
err = aReader.Next();
243243
SuccessOrExit(err);
@@ -276,22 +276,6 @@ WEAVE_ERROR ValidatePath(TLVReader &aReader,
276276
return err;
277277
}
278278

279-
/*
280-
* one day we might want to include the other form of instance ID
281-
* in testing. for now just leave this as a placeholder.
282-
*/
283-
284-
WEAVE_ERROR ValidatePath(nl::Weave::TLV::TLVReader &aReader,
285-
const uint64_t &aTag,
286-
uint32_t aProfileId,
287-
uint32_t aInstanceIdLen,
288-
uint8_t *aInstanceId,
289-
uint16_t aPathLen,
290-
...)
291-
{
292-
return WEAVE_NO_ERROR;
293-
}
294-
295279
/*
296280
* in order to use the "new improved" data management, we have to create
297281
* a sub-class of the WDM client and supply the relevant methods as follows.

0 commit comments

Comments
 (0)