Skip to content

Commit

Permalink
Merge branch 'master' into AA/libsupport1
Browse files Browse the repository at this point in the history
  • Loading branch information
Alami-Amine authored Apr 23, 2024
2 parents 0ff3bc4 + 9ff29ed commit 55c074b
Show file tree
Hide file tree
Showing 27 changed files with 706 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ class BluetoothManager : BleCallback {

private val coroutineContinuation = continuation

private val STATE_INIT = 1
private val STATE_DISCOVER_SERVICE = 2
private val STATE_REQUEST_MTU = 3

private var mState = STATE_INIT

override fun onConnectionStateChange(gatt: BluetoothGatt?, status: Int, newState: Int) {
super.onConnectionStateChange(gatt, status, newState)
Log.i(
Expand All @@ -148,21 +154,31 @@ class BluetoothManager : BleCallback {

if (newState == BluetoothProfile.STATE_CONNECTED && status == BluetoothGatt.GATT_SUCCESS) {
Log.i("$TAG|onConnectionStateChange", "Discovering Services...")
mState = STATE_DISCOVER_SERVICE
gatt?.discoverServices()
}
}

override fun onServicesDiscovered(gatt: BluetoothGatt?, status: Int) {
Log.d(TAG, "${gatt?.device?.name}.onServicesDiscovered status = $status")
if (mState != STATE_DISCOVER_SERVICE) {
Log.d(TAG, "Invalid state : $mState")
return
}
wrappedCallback.onServicesDiscovered(gatt, status)

Log.i("$TAG|onServicesDiscovered", "Services Discovered")
mState = STATE_REQUEST_MTU
gatt?.requestMtu(247)
}

override fun onMtuChanged(gatt: BluetoothGatt?, mtu: Int, status: Int) {
Log.d(TAG, "${gatt?.device?.name}.onMtuChanged: connecting to CHIP device")
super.onMtuChanged(gatt, mtu, status)
if (mState != STATE_REQUEST_MTU) {
Log.d(TAG, "Invalid state : $mState")
return
}
wrappedCallback.onMtuChanged(gatt, mtu, status)
if (coroutineContinuation.isActive) {
coroutineContinuation.resume(gatt)
Expand Down
3 changes: 2 additions & 1 deletion examples/lit-icd-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ void AppTask::ButtonEventHandler(uint32_t buttonState, uint32_t hasChanged)

void AppTask::IcdUatEventHandler(const AppEvent &)
{
Server::GetInstance().GetICDManager().UpdateOperationState(ICDManager::OperationalState::ActiveMode);
// Temporarily claim network activity, until we implement a "user trigger" reason for ICD wakeups.
PlatformMgr().ScheduleWork([](intptr_t) { ICDNotifier::GetInstance().NotifyNetworkActivityNotification(); });
}

void AppTask::FunctionTimerTimeoutCallback(k_timer * timer)
Expand Down
4 changes: 1 addition & 3 deletions examples/platform/silabs/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,7 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
SILABS_LOG("Network is already provisioned, Ble advertisement not enabled");
#if CHIP_CONFIG_ENABLE_ICD_SERVER
// Temporarily claim network activity, until we implement a "user trigger" reason for ICD wakeups.
PlatformMgr().LockChipStack();
ICDNotifier::GetInstance().NotifyNetworkActivityNotification();
PlatformMgr().UnlockChipStack();
PlatformMgr().ScheduleWork([](intptr_t) { ICDNotifier::GetInstance().NotifyNetworkActivityNotification(); });
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ private String getCastingPlayerButtonText(CastingPlayer player) {
? (aux.isEmpty() ? "" : ", ") + "Device Type: " + player.getDeviceType()
: "";
aux += (aux.isEmpty() ? "" : ", ") + "Resolved IP?: " + (player.getIpAddresses().size() > 0);
aux +=
(aux.isEmpty() ? "" : ", ")
+ "Supports Commissioner Generated Passcode: "
+ (player.getSupportsCommissionerGeneratedPasscode());

aux = aux.isEmpty() ? aux : "\n" + aux;
return main + aux;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public interface CastingPlayer {

long getDeviceType();

boolean getSupportsCommissionerGeneratedPasscode();

List<Endpoint> getEndpoints();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class MatterCastingPlayer implements CastingPlayer {
private int productId;
private int vendorId;
private long deviceType;
private boolean supportsCommissionerGeneratedPasscode;

protected long _cppCastingPlayer;

public MatterCastingPlayer(
Expand All @@ -59,7 +61,8 @@ public MatterCastingPlayer(
int port,
int productId,
int vendorId,
long deviceType) {
long deviceType,
boolean supportsCommissionerGeneratedPasscode) {
this.connected = connected;
this.deviceId = deviceId;
this.hostName = hostName;
Expand All @@ -70,6 +73,7 @@ public MatterCastingPlayer(
this.productId = productId;
this.vendorId = vendorId;
this.deviceType = deviceType;
this.supportsCommissionerGeneratedPasscode = supportsCommissionerGeneratedPasscode;
}

/**
Expand Down Expand Up @@ -131,6 +135,11 @@ public long getDeviceType() {
return this.deviceType;
}

@Override
public boolean getSupportsCommissionerGeneratedPasscode() {
return this.supportsCommissionerGeneratedPasscode;
}

@Override
public native List<Endpoint> getEndpoints();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ jobject convertCastingPlayerFromCppToJava(matter::casting::memory::Strong<core::
// Get the constructor for the com/matter/casting/core/MatterCastingPlayer Java class
jmethodID constructor =
env->GetMethodID(matterCastingPlayerJavaClass, "<init>",
"(ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;IIIJ)V");
"(ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;IIIJZ)V");
if (constructor == nullptr)
{
ChipLogError(AppServer, "convertCastingPlayerFromCppToJava() could not locate MatterCastingPlayer Java class constructor");
Expand Down Expand Up @@ -186,7 +186,8 @@ jobject convertCastingPlayerFromCppToJava(matter::casting::memory::Strong<core::
env->NewStringUTF(player->GetId()), env->NewStringUTF(player->GetHostName()),
env->NewStringUTF(player->GetDeviceName()), env->NewStringUTF(player->GetInstanceName()),
jIpAddressList, (jint) (player->GetPort()), (jint) (player->GetProductId()),
(jint) (player->GetVendorId()), (jlong) (player->GetDeviceType()));
(jint) (player->GetVendorId()), (jlong) (player->GetDeviceType()),
static_cast<jboolean>(player->GetSupportsCommissionerGeneratedPasscode()));
if (jMatterCastingPlayer == nullptr)
{
ChipLogError(AppServer, "convertCastingPlayerFromCppToJava(): Could not create MatterCastingPlayer Java object");
Expand Down
3 changes: 2 additions & 1 deletion examples/tv-casting-app/linux/simple-app-helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ DiscoveryDelegateImpl * DiscoveryDelegateImpl::GetInstance()

void DiscoveryDelegateImpl::HandleOnAdded(matter::casting::memory::Strong<matter::casting::core::CastingPlayer> player)
{
ChipLogProgress(AppServer, "DiscoveryDelegateImpl::HandleOnAdded() called");
if (commissionersCount == 0)
{
ChipLogProgress(AppServer, "Select discovered Casting Player (start index = 0) to request commissioning");
Expand All @@ -58,7 +59,7 @@ void DiscoveryDelegateImpl::HandleOnAdded(matter::casting::memory::Strong<matter

void DiscoveryDelegateImpl::HandleOnUpdated(matter::casting::memory::Strong<matter::casting::core::CastingPlayer> player)
{
ChipLogProgress(AppServer, "Updated CastingPlayer with ID: %s", player->GetId());
ChipLogProgress(AppServer, "DiscoveryDelegateImpl::HandleOnUpdated() Updated CastingPlayer with ID: %s", player->GetId());
}

void InvokeContentLauncherLaunchURL(matter::casting::memory::Strong<matter::casting::core::Endpoint> endpoint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ bool CastingPlayer::ContainsDesiredEndpoint(core::CastingPlayer * cachedCastingP

void CastingPlayer::LogDetail() const
{
ChipLogProgress(AppServer, "CastingPlayer::LogDetail() called");
if (strlen(mAttributes.id) != 0)
{
ChipLogDetail(AppServer, "\tID: %s", mAttributes.id);
Expand Down Expand Up @@ -281,6 +282,8 @@ void CastingPlayer::LogDetail() const
{
ChipLogDetail(AppServer, "\tDevice Type: %" PRIu32, mAttributes.deviceType);
}
ChipLogDetail(AppServer, "\tSupports Commissioner Generated Passcode: %s",
mAttributes.supportsCommissionerGeneratedPasscode ? "true" : "false");
if (mAttributes.nodeId > 0)
{
ChipLogDetail(AppServer, "\tNode ID: 0x" ChipLogFormatX64, ChipLogValueX64(mAttributes.nodeId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ class CastingPlayerAttributes
char deviceName[chip::Dnssd::kMaxDeviceNameLen + 1] = {};
char hostName[chip::Dnssd::kHostNameMaxLength + 1] = {};
char instanceName[chip::Dnssd::Commission::kInstanceNameMaxLength + 1] = {};
unsigned int numIPs; // number of valid IP addresses
unsigned int numIPs; // Number of valid IP addresses
chip::Inet::IPAddress ipAddresses[chip::Dnssd::CommonResolutionData::kMaxIPAddresses];
chip::Inet::InterfaceId interfaceId;
uint16_t port;
uint16_t productId;
uint16_t vendorId;
uint32_t deviceType;
bool supportsCommissionerGeneratedPasscode;

chip::NodeId nodeId = 0;
chip::FabricIndex fabricIndex = 0;
Expand Down Expand Up @@ -182,6 +183,8 @@ class CastingPlayer : public std::enable_shared_from_this<CastingPlayer>

uint32_t GetDeviceType() const { return mAttributes.deviceType; }

bool GetSupportsCommissionerGeneratedPasscode() const { return mAttributes.supportsCommissionerGeneratedPasscode; }

chip::NodeId GetNodeId() const { return mAttributes.nodeId; }

chip::FabricIndex GetFabricIndex() const { return mAttributes.fabricIndex; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,12 @@ void DeviceDiscoveryDelegateImpl::OnDiscoveredDevice(const chip::Dnssd::Discover
{
attributes.ipAddresses[j] = nodeData.resolutionData.ipAddress[j];
}
attributes.interfaceId = nodeData.resolutionData.interfaceId;
attributes.port = nodeData.resolutionData.port;
attributes.productId = nodeData.nodeData.productId;
attributes.vendorId = nodeData.nodeData.vendorId;
attributes.deviceType = nodeData.nodeData.deviceType;
attributes.interfaceId = nodeData.resolutionData.interfaceId;
attributes.port = nodeData.resolutionData.port;
attributes.productId = nodeData.nodeData.productId;
attributes.vendorId = nodeData.nodeData.vendorId;
attributes.deviceType = nodeData.nodeData.deviceType;
attributes.supportsCommissionerGeneratedPasscode = nodeData.nodeData.supportsCommissionerGeneratedPasscode;

memory::Strong<CastingPlayer> player = std::make_shared<CastingPlayer>(attributes);

Expand Down
10 changes: 10 additions & 0 deletions examples/tv-casting-app/tv-casting-common/support/CastingStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ std::vector<core::CastingPlayer> CastingStore::ReadAll()
continue;
}

if (castingPlayerContainerTagNum == kCastingPlayerSupportsCommissionerGeneratedPasscodeTag)
{
err = reader.Get(attributes.supportsCommissionerGeneratedPasscode);
VerifyOrReturnValue(err == CHIP_NO_ERROR, std::vector<core::CastingPlayer>(),
ChipLogError(AppServer, "TLVReader.Get failed %" CHIP_ERROR_FORMAT, err.Format()));
continue;
}

if (castingPlayerContainerTagNum == kCastingPlayerPortTag)
{
err = reader.Get(attributes.port);
Expand Down Expand Up @@ -472,6 +480,8 @@ CHIP_ERROR CastingStore::WriteAll(std::vector<core::CastingPlayer> castingPlayer
ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerVendorIdTag), castingPlayer.GetVendorId()));
ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerProductIdTag), castingPlayer.GetProductId()));
ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerDeviceTypeIdTag), castingPlayer.GetDeviceType()));
ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerSupportsCommissionerGeneratedPasscodeTag),
castingPlayer.GetSupportsCommissionerGeneratedPasscode()));
ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerPortTag), castingPlayer.GetPort()));
ReturnErrorOnFailure(tlvWriter.PutBytes(chip::TLV::ContextTag(kCastingPlayerInstanceNameTag),
(const uint8_t *) castingPlayer.GetInstanceName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class CastingStore : public chip::FabricTable::Delegate
kCastingPlayerEndpointServerListContainerTag,
kCastingPlayerEndpointServerClusterIdTag,

kCastingPlayerSupportsCommissionerGeneratedPasscodeTag,

kContextTagMaxNum = UINT8_MAX
};

Expand Down
51 changes: 37 additions & 14 deletions scripts/checkout_submodules.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
'silabs_docker',
])

Module = namedtuple('Module', 'name path platforms')
Module = namedtuple('Module', 'name path platforms recursive')


def load_module_info() -> None:
Expand All @@ -63,9 +63,11 @@ def load_module_info() -> None:
if name != 'DEFAULT':
platforms = module.get('platforms', '').split(',')
platforms = set(filter(None, platforms))
assert not (platforms - ALL_PLATFORMS), "Submodule's platform not contained in ALL_PLATFORMS"
assert not (
platforms - ALL_PLATFORMS), "Submodule's platform not contained in ALL_PLATFORMS"
recursive = module.getboolean('recursive', False)
name = name.replace('submodule "', '').replace('"', '')
yield Module(name=name, path=module['path'], platforms=platforms)
yield Module(name=name, path=module['path'], platforms=platforms, recursive=recursive)


def module_matches_platforms(module: Module, platforms: set) -> bool:
Expand All @@ -88,8 +90,10 @@ def make_chip_root_safe_directory() -> None:
config.check_returncode()
existing = config.stdout.split('\0')
if CHIP_ROOT not in existing:
logging.info("Adding CHIP_ROOT to global git safe.directory configuration")
subprocess.check_call(['git', 'config', '--global', '--add', 'safe.directory', CHIP_ROOT])
logging.info(
"Adding CHIP_ROOT to global git safe.directory configuration")
subprocess.check_call(
['git', 'config', '--global', '--add', 'safe.directory', CHIP_ROOT])


def checkout_modules(modules: list, shallow: bool, force: bool, recursive: bool, jobs: int) -> None:
Expand All @@ -101,9 +105,21 @@ def checkout_modules(modules: list, shallow: bool, force: bool, recursive: bool,
cmd += ['--force'] if force else []
cmd += ['--recursive'] if recursive else []
cmd += ['--jobs', f'{jobs}'] if jobs else []
cmd += [module.path for module in modules]
module_paths = [module.path for module in modules]

subprocess.check_call(cmd)
subprocess.check_call(cmd + module_paths)

if recursive:
# We've recursively checkouted all submodules.
pass
else:
# We've checkouted all top-level submodules.
# We're going to recursively checkout submodules whose recursive configuration is true.
cmd += ['--recursive']
module_paths = [module.path for module in modules if module.recursive]

if module_paths:
subprocess.check_call(cmd + module_paths)


def deinit_modules(modules: list, force: bool) -> None:
Expand All @@ -120,28 +136,35 @@ def deinit_modules(modules: list, force: bool) -> None:
def main():
logging.basicConfig(format='%(message)s', level=logging.INFO)

parser = argparse.ArgumentParser(description='Checkout or update relevant git submodules')
parser = argparse.ArgumentParser(
description='Checkout or update relevant git submodules')
parser.add_argument('--allow-changing-global-git-config', action='store_true',
help='Allow global git options to be modified if necessary, e.g. safe.directory')
parser.add_argument('--shallow', action='store_true', help='Fetch submodules without history')
parser.add_argument('--shallow', action='store_true',
help='Fetch submodules without history')
parser.add_argument('--platform', nargs='+', choices=ALL_PLATFORMS, default=[],
help='Process submodules for specific platforms only')
parser.add_argument('--force', action='store_true', help='Perform action despite of warnings')
parser.add_argument('--force', action='store_true',
help='Perform action despite of warnings')
parser.add_argument('--deinit-unmatched', action='store_true',
help='Deinitialize submodules for non-matching platforms')
parser.add_argument('--recursive', action='store_true', help='Recursive init of the listed submodules')
parser.add_argument('--jobs', type=int, metavar='N', help='Clone new submodules in parallel with N jobs')
parser.add_argument('--recursive', action='store_true',
help='Recursive init of the listed submodules')
parser.add_argument('--jobs', type=int, metavar='N',
help='Clone new submodules in parallel with N jobs')
args = parser.parse_args()

modules = list(load_module_info())
selected_platforms = set(args.platform)
selected_modules = [m for m in modules if module_matches_platforms(m, selected_platforms)]
selected_modules = [
m for m in modules if module_matches_platforms(m, selected_platforms)]
unmatched_modules = [m for m in modules if not module_matches_platforms(
m, selected_platforms) and module_initialized(m)]

if args.allow_changing_global_git_config:
make_chip_root_safe_directory() # ignore directory ownership issues for sub-modules
checkout_modules(selected_modules, args.shallow, args.force, args.recursive, args.jobs)
checkout_modules(selected_modules, args.shallow,
args.force, args.recursive, args.jobs)

if args.deinit_unmatched and unmatched_modules:
deinit_modules(unmatched_modules, args.force)
Expand Down
2 changes: 1 addition & 1 deletion scripts/py_matter_idl/matter_idl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ directory of this README). Most of the heavy lifting is done by the lark using
content
- [matter_idl_parser.py](./matter_idl_parser.py) has a transformer that
converts the text given by lark into a more type-safe (and type-rich) AST as
defined ing [matter_idl_types.py](./matter_idl_types.py)
defined in [matter_idl_types.py](./matter_idl_types.py)

## Code generation

Expand Down
Loading

0 comments on commit 55c074b

Please sign in to comment.