Skip to content

Commit

Permalink
[style] Run 'make pretty' to reapply style guide on codebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
turon committed Mar 19, 2020
1 parent 3ea669f commit d3956f9
Show file tree
Hide file tree
Showing 43 changed files with 668 additions and 719 deletions.
4 changes: 2 additions & 2 deletions src/ble/BLEEndPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ class DLL_EXPORT BLEEndPoint : public BleLayerObject
inline void QueueTxLock() { mTxQueueMutex.Lock(); };
inline void QueueTxUnlock() { mTxQueueMutex.Unlock(); };
#else
inline void QueueTxLock() { };
inline void QueueTxUnlock() { };
inline void QueueTxLock(){};
inline void QueueTxUnlock(){};
#endif
void QueueTx(PacketBuffer * data, PacketType_t type);
};
Expand Down
1 change: 0 additions & 1 deletion src/ble/BleError.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,5 +425,4 @@ extern bool FormatBleLayerError(char * buf, uint16_t bufSize, int32_t err);
} /* namespace Ble */
} /* namespace chip */


#endif /* BLEERROR_H_ */
7 changes: 3 additions & 4 deletions src/ble/BleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ using ::chip::System::PacketBuffer;
* versions encapsulated in a BleTransportCapabilitiesRequest. Defined by chip
* over BLE protocol specification.
*/
#define NUM_SUPPORTED_PROTOCOL_VERSIONS 8
#define NUM_SUPPORTED_PROTOCOL_VERSIONS 8
/// Version(s) of the CHIP BLE Transport Protocol that this stack supports.
#define CHIP_BLE_TRANSPORT_PROTOCOL_MIN_SUPPORTED_VERSION kBleTransportProtocolVersion_V2
#define CHIP_BLE_TRANSPORT_PROTOCOL_MAX_SUPPORTED_VERSION kBleTransportProtocolVersion_V3
Expand Down Expand Up @@ -250,8 +250,7 @@ class DLL_EXPORT BleLayer
// Public functions:
BleLayer(void);

BLE_ERROR Init(BlePlatformDelegate * platformDelegate, BleApplicationDelegate * appDelegate,
chip::System::Layer * systemLayer);
BLE_ERROR Init(BlePlatformDelegate * platformDelegate, BleApplicationDelegate * appDelegate, chip::System::Layer * systemLayer);

#if BLE_CONFIG_PROVIDE_OBSOLESCENT_INTERFACES
BLE_ERROR Init(BlePlatformDelegate * platformDelegate, BleApplicationDelegate * appDelegate, Inet::InetLayer * inetLayer);
Expand All @@ -261,7 +260,7 @@ class DLL_EXPORT BleLayer

BLE_ERROR NewBleEndPoint(BLEEndPoint ** retEndPoint, BLE_CONNECTION_OBJECT connObj, BleRole role, bool autoClose);

chip::System::Error ScheduleWork(chip::System::Layer::TimerCompleteFunct aComplete, void* aAppState)
chip::System::Error ScheduleWork(chip::System::Layer::TimerCompleteFunct aComplete, void * aAppState)
{
return mSystemLayer->ScheduleWork(aComplete, aAppState);
}
Expand Down
7 changes: 3 additions & 4 deletions src/ble/BlePlatformDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ class DLL_EXPORT BlePlatformDelegate
// Following APIs must be implemented by platform:

// Subscribe to updates and indications on the specfied characteristic
virtual bool SubscribeCharacteristic(BLE_CONNECTION_OBJECT connObj, const chipBleUUID * svcId,
const chipBleUUID * charId) = 0;
virtual bool SubscribeCharacteristic(BLE_CONNECTION_OBJECT connObj, const chipBleUUID * svcId, const chipBleUUID * charId) = 0;

// Unsubscribe from updates and indications on the specified characteristic
virtual bool UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT connObj, const chipBleUUID * svcId,
Expand Down Expand Up @@ -87,8 +86,8 @@ class DLL_EXPORT BlePlatformDelegate
PacketBuffer * pBuf) = 0;

// Send response to remote host's GATT chacteristic read response
virtual bool SendReadResponse(BLE_CONNECTION_OBJECT connObj, BLE_READ_REQUEST_CONTEXT requestContext,
const chipBleUUID * svcId, const chipBleUUID * charId) = 0;
virtual bool SendReadResponse(BLE_CONNECTION_OBJECT connObj, BLE_READ_REQUEST_CONTEXT requestContext, const chipBleUUID * svcId,
const chipBleUUID * charId) = 0;
};

} /* namespace Ble */
Expand Down
42 changes: 12 additions & 30 deletions src/ble/CHIPBleServiceData.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ namespace Ble {
*/
enum chipBLEServiceDataType
{
kchipBLEServiceDataType_DeviceIdentificationInfo = 0x01,
kchipBLEServiceDataType_TokenIdentificationInfo = 0x02,
kchipBLEServiceDataType_DeviceIdentificationInfo = 0x01,
kchipBLEServiceDataType_TokenIdentificationInfo = 0x02,
};

/**
Expand All @@ -45,8 +45,8 @@ struct chipBLEDeviceIdentificationInfo
{
enum
{
kMajorVersion = 0,
kMinorVersion = 1,
kMajorVersion = 0,
kMinorVersion = 1,
};

enum
Expand All @@ -67,41 +67,23 @@ struct chipBLEDeviceIdentificationInfo
void Init()
{
memset(this, 0, sizeof(*this));
BlockLen = sizeof(*this) - sizeof(BlockLen); // size of all fields EXCEPT BlockLen
BlockType = kchipBLEServiceDataType_DeviceIdentificationInfo;
BlockLen = sizeof(*this) - sizeof(BlockLen); // size of all fields EXCEPT BlockLen
BlockType = kchipBLEServiceDataType_DeviceIdentificationInfo;
MajorVersion = kMajorVersion;
MinorVersion = kMinorVersion;
}

uint16_t GetVendorId(void)
{
return chip::Encoding::LittleEndian::Get16(DeviceVendorId);
}
uint16_t GetVendorId(void) { return chip::Encoding::LittleEndian::Get16(DeviceVendorId); }

void SetVendorId(uint16_t vendorId)
{
chip::Encoding::LittleEndian::Put16(DeviceVendorId, vendorId);
}
void SetVendorId(uint16_t vendorId) { chip::Encoding::LittleEndian::Put16(DeviceVendorId, vendorId); }

uint16_t GetProductId(void)
{
return chip::Encoding::LittleEndian::Get16(DeviceProductId);
}
uint16_t GetProductId(void) { return chip::Encoding::LittleEndian::Get16(DeviceProductId); }

void SetProductId(uint16_t productId)
{
chip::Encoding::LittleEndian::Put16(DeviceProductId, productId);
}
void SetProductId(uint16_t productId) { chip::Encoding::LittleEndian::Put16(DeviceProductId, productId); }

uint64_t GetDeviceId(void)
{
return chip::Encoding::LittleEndian::Get64(DeviceId);
}
uint64_t GetDeviceId(void) { return chip::Encoding::LittleEndian::Get64(DeviceId); }

void SetDeviceId(uint64_t deviceId)
{
chip::Encoding::LittleEndian::Put64(DeviceId, deviceId);
}
void SetDeviceId(uint64_t deviceId) { chip::Encoding::LittleEndian::Put64(DeviceId, deviceId); }
} __attribute__((packed));

} /* namespace Ble */
Expand Down
4 changes: 2 additions & 2 deletions src/ble/CHIPoBle.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ class CHIPoBle

public:
// Public functions:
CHIPoBle(void) { };
~CHIPoBle(void) { };
CHIPoBle(void){};
~CHIPoBle(void){};

BLE_ERROR Init(void * an_app_state, bool expect_first_ack);

Expand Down
42 changes: 22 additions & 20 deletions src/inet/AsyncDNSResolverSockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,40 +53,42 @@ class AsyncDNSResolverSockets
{
friend class InetLayer;
friend class DNSResolver;
public:

INET_ERROR EnqueueRequest(DNSResolver &resolver);
public:
INET_ERROR EnqueueRequest(DNSResolver & resolver);

INET_ERROR Init(InetLayer *inet);
INET_ERROR Init(InetLayer * inet);

INET_ERROR Cancel(DNSResolver &resolver);
INET_ERROR Cancel(DNSResolver & resolver);

INET_ERROR Shutdown(void);

INET_ERROR PrepareDNSResolver(DNSResolver &resolver, const char *hostName, uint16_t hostNameLen,
uint8_t options, uint8_t maxAddrs, IPAddress *addrArray,
DNSResolver::OnResolveCompleteFunct onComplete, void *appState);
INET_ERROR PrepareDNSResolver(DNSResolver & resolver, const char * hostName, uint16_t hostNameLen, uint8_t options,
uint8_t maxAddrs, IPAddress * addrArray, DNSResolver::OnResolveCompleteFunct onComplete,
void * appState);

private:
pthread_t mAsyncDNSThreadHandle[INET_CONFIG_DNS_ASYNC_MAX_THREAD_COUNT];
pthread_mutex_t mAsyncDNSMutex; /* Mutex for accessing the DNSResolver queue. */
pthread_cond_t mAsyncDNSCondVar; /* Condition Variable for thread synchronization. */
volatile DNSResolver *mAsyncDNSQueueHead; /* The head of the asynchronous DNSResolver object queue. */
volatile DNSResolver *mAsyncDNSQueueTail; /* The tail of the asynchronous DNSResolver object queue. */
InetLayer *mInet; /* The pointer to the InetLayer. */
static void DNSResultEventHandler(chip::System::Layer* aLayer, void* aAppState, chip::System::Error aError); /* Timer event handler function for asynchronous DNS notification */

INET_ERROR DequeueRequest(DNSResolver **outResolver);
pthread_t mAsyncDNSThreadHandle[INET_CONFIG_DNS_ASYNC_MAX_THREAD_COUNT];
pthread_mutex_t mAsyncDNSMutex; /* Mutex for accessing the DNSResolver queue. */
pthread_cond_t mAsyncDNSCondVar; /* Condition Variable for thread synchronization. */
volatile DNSResolver * mAsyncDNSQueueHead; /* The head of the asynchronous DNSResolver object queue. */
volatile DNSResolver * mAsyncDNSQueueTail; /* The tail of the asynchronous DNSResolver object queue. */
InetLayer * mInet; /* The pointer to the InetLayer. */
static void
DNSResultEventHandler(chip::System::Layer * aLayer, void * aAppState,
chip::System::Error aError); /* Timer event handler function for asynchronous DNS notification */

INET_ERROR DequeueRequest(DNSResolver ** outResolver);

bool ShouldThreadShutdown(void);

void Resolve(DNSResolver &resolver);
void Resolve(DNSResolver & resolver);

void UpdateDNSResult(DNSResolver &resolver, struct addrinfo *lookupRes);
void UpdateDNSResult(DNSResolver & resolver, struct addrinfo * lookupRes);

static void *AsyncDNSThreadRun(void *args);
static void * AsyncDNSThreadRun(void * args);

static void NotifyChipThread(DNSResolver *resolver);
static void NotifyChipThread(DNSResolver * resolver);

void AsyncMutexLock(void);

Expand Down
51 changes: 24 additions & 27 deletions src/inet/DNSResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <InetError.h>
#include "InetLayerBasis.h"

#define NL_DNS_HOSTNAME_MAX_LEN (253)
#define NL_DNS_HOSTNAME_MAX_LEN (253)

struct addrinfo;

Expand All @@ -43,25 +43,24 @@ class InetLayer;
*/
enum DNSOptions
{
kDNSOption_AddrFamily_Mask = 0x07, ///< Bits within a DNSOptions integer value representing the desired address family.
kDNSOption_Flags_Mask = 0xF8, ///< Bits within a DNSOptions integer value reserved for flags.
kDNSOption_AddrFamily_Mask = 0x07, ///< Bits within a DNSOptions integer value representing the desired address family.
kDNSOption_Flags_Mask = 0xF8, ///< Bits within a DNSOptions integer value reserved for flags.

// Address Family Choices
kDNSOption_AddrFamily_Any = 0x00, ///< Return IPv4 and/or IPv6 addresses in the order returned by the nameserver.
kDNSOption_AddrFamily_Any = 0x00, ///< Return IPv4 and/or IPv6 addresses in the order returned by the nameserver.
#if INET_CONFIG_ENABLE_IPV4
kDNSOption_AddrFamily_IPv4Only = 0x01, ///< Return only IPv4 addresses.
kDNSOption_AddrFamily_IPv4Preferred = 0x02, ///< Return IPv4 and/or IPv6 addresses, with IPv4 addresses listed first.
kDNSOption_AddrFamily_IPv4Only = 0x01, ///< Return only IPv4 addresses.
kDNSOption_AddrFamily_IPv4Preferred = 0x02, ///< Return IPv4 and/or IPv6 addresses, with IPv4 addresses listed first.
#endif
kDNSOption_AddrFamily_IPv6Only = 0x03, ///< Return only IPv6 addresses.
kDNSOption_AddrFamily_IPv6Preferred = 0x04, ///< Return IPv4 and/or IPv6 addresses, with IPv6 addresses listed first.
kDNSOption_AddrFamily_IPv6Only = 0x03, ///< Return only IPv6 addresses.
kDNSOption_AddrFamily_IPv6Preferred = 0x04, ///< Return IPv4 and/or IPv6 addresses, with IPv6 addresses listed first.

// NOTE: At present there are no DNSOption flags define.
kDNSOption_ValidFlags = 0, ///< Set of all valid DNSOption flags.
kDNSOption_ValidFlags = 0, ///< Set of all valid DNSOption flags.

kDNSOption_Default = kDNSOption_AddrFamily_Any
kDNSOption_Default = kDNSOption_AddrFamily_Any
};


/**
* @class DNSResolver
*
Expand All @@ -71,7 +70,7 @@ enum DNSOptions
* interface available for the application layer.
*
*/
class DNSResolver: public InetLayerBasis
class DNSResolver : public InetLayerBasis
{
private:
friend class InetLayer;
Expand All @@ -81,12 +80,11 @@ class DNSResolver: public InetLayerBasis
friend class AsyncDNSResolverSockets;

/// States of the DNSResolver object with respect to hostname resolution.
typedef enum DNSResolverState
{
kState_Unused = 0, ///<Used to indicate that the DNSResolver object is not used.
kState_Active = 2, ///<Used to indicate that a DNS resolution is being performed on the DNSResolver object.
kState_Complete = 3, ///<Used to indicate that the DNS resolution on the DNSResolver object is complete.
kState_Canceled = 4, ///<Used to indicate that the DNS resolution on the DNSResolver has been canceled.
typedef enum DNSResolverState{
kState_Unused = 0, ///< Used to indicate that the DNSResolver object is not used.
kState_Active = 2, ///< Used to indicate that a DNS resolution is being performed on the DNSResolver object.
kState_Complete = 3, ///< Used to indicate that the DNS resolution on the DNSResolver object is complete.
kState_Canceled = 4, ///< Used to indicate that the DNS resolution on the DNSResolver has been canceled.
} DNSResolverState;
#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS
#endif // INET_CONFIG_ENABLE_ASYNC_DNS_SOCKETS
Expand All @@ -103,7 +101,7 @@ class DNSResolver: public InetLayerBasis
* Provide a function of this type to the \c Resolve method to process
* completion events.
*/
typedef void (*OnResolveCompleteFunct)(void *appState, INET_ERROR err, uint8_t addrCount, IPAddress *addrArray);
typedef void (*OnResolveCompleteFunct)(void * appState, INET_ERROR err, uint8_t addrCount, IPAddress * addrArray);

static chip::System::ObjectPool<DNSResolver, INET_CONFIG_NUM_DNS_RESOLVERS> sPool;

Expand All @@ -115,7 +113,7 @@ class DNSResolver: public InetLayerBasis
/**
* A pointer to the DNS table that stores a list of resolved addresses.
*/
IPAddress *AddrArray;
IPAddress * AddrArray;

/**
* The maximum number of addresses that could be stored in the DNS table.
Expand Down Expand Up @@ -146,7 +144,7 @@ class DNSResolver: public InetLayerBasis

INET_ERROR asyncDNSResolveResult;
/* The next DNSResolver object in the asynchronous DNS resolution queue. */
DNSResolver *pNextAsyncDNSResolver;
DNSResolver * pNextAsyncDNSResolver;

DNSResolverState mState;

Expand All @@ -156,17 +154,16 @@ class DNSResolver: public InetLayerBasis

#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS

INET_ERROR Resolve(const char *hostName, uint16_t hostNameLen, uint8_t options,
uint8_t maxAddrs, IPAddress *addrArray,
OnResolveCompleteFunct onComplete, void *appState);
INET_ERROR Resolve(const char * hostName, uint16_t hostNameLen, uint8_t options, uint8_t maxAddrs, IPAddress * addrArray,
OnResolveCompleteFunct onComplete, void * appState);
INET_ERROR Cancel(void);

#if CHIP_SYSTEM_CONFIG_USE_LWIP
void HandleResolveComplete(void);
#if LWIP_VERSION_MAJOR > 1
static void LwIPHandleResolveComplete(const char *name, const ip_addr_t *ipaddr, void *callback_arg);
#else // LWIP_VERSION_MAJOR <= 1
static void LwIPHandleResolveComplete(const char *name, ip_addr_t *ipaddr, void *callback_arg);
static void LwIPHandleResolveComplete(const char * name, const ip_addr_t * ipaddr, void * callback_arg);
#else // LWIP_VERSION_MAJOR <= 1
static void LwIPHandleResolveComplete(const char * name, ip_addr_t * ipaddr, void * callback_arg);
#endif // LWIP_VERSION_MAJOR <= 1
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
};
Expand Down
Loading

0 comments on commit d3956f9

Please sign in to comment.