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

Tizen WiFi and bluetooth fix #25186

Merged
merged 7 commits into from
Feb 21, 2023
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
1 change: 1 addition & 0 deletions examples/all-clusters-app/tizen/tizen-manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<privilege>http://tizen.org/privilege/internet</privilege>
<privilege>http://tizen.org/privilege/network.get</privilege>
<privilege>http://tizen.org/privilege/network.set</privilege>
<privilege>http://tizen.org/privilege/network.profile</privilege>
</privileges>
<feature name="http://tizen.org/feature/network.bluetooth">true</feature>
<feature name="http://tizen.org/feature/network.bluetooth.le">true</feature>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<privilege>http://tizen.org/privilege/internet</privilege>
<privilege>http://tizen.org/privilege/network.get</privilege>
<privilege>http://tizen.org/privilege/network.set</privilege>
<privilege>http://tizen.org/privilege/network.profile</privilege>
</privileges>
<feature name="http://tizen.org/feature/network.bluetooth">true</feature>
<feature name="http://tizen.org/feature/network.bluetooth.le">true</feature>
Expand Down
16 changes: 15 additions & 1 deletion examples/lighting-app/tizen/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/ConcreteAttributePath.h>
#include <app/clusters/network-commissioning/network-commissioning.h>
#include <platform/Tizen/NetworkCommissioningDriver.h>

#include <LightingManager.h>
#include <TizenServiceAppMain.h>
Expand All @@ -27,6 +29,13 @@ using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
namespace {
DeviceLayer::NetworkCommissioning::TizenWiFiDriver sTizenWiFiDriver;
Clusters::NetworkCommissioning::Instance sWiFiNetworkCommissioningInstance(0, &sTizenWiFiDriver);
} // namespace
#endif

void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size,
uint8_t * value)
{
Expand All @@ -36,7 +45,12 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
}
}

void ApplicationInit() {}
void ApplicationInit()
{
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
sWiFiNetworkCommissioningInstance.Init();
#endif
}

int main(int argc, char * argv[])
{
Expand Down
1 change: 1 addition & 0 deletions examples/lighting-app/tizen/tizen-manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<privilege>http://tizen.org/privilege/internet</privilege>
<privilege>http://tizen.org/privilege/network.get</privilege>
<privilege>http://tizen.org/privilege/network.set</privilege>
<privilege>http://tizen.org/privilege/network.profile</privilege>
</privileges>
<feature name="http://tizen.org/feature/network.bluetooth">true</feature>
<feature name="http://tizen.org/feature/network.bluetooth.le">true</feature>
Expand Down
4 changes: 4 additions & 0 deletions src/platform/Tizen/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,10 @@ int BLEManagerImpl::StartBLEAdvertising()
VerifyOrExit(ret == BT_ERROR_NONE,
ChipLogError(DeviceLayer, "bt_adapter_le_add_advertising_service_data() failed. ret: %d", ret));

ret = bt_adapter_le_set_advertising_device_name(mAdvertiser, BT_ADAPTER_LE_PACKET_ADVERTISING, true);
VerifyOrExit(ret == BT_ERROR_NONE,
ChipLogError(DeviceLayer, "bt_adapter_le_set_advertising_device_name() failed. ret: %d", ret));

BLEManagerImpl::NotifyBLEPeripheralAdvConfiguredComplete(true, nullptr);

ret = bt_adapter_le_start_advertising_new(mAdvertiser, AdvertisingStateChangedCb, nullptr);
Expand Down
7 changes: 6 additions & 1 deletion src/platform/Tizen/WiFiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <lib/support/CodeUtils.h>
#include <lib/support/Span.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/PlatformManager.h>

#include "MainLoop.h"

Expand Down Expand Up @@ -272,22 +273,26 @@ void WiFiManager::_ConnectedCb(wifi_manager_error_e wifiErr, void * userData)
{
auto loop = reinterpret_cast<GMainLoop *>(userData);

if (wifiErr == WIFI_MANAGER_ERROR_NONE)
if (wifiErr == WIFI_MANAGER_ERROR_NONE || wifiErr == WIFI_MANAGER_ERROR_ALREADY_EXISTS)
{
ChipLogProgress(DeviceLayer, "WiFi is connected");
if (sInstance.mpConnectCallback != nullptr)
{
chip::DeviceLayer::PlatformMgr().LockChipStack();
sInstance.mpConnectCallback->OnResult(NetworkCommissioning::Status::kSuccess, CharSpan(), 0);
sInstance.mpConnectCallback = nullptr;
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
}
}
else
{
ChipLogError(DeviceLayer, "FAIL: connect WiFi [%s]", get_error_message(wifiErr));
if (sInstance.mpConnectCallback != nullptr)
{
chip::DeviceLayer::PlatformMgr().LockChipStack();
sInstance.mpConnectCallback->OnResult(NetworkCommissioning::Status::kUnknownError, CharSpan(), 0);
sInstance.mpConnectCallback = nullptr;
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
}
}

Expand Down