Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import software update manager generic code #59

Merged
merged 5 commits into from
Mar 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 67 additions & 67 deletions src/ble/BLEEndPoint.cpp

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions src/ble/BleLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ BLE_ERROR BleLayer::NewBleEndPoint(BLEEndPoint ** retEndPoint, BLE_CONNECTION_OB
*retEndPoint = sBLEEndPointPool.GetFree();
if (*retEndPoint == NULL)
{
chipLogError(Ble, "%s endpoint pool FULL", "Ble");
ChipLogError(Ble, "%s endpoint pool FULL", "Ble");
return BLE_ERROR_NO_ENDPOINTS;
}

Expand Down Expand Up @@ -421,7 +421,7 @@ BLE_ERROR BleLayer::HandleBleTransportConnectionInitiated(BLE_CONNECTION_OBJECT

if (err != BLE_NO_ERROR)
{
chipLogError(Ble, "HandlechipConnectionReceived failed, err = %d", err);
ChipLogError(Ble, "HandlechipConnectionReceived failed, err = %d", err);
}

return err;
Expand All @@ -432,15 +432,15 @@ bool BleLayer::HandleWriteReceived(BLE_CONNECTION_OBJECT connObj, const chipBleU
{
if (!UUIDsMatch(&CHIP_BLE_SVC_ID, svcId))
{
chipLogError(Ble, "ble write rcvd on unknown svc id");
ChipLogError(Ble, "ble write rcvd on unknown svc id");
ExitNow();
}

if (UUIDsMatch(&CHIP_BLE_CHAR_1_ID, charId))
{
if (pBuf == NULL)
{
chipLogError(Ble, "rcvd null ble write");
ChipLogError(Ble, "rcvd null ble write");
ExitNow();
}

Expand All @@ -453,7 +453,7 @@ bool BleLayer::HandleWriteReceived(BLE_CONNECTION_OBJECT connObj, const chipBleU
pBuf = NULL;
if (status != BLE_NO_ERROR)
{
chipLogError(Ble, "BLEEndPoint rcv failed, err = %d", status);
ChipLogError(Ble, "BLEEndPoint rcv failed, err = %d", status);
}
}
else
Expand All @@ -462,13 +462,13 @@ bool BleLayer::HandleWriteReceived(BLE_CONNECTION_OBJECT connObj, const chipBleU
pBuf = NULL;
if (status != BLE_NO_ERROR)
{
chipLogError(Ble, "failed handle new chip BLE connection, status = %d", status);
ChipLogError(Ble, "failed handle new chip BLE connection, status = %d", status);
}
}
}
else
{
chipLogError(Ble, "ble write rcvd on unknown char");
ChipLogError(Ble, "ble write rcvd on unknown char");
}

exit:
Expand All @@ -492,7 +492,7 @@ bool BleLayer::HandleIndicationReceived(BLE_CONNECTION_OBJECT connObj, const chi
{
if (pBuf == NULL)
{
chipLogError(Ble, "rcvd null ble indication");
ChipLogError(Ble, "rcvd null ble indication");
ExitNow();
}

Expand All @@ -505,17 +505,17 @@ bool BleLayer::HandleIndicationReceived(BLE_CONNECTION_OBJECT connObj, const chi
pBuf = NULL;
if (status != BLE_NO_ERROR)
{
chipLogError(Ble, "BLEEndPoint rcv failed, err = %d", status);
ChipLogError(Ble, "BLEEndPoint rcv failed, err = %d", status);
}
}
else
{
chipLogDetail(Ble, "no endpoint for rcvd indication");
ChipLogDetail(Ble, "no endpoint for rcvd indication");
}
}
else
{
chipLogError(Ble, "ble ind rcvd on unknown char");
ChipLogError(Ble, "ble ind rcvd on unknown char");
}

exit:
Expand All @@ -540,7 +540,7 @@ bool BleLayer::HandleWriteConfirmation(BLE_CONNECTION_OBJECT connObj, const chip
}
else
{
chipLogError(Ble, "ble write con rcvd on unknown char");
ChipLogError(Ble, "ble write con rcvd on unknown char");
}

return true;
Expand All @@ -559,7 +559,7 @@ bool BleLayer::HandleIndicationConfirmation(BLE_CONNECTION_OBJECT connObj, const
}
else
{
chipLogError(Ble, "ble ind con rcvd on unknown char");
ChipLogError(Ble, "ble ind con rcvd on unknown char");
}

return true;
Expand All @@ -576,12 +576,12 @@ void BleLayer::HandleAckReceived(BLE_CONNECTION_OBJECT connObj)

if (status != BLE_NO_ERROR)
{
chipLogError(Ble, "endpoint conf recvd failed, err = %d", status);
ChipLogError(Ble, "endpoint conf recvd failed, err = %d", status);
}
}
else
{
chipLogError(Ble, "no endpoint for BLE sent data ack");
ChipLogError(Ble, "no endpoint for BLE sent data ack");
}
}

Expand All @@ -603,7 +603,7 @@ bool BleLayer::HandleSubscribeReceived(BLE_CONNECTION_OBJECT connObj, const chip
}
else
{
chipLogError(Ble, "no endpoint for sub recvd");
ChipLogError(Ble, "no endpoint for sub recvd");
}
}

Expand All @@ -627,7 +627,7 @@ bool BleLayer::HandleSubscribeComplete(BLE_CONNECTION_OBJECT connObj, const chip
}
else
{
chipLogError(Ble, "no endpoint for sub complete");
ChipLogError(Ble, "no endpoint for sub complete");
}
}

Expand All @@ -652,7 +652,7 @@ bool BleLayer::HandleUnsubscribeReceived(BLE_CONNECTION_OBJECT connObj, const ch
}
else
{
chipLogError(Ble, "no endpoint for unsub recvd");
ChipLogError(Ble, "no endpoint for unsub recvd");
}
}

Expand All @@ -677,7 +677,7 @@ bool BleLayer::HandleUnsubscribeComplete(BLE_CONNECTION_OBJECT connObj, const ch
}
else
{
chipLogError(Ble, "no endpoint for unsub complete");
ChipLogError(Ble, "no endpoint for unsub complete");
}
}

Expand Down
74 changes: 37 additions & 37 deletions src/ble/CHIPoBle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
#undef CHIP_BTP_PROTOCOL_ENGINE_DEBUG_LOGGING_ENABLED

#ifdef CHIP_BTP_PROTOCOL_ENGINE_DEBUG_LOGGING_ENABLED
#define chipLogDebugBtpEngine(MOD, MSG, ...) chipLogError(MOD, MSG, ##__VA_ARGS__)
#define ChipLogDebugBtpEngine(MOD, MSG, ...) ChipLogError(MOD, MSG, ##__VA_ARGS__)
#else
#define chipLogDebugBtpEngine(MOD, MSG, ...)
#define ChipLogDebugBtpEngine(MOD, MSG, ...)
#endif

#define CHIP_BLE_TRANSFER_PROTOCOL_HEADER_FLAGS_SIZE 1 // Size in bytes of enocded BTP fragment header flag bits
Expand Down Expand Up @@ -83,7 +83,7 @@ static void PrintBufDebug(PacketBuffer * buf)

for (int i = 0; i < buf->DataLength(); i++)
{
chipLogError(Ble, "\t%02x", b[i]);
ChipLogError(Ble, "\t%02x", b[i]);
}
#endif
}
Expand Down Expand Up @@ -166,13 +166,13 @@ bool CHIPoBle::HasUnackedData() const

bool CHIPoBle::IsValidAck(SequenceNumber_t ack_num) const
{
chipLogDebugBtpEngine(Ble, "entered IsValidAck, ack = %u, oldest = %u, newest = %u", ack_num, mTxOldestUnackedSeqNum,
ChipLogDebugBtpEngine(Ble, "entered IsValidAck, ack = %u, oldest = %u, newest = %u", ack_num, mTxOldestUnackedSeqNum,
mTxNewestUnackedSeqNum);

// Return false if not awaiting any ack.
if (!mExpectingAck)
{
chipLogDebugBtpEngine(Ble, "unexpected ack is invalid");
ChipLogDebugBtpEngine(Ble, "unexpected ack is invalid");
return false;
}

Expand All @@ -192,7 +192,7 @@ BLE_ERROR CHIPoBle::HandleAckReceived(SequenceNumber_t ack_num)
{
BLE_ERROR err = BLE_NO_ERROR;

chipLogDebugBtpEngine(Ble, "entered HandleAckReceived, ack_num = %u", ack_num);
ChipLogDebugBtpEngine(Ble, "entered HandleAckReceived, ack_num = %u", ack_num);

// Ensure ack_num falls within range of ack values we're expecting.
VerifyOrExit(IsValidAck(ack_num), err = BLE_ERROR_INVALID_ACK);
Expand Down Expand Up @@ -234,7 +234,7 @@ BLE_ERROR CHIPoBle::EncodeStandAloneAck(PacketBuffer * data)

// Acknowledge most recently received sequence number.
characteristic[1] = GetAndRecordRxAckSeqNum();
chipLogDebugBtpEngine(Ble, "===> encoded stand-alone ack = %u", characteristic[1]);
ChipLogDebugBtpEngine(Ble, "===> encoded stand-alone ack = %u", characteristic[1]);

// Include sequence number for stand-alone ack itself.
characteristic[2] = GetAndIncrementNextTxSeqNum();
Expand Down Expand Up @@ -313,7 +313,7 @@ BLE_ERROR CHIPoBle::HandleCharacteristicReceived(PacketBuffer * data, SequenceNu
// mRxFragnentSize may be smaller than the characteristic size.
data->SetDataLength(chip::min(data->DataLength(), mRxFragmentSize));

chipLogDebugBtpEngine(Ble, ">>> BTP reassembler received data:");
ChipLogDebugBtpEngine(Ble, ">>> BTP reassembler received data:");
PrintBufDebug(data);

if (mRxState == kState_Idle)
Expand Down Expand Up @@ -386,14 +386,14 @@ BLE_ERROR CHIPoBle::HandleCharacteristicReceived(PacketBuffer * data, SequenceNu
mRxState = kState_Error;

// Dump protocol engine state, plus header flags and received data length.
chipLogError(Ble, "HandleCharacteristicReceived failed, err = %d, rx_flags = %u", err, rx_flags);
ChipLogError(Ble, "HandleCharacteristicReceived failed, err = %d, rx_flags = %u", err, rx_flags);
if (didReceiveAck)
{
chipLogError(Ble, "With rx'd ack = %u", receivedAck);
ChipLogError(Ble, "With rx'd ack = %u", receivedAck);
}
if (mRxBuf != NULL)
{
chipLogError(Ble, "With rx buf data length = %u", mRxBuf->DataLength());
ChipLogError(Ble, "With rx buf data length = %u", mRxBuf->DataLength());
}
LogState();

Expand Down Expand Up @@ -442,7 +442,7 @@ bool CHIPoBle::HandleCharacteristicSend(PacketBuffer * data, bool send_ack)

if (send_ack && !HasUnackedData())
{
chipLogError(Ble, "HandleCharacteristicSend: send_ack true, but nothing to acknowledge.");
ChipLogError(Ble, "HandleCharacteristicSend: send_ack true, but nothing to acknowledge.");
return false;
}

Expand All @@ -457,7 +457,7 @@ bool CHIPoBle::HandleCharacteristicSend(PacketBuffer * data, bool send_ack)
mTxState = kState_InProgress;
mTxLength = mTxBuf->DataLength();

chipLogDebugBtpEngine(Ble, ">>> CHIPoBle preparing to send whole message:");
ChipLogDebugBtpEngine(Ble, ">>> CHIPoBle preparing to send whole message:");
PrintBufDebug(data);

// Determine fragment header size.
Expand All @@ -468,7 +468,7 @@ bool CHIPoBle::HandleCharacteristicSend(PacketBuffer * data, bool send_ack)
if (!mTxBuf->EnsureReservedSize(header_size + CHIP_CONFIG_BLE_PKT_RESERVED_SIZE))
{
// handle error
chipLogError(Ble, "HandleCharacteristicSend: not enough headroom");
ChipLogError(Ble, "HandleCharacteristicSend: not enough headroom");
mTxState = kState_Error;
mTxBuf = NULL; // Avoid double-free after assignment above, as caller frees data on error.

Expand All @@ -492,7 +492,7 @@ bool CHIPoBle::HandleCharacteristicSend(PacketBuffer * data, bool send_ack)
{
SetFlag(characteristic[0], kHeaderFlag_FragmentAck, true);
characteristic[cursor++] = GetAndRecordRxAckSeqNum();
chipLogDebugBtpEngine(Ble, "===> encoded piggybacked ack, ack_num = %u", characteristic[cursor - 1]);
ChipLogDebugBtpEngine(Ble, "===> encoded piggybacked ack, ack_num = %u", characteristic[cursor - 1]);
}

characteristic[cursor++] = GetAndIncrementNextTxSeqNum();
Expand All @@ -513,7 +513,7 @@ bool CHIPoBle::HandleCharacteristicSend(PacketBuffer * data, bool send_ack)
mTxLength -= mTxFragmentSize - cursor;
}

chipLogDebugBtpEngine(Ble, ">>> CHIPoBle preparing to send first fragment:");
ChipLogDebugBtpEngine(Ble, ">>> CHIPoBle preparing to send first fragment:");
PrintBufDebug(data);
}
else if (mTxState == kState_InProgress)
Expand Down Expand Up @@ -545,7 +545,7 @@ bool CHIPoBle::HandleCharacteristicSend(PacketBuffer * data, bool send_ack)
{
SetFlag(characteristic[0], kHeaderFlag_FragmentAck, true);
characteristic[cursor++] = GetAndRecordRxAckSeqNum();
chipLogDebugBtpEngine(Ble, "===> encoded piggybacked ack, ack_num = %u", characteristic[cursor - 1]);
ChipLogDebugBtpEngine(Ble, "===> encoded piggybacked ack, ack_num = %u", characteristic[cursor - 1]);
}

characteristic[cursor++] = GetAndIncrementNextTxSeqNum();
Expand All @@ -564,7 +564,7 @@ bool CHIPoBle::HandleCharacteristicSend(PacketBuffer * data, bool send_ack)
mTxLength -= mTxFragmentSize - cursor;
}

chipLogDebugBtpEngine(Ble, ">>> CHIPoBle preparing to send additional fragment:");
ChipLogDebugBtpEngine(Ble, ">>> CHIPoBle preparing to send additional fragment:");
PrintBufDebug(mTxBuf);
}
else
Expand Down Expand Up @@ -596,25 +596,25 @@ bool CHIPoBle::ClearTxPacket()

void CHIPoBle::LogState() const
{
chipLogError(Ble, "mAppState: %p", mAppState);

chipLogError(Ble, "mRxFragmentSize: %d", mRxFragmentSize);
chipLogError(Ble, "mRxState: %d", mRxState);
chipLogError(Ble, "mRxBuf: %p", mRxBuf);
chipLogError(Ble, "mRxNextSeqNum: %d", mRxNextSeqNum);
chipLogError(Ble, "mRxNewestUnackedSeqNum: %d", mRxNewestUnackedSeqNum);
chipLogError(Ble, "mRxOldestUnackedSeqNum: %d", mRxOldestUnackedSeqNum);
chipLogError(Ble, "mRxCharCount: %d", mRxCharCount);
chipLogError(Ble, "mRxPacketCount: %d", mRxPacketCount);

chipLogError(Ble, "mTxFragmentSize: %d", mTxFragmentSize);
chipLogError(Ble, "mTxState: %d", mTxState);
chipLogError(Ble, "mTxBuf: %p", mTxBuf);
chipLogError(Ble, "mTxNextSeqNum: %d", mTxNextSeqNum);
chipLogError(Ble, "mTxNewestUnackedSeqNum: %d", mTxNewestUnackedSeqNum);
chipLogError(Ble, "mTxOldestUnackedSeqNum: %d", mTxOldestUnackedSeqNum);
chipLogError(Ble, "mTxCharCount: %d", mTxCharCount);
chipLogError(Ble, "mTxPacketCount: %d", mTxPacketCount);
ChipLogError(Ble, "mAppState: %p", mAppState);

ChipLogError(Ble, "mRxFragmentSize: %d", mRxFragmentSize);
ChipLogError(Ble, "mRxState: %d", mRxState);
ChipLogError(Ble, "mRxBuf: %p", mRxBuf);
ChipLogError(Ble, "mRxNextSeqNum: %d", mRxNextSeqNum);
ChipLogError(Ble, "mRxNewestUnackedSeqNum: %d", mRxNewestUnackedSeqNum);
ChipLogError(Ble, "mRxOldestUnackedSeqNum: %d", mRxOldestUnackedSeqNum);
ChipLogError(Ble, "mRxCharCount: %d", mRxCharCount);
ChipLogError(Ble, "mRxPacketCount: %d", mRxPacketCount);

ChipLogError(Ble, "mTxFragmentSize: %d", mTxFragmentSize);
ChipLogError(Ble, "mTxState: %d", mTxState);
ChipLogError(Ble, "mTxBuf: %p", mTxBuf);
ChipLogError(Ble, "mTxNextSeqNum: %d", mTxNextSeqNum);
ChipLogError(Ble, "mTxNewestUnackedSeqNum: %d", mTxNewestUnackedSeqNum);
ChipLogError(Ble, "mTxOldestUnackedSeqNum: %d", mTxOldestUnackedSeqNum);
ChipLogError(Ble, "mTxCharCount: %d", mTxCharCount);
ChipLogError(Ble, "mTxPacketCount: %d", mTxPacketCount);
}

void CHIPoBle::LogStateDebug() const
Expand Down
Loading