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

Use enum class for TLVElementType and TLVTagControl. #3157

Merged
merged 9 commits into from
Oct 12, 2020
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Connected Home over IP {#mainpage}
# Connected Home over IP

![Main](https://github.com/project-chip/connectedhomeip/workflows/Builds/badge.svg)
![Examples](https://github.com/project-chip/connectedhomeip/workflows/Examples/badge.svg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*
*/

#ifndef __CHIPTOOL_BARRIERCONTROL_COMMANDS_H__
#define __CHIPTOOL_BARRIERCONTROL_COMMANDS_H__
#pragma once

#include "../../common/ModelCommand.h"

Expand Down Expand Up @@ -61,5 +60,3 @@ void registerClusterBarrierControl(Commands & commands)

commands.Register(clusterName, clusterCommands);
}

#endif // __CHIPTOOL_BARRIERCONTROL_COMMANDS_H__
5 changes: 1 addition & 4 deletions examples/chip-tool/commands/clusters/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
//
//

#ifndef __CHIPTOOL_CLUSTERS_COMMANDS_H__
#define __CHIPTOOL_CLUSTERS_COMMANDS_H__
#pragma once

#include "../common/ModelCommand.h"

Expand Down Expand Up @@ -3677,5 +3676,3 @@ void registerClusters(Commands & commands)
registerClusterScenes(commands);
registerClusterTemperatureMeasurement(commands);
}

#endif // __CHIPTOOL_CLUSTERS_COMMANDS_H__
5 changes: 1 addition & 4 deletions examples/chip-tool/commands/clusters/DoorLock/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*
*/

#ifndef __CHIPTOOL_DOORLOCK_COMMANDS_H__
#define __CHIPTOOL_DOORLOCK_COMMANDS_H__
#pragma once

#include "../../common/ModelCommand.h"

Expand Down Expand Up @@ -61,5 +60,3 @@ void registerClusterDoorLock(Commands & commands)

commands.Register(clusterName, clusterCommands);
}

#endif // __CHIPTOOL_DOORLOCK_COMMANDS_H__
5 changes: 1 addition & 4 deletions examples/chip-tool/commands/common/Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*
*/

#ifndef __CHIPTOOL_COMMAND_H__
#define __CHIPTOOL_COMMAND_H__
#pragma once

#include <controller/CHIPDeviceController.h>
#include <inet/InetInterface.h>
Expand Down Expand Up @@ -110,5 +109,3 @@ class Command
const char * mName = nullptr;
std::vector<Argument> mArgs;
};

#endif // __CHIPTOOL_COMMAND_H__
5 changes: 1 addition & 4 deletions examples/chip-tool/commands/common/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*
*/

#ifndef __CHIPTOOL_COMMANDS_H__
#define __CHIPTOOL_COMMANDS_H__
#pragma once

#include "Command.h"
#include <map>
Expand All @@ -43,5 +42,3 @@ class Commands

std::map<const char *, std::vector<std::unique_ptr<Command>>> clusters;
};

#endif // __CHIPTOOL_COMMANDS_H__
8 changes: 4 additions & 4 deletions examples/chip-tool/commands/common/EchoCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ void EchoCommand::SendEcho() const
CHIP_ERROR err = mController->SendMessage(NULL, buffer);
if (err == CHIP_NO_ERROR)
{
ChipLogProgress(chipTool, "Echo (%s): Message sent to server", GetName());
ChipLogProgress(chipTool, "Echo (%s): Message sent to server", GetNetworkName());
}
else
{
ChipLogError(chipTool, "Echo (%s): %s", GetName(), ErrorStr(err));
ChipLogError(chipTool, "Echo (%s): %s", GetNetworkName(), ErrorStr(err));
}
}

Expand All @@ -62,11 +62,11 @@ void EchoCommand::ReceiveEcho(PacketBuffer * buffer) const
bool isEchoIdenticalToMessage = strncmp(msg_buffer, PAYLOAD, data_len) == 0;
if (isEchoIdenticalToMessage)
{
ChipLogProgress(chipTool, "Echo (%s): Received expected message !", GetName());
ChipLogProgress(chipTool, "Echo (%s): Received expected message !", GetNetworkName());
}
else
{
ChipLogProgress(chipTool, "Echo: (%s): Error \nSend: %s \nRecv: %s", GetName(), PAYLOAD, msg_buffer);
ChipLogProgress(chipTool, "Echo: (%s): Error \nSend: %s \nRecv: %s", GetNetworkName(), PAYLOAD, msg_buffer);
}
}

Expand Down
5 changes: 1 addition & 4 deletions examples/chip-tool/commands/common/EchoCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*
*/

#ifndef __CHIPTOOL_COMMAND_ECHO_H__
#define __CHIPTOOL_COMMAND_ECHO_H__
#pragma once

#include "NetworkCommand.h"

Expand All @@ -40,5 +39,3 @@ class EchoCommand : public NetworkCommand

ChipDeviceController * mController = nullptr;
};

#endif // __CHIPTOOL_COMMAND_ECHO_H__
20 changes: 15 additions & 5 deletions examples/chip-tool/commands/common/ModelCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ bool isValidFrame(uint8_t frameControl)

void ModelCommand::OnConnect(ChipDeviceController * dc)
{
SendCommand(dc);
UpdateWaitForResponse(true);
WaitForResponse();
if (SendCommand(dc))
{
UpdateWaitForResponse(true);
WaitForResponse();
}
}

void ModelCommand::OnError(ChipDeviceController * dc, CHIP_ERROR err)
Expand Down Expand Up @@ -80,7 +82,7 @@ CHIP_ERROR ModelCommand::Run(ChipDeviceController * dc, NodeId remoteId)
return err;
}

void ModelCommand::SendCommand(ChipDeviceController * dc)
bool ModelCommand::SendCommand(ChipDeviceController * dc)
{
// Make sure our buffer is big enough, but this will need a better setup!
static const size_t bufferSize = 1024;
Expand All @@ -89,10 +91,17 @@ void ModelCommand::SendCommand(ChipDeviceController * dc)
if (buffer == nullptr)
{
ChipLogError(chipTool, "Failed to allocate memory for packet data.");
return;
return false;
}

uint16_t dataLength = EncodeCommand(buffer, bufferSize, mEndPointId);
if (dataLength == 0)
{
PacketBuffer::Free(buffer);
ChipLogError(chipTool, "Error while encoding data for command: %s", GetName());
return false;
}

buffer->SetDataLength(dataLength);
ChipLogProgress(chipTool, "Encoded data of length %d", dataLength);

Expand All @@ -101,6 +110,7 @@ void ModelCommand::SendCommand(ChipDeviceController * dc)
#endif

dc->SendMessage(NULL, buffer);
return true;
}

void ModelCommand::ReceiveCommandResponse(ChipDeviceController * dc, PacketBuffer * buffer) const
Expand Down
7 changes: 2 additions & 5 deletions examples/chip-tool/commands/common/ModelCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*
*/

#ifndef __CHIPTOOL_MODELCOMMAND_H__
#define __CHIPTOOL_MODELCOMMAND_H__
#pragma once

#include "NetworkCommand.h"

Expand Down Expand Up @@ -56,7 +55,7 @@ class ModelCommand : public NetworkCommand
virtual bool HandleClusterResponse(uint8_t * message, uint16_t messageLen) const { return false; }

private:
void SendCommand(ChipDeviceController * dc);
bool SendCommand(ChipDeviceController * dc);
void ReceiveCommandResponse(ChipDeviceController * dc, chip::System::PacketBuffer * buffer) const;

void ParseGlobalResponseCommand(uint8_t commandId, uint8_t * message, uint16_t messageLen) const;
Expand All @@ -76,5 +75,3 @@ class ModelCommand : public NetworkCommand
uint32_t mEndPointId;
uint16_t mClusterId;
};

#endif // __CHIPTOOL_MODELCOMMAND_H__
7 changes: 2 additions & 5 deletions examples/chip-tool/commands/common/NetworkCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*
*/

#ifndef __CHIPTOOL_IPCOMMAND_H__
#define __CHIPTOOL_IPCOMMAND_H__
#pragma once

#include "Command.h"

Expand Down Expand Up @@ -46,7 +45,7 @@ class NetworkCommand : public Command
}
}

const char * GetName(void) const { return mName; }
const char * GetNetworkName(void) const { return mName; }

virtual void OnConnect(ChipDeviceController * dc) = 0;
virtual void OnError(ChipDeviceController * dc, CHIP_ERROR err) = 0;
Expand All @@ -65,5 +64,3 @@ class NetworkCommand : public Command
uint32_t mDiscriminator;
uint32_t mSetupPINCode;
};

#endif //__CHIPTOOL_IPCOMMAND_H__
5 changes: 1 addition & 4 deletions examples/chip-tool/commands/echo/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*
*/

#ifndef __CHIPTOOL_ECHO_COMMANDS_H__
#define __CHIPTOOL_ECHO_COMMANDS_H__
#pragma once

#include "../common/EchoCommand.h"

Expand All @@ -44,5 +43,3 @@ void registerCommandsEcho(Commands & commands)

commands.Register(clusterName, clusterCommands);
}

#endif // __CHIPTOOL_ECHO_COMMANDS_H__
5 changes: 1 addition & 4 deletions examples/common/chip-app-server/include/DataModelHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
* This file defines the API for the handler for data model messages.
*/

#ifndef DATA_MODEL_HANDLER_H
#define DATA_MODEL_HANDLER_H
#pragma once

#include <system/SystemPacketBuffer.h>
#include <transport/SecureSessionMgr.h>
Expand All @@ -39,5 +38,3 @@ void HandleDataModelMessage(const chip::PacketHeader & header, chip::System::Pac
chip::SecureSessionMgrBase * mgr);
void InitDataModelHandler();
}

#endif // DATA_MODEL_HANDLER_H
5 changes: 1 addition & 4 deletions examples/common/chip-app-server/include/QRCodeUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
* limitations under the License.
*/

#ifndef QR_CODE_UTIL_H
#define QR_CODE_UTIL_H
#pragma once

#include <setup_payload/SetupPayload.h>

void PrintQRCode(chip::RendezvousInformationFlags rendezvousFlags);

#endif // QR_CODE_UTIL_H
5 changes: 1 addition & 4 deletions examples/common/chip-app-server/include/RendezvousServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
* limitations under the License.
*/

#ifndef CHIP_APP_SERVER_RENDEZVOUS_DELEGATE_H_
#define CHIP_APP_SERVER_RENDEZVOUS_DELEGATE_H_
#pragma once

#include <platform/CHIPDeviceLayer.h>
#include <transport/RendezvousSession.h>
Expand All @@ -40,5 +39,3 @@ class RendezvousServer : public RendezvousSessionDelegate
};

} // namespace chip

#endif // CHIP_APP_SERVER_RENDEZVOUS_DELEGATE_H_
5 changes: 1 addition & 4 deletions examples/common/chip-app-server/include/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
* limitations under the License.
*/

#ifndef CHIP_APP_SERVER_SERVER_H
#define CHIP_APP_SERVER_SERVER_H
#pragma once

#include <inet/IPAddress.h>
#include <inet/InetLayer.h>
Expand All @@ -33,5 +32,3 @@ using DemoSessionManager = chip::SecureSessionMgr<chip::Transport::UDP>;
* @param [in] sessions The demo's session manager.
*/
void InitServer();

#endif // CHIP_APP_SERVER_SERVER_H
5 changes: 1 addition & 4 deletions examples/common/screen-framework/include/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
*
*/

#ifndef DISPLAY_H
#define DISPLAY_H
#pragma once

#include "esp_system.h"

Expand Down Expand Up @@ -98,5 +97,3 @@ extern void DisplayStatusMessage(char * msg, uint16_t vpos);
extern bool WakeDisplay();

#endif // #if CONFIG_HAVE_DISPLAY

#endif // DISPLAY_H
5 changes: 1 addition & 4 deletions examples/common/screen-framework/include/ListScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
*
*/

#ifndef LIST_SCREEN_H
#define LIST_SCREEN_H
#pragma once

#include "Screen.h"
#include "ScreenManager.h"
Expand Down Expand Up @@ -124,5 +123,3 @@ class SimpleListModel : public ListScreen::Model
};

#endif // CONFIG_HAVE_DISPLAY

#endif // LIST_SCREEN_H
5 changes: 1 addition & 4 deletions examples/common/screen-framework/include/Screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
*
*/

#ifndef SCREEN_H
#define SCREEN_H
#pragma once

#include "Display.h"

Expand Down Expand Up @@ -66,5 +65,3 @@ class Screen
};

#endif // CONFIG_HAVE_DISPLAY

#endif // SCREEN_H
5 changes: 1 addition & 4 deletions examples/common/screen-framework/include/ScreenManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
*
*/

#ifndef SCREEN_MANAGER_H
#define SCREEN_MANAGER_H
#pragma once

#include "Display.h"
#include "Screen.h"
Expand Down Expand Up @@ -63,5 +62,3 @@ class ScreenManager
};

#endif // CONFIG_HAVE_DISPLAY

#endif // SCREEN_MANAGER_H
4 changes: 1 addition & 3 deletions examples/lighting-app/efr32/include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
* limitations under the License.
*/

#ifndef APP_CONFIG_H
#define APP_CONFIG_H
#pragma once

// ---- Lighting Example App Config ----

Expand Down Expand Up @@ -67,4 +66,3 @@ void appError(int err);
#ifdef __cplusplus
}
#endif
#endif // APP_CONFIG_H
Loading