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

Commit 820c871

Browse files
authored
Merge pull request #67 from gandreello/giuseppe/woble-fault-injection
Added a fault injection point in WoBLE
2 parents 4022661 + 272b626 commit 820c871

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
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/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/happy/test-templates/WeaveBle.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def __start_server_side(self):
172172
return
173173

174174
cmd += " --enable-bluez-peripheral --peripheral-name N0001 --peripheral-address " + self.interfaces[0]["bd_address"]
175+
cmd += " --print-fault-counters"
175176
self.start_weave_process(node_id=self.server_node_id, cmd=cmd, tag=self.server_process_tag, rootMode=True)
176177

177178
def resetBluez(self):

0 commit comments

Comments
 (0)