Skip to content

Commit

Permalink
Merge branch 'master' into admin_commissioning_to_spec
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Oct 25, 2023
2 parents b5b157e + c4148b0 commit 1221fc0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 23 deletions.
15 changes: 6 additions & 9 deletions src/platform/Linux/bluez/BluezEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
#include <system/SystemPacketBuffer.h>

#include "BluezConnection.h"
#include "Types.h"

namespace chip {
namespace DeviceLayer {
Expand Down Expand Up @@ -691,18 +692,14 @@ static void BluezSignalOnObjectAdded(GDBusObjectManager * aManager, GDBusObject
{
// TODO: right now we do not handle addition/removal of adapters
// Primary focus here is to handle addition of a device
BluezDevice1 * device = bluez_object_get_device1(BLUEZ_OBJECT(aObject));
if (device == nullptr)
{
return;
}
GAutoPtr<BluezDevice1> device(bluez_object_get_device1(BLUEZ_OBJECT(aObject)));

if (BluezIsDeviceOnAdapter(device, endpoint->mpAdapter) == TRUE)
VerifyOrReturn(device.get() != nullptr);

if (BluezIsDeviceOnAdapter(device.get(), endpoint->mpAdapter) == TRUE)
{
BluezHandleNewDevice(device, endpoint);
BluezHandleNewDevice(device.get(), endpoint);
}

g_object_unref(device);
}

static void BluezSignalOnObjectRemoved(GDBusObjectManager * aManager, GDBusObject * aObject, gpointer apClosure)
Expand Down
23 changes: 9 additions & 14 deletions src/platform/Linux/bluez/ChipDeviceScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,24 +223,20 @@ CHIP_ERROR ChipDeviceScanner::MainLoopStopScan(ChipDeviceScanner * self)

void ChipDeviceScanner::SignalObjectAdded(GDBusObjectManager * manager, GDBusObject * object, ChipDeviceScanner * self)
{
BluezDevice1 * device = bluez_object_get_device1(BLUEZ_OBJECT(object));
VerifyOrReturn(device != nullptr);
GAutoPtr<BluezDevice1> device(bluez_object_get_device1(BLUEZ_OBJECT(object)));
VerifyOrReturn(device.get() != nullptr);

self->ReportDevice(*device);

g_object_unref(device);
self->ReportDevice(*device.get());
}

void ChipDeviceScanner::SignalInterfaceChanged(GDBusObjectManagerClient * manager, GDBusObjectProxy * object,
GDBusProxy * aInterface, GVariant * aChangedProperties,
const gchar * const * aInvalidatedProps, ChipDeviceScanner * self)
{
BluezDevice1 * device = bluez_object_get_device1(BLUEZ_OBJECT(object));
VerifyOrReturn(device != nullptr);

self->ReportDevice(*device);
GAutoPtr<BluezDevice1> device(bluez_object_get_device1(BLUEZ_OBJECT(object)));
VerifyOrReturn(device.get() != nullptr);

g_object_unref(device);
self->ReportDevice(*device.get());
}

void ChipDeviceScanner::ReportDevice(BluezDevice1 & device)
Expand Down Expand Up @@ -295,11 +291,10 @@ CHIP_ERROR ChipDeviceScanner::MainLoopStartScan(ChipDeviceScanner * self)
ChipLogProgress(Ble, "BLE removing known devices.");
for (BluezObject & object : BluezObjectList(self->mManager))
{
BluezDevice1 * device = bluez_object_get_device1(&object);
if (device != nullptr)
GAutoPtr<BluezDevice1> device(bluez_object_get_device1(&object));
if (device.get() != nullptr)
{
self->RemoveDevice(*device);
g_object_unref(device);
self->RemoveDevice(*device.get());
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/platform/Linux/bluez/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,20 @@
#pragma once

#include <platform/CHIPDeviceConfig.h>
#include <platform/GLibTypeDeleter.h>

#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE

#include <platform/Linux/dbus/bluez/DbusBluez.h>

namespace chip {

template <>
struct GAutoPtrDeleter<BluezDevice1>
{
using deleter = GObjectDeleter;
};

namespace DeviceLayer {
namespace Internal {

Expand Down
17 changes: 17 additions & 0 deletions src/platform/bouffalolab/common/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,20 @@ extern "C" void otPlatLog(int aLogLevel, int aLogRegion, const char * aFormat, .
va_end(v);
}
#endif

#if CHIP_SYSTEM_CONFIG_USE_LWIP
/**
* LwIP log output function.
*/
extern "C" void LwIPLog(const char * msg, ...)
{
va_list v;
uint8_t category = chip::Logging::kLogCategory_Error;

va_start(v, msg);

chip::Logging::Platform::LogV("LWIP", category, msg, v);

va_end(v);
}
#endif // #if CHIP_SYSTEM_CONFIG_USE_LWIP

0 comments on commit 1221fc0

Please sign in to comment.