-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* basic code generation template, but not able to import to tool app * create new public class under chip/clusterinfo * change package * no error code generation * new design solution * need to wait for cast-helper * callback generation done * on/off commands working * revert .idea changes * one more .idea change revert * remove outline.java * Restyled by whitespace * Restyled by google-java-format * Restyled by gn * Restyled by google-java-format * fix merge * merge conflict * fix comments * Restyled by gn * resolve type, nullable and format comments * resolve build issues * Restyled by gn * update zap generated file * add descriptive documentation on each new class * Restyled by google-java-format * modify description of each new added class * Restyled by google-java-format * add . at the end of class description * Restyled by google-java-format * rebase and regenerate script file * merge with mbedos problem fixed * rebase and try checks * rebase master to see if pass checks * retry checks Co-authored-by: Restyled.io <commits@restyled.io>
- Loading branch information
Showing
12 changed files
with
7,457 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 14 additions & 4 deletions
18
src/android/CHIPTool/app/src/main/res/layout/cluster_interaction_fragment.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/controller/java/src/chip/clusterinfo/ClusterCommandCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package chip.clusterinfo; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Interface for making customized callback that implements both onSuccess and onFailure functions. | ||
*/ | ||
public interface ClusterCommandCallback { | ||
void onSuccess(List<Object> responseValues); | ||
|
||
void onFailure(Exception exception); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package chip.clusterinfo; | ||
|
||
import chip.devicecontroller.ChipClusters.BaseChipCluster; | ||
import java.util.Map; | ||
|
||
/** ClusterInfo maps commands and provides a constructor function for a cluster. */ | ||
public class ClusterInfo { | ||
private final ClusterConstructor createClusterFunction; | ||
private final Map<String, CommandInfo> commands; | ||
|
||
public ClusterInfo(ClusterConstructor createClusterFunction, Map<String, CommandInfo> commands) { | ||
this.createClusterFunction = createClusterFunction; | ||
this.commands = commands; | ||
} | ||
|
||
public ClusterConstructor getCreateClusterFunction() { | ||
return createClusterFunction; | ||
} | ||
|
||
public Map<String, CommandInfo> getCommands() { | ||
return commands; | ||
} | ||
|
||
/** | ||
* The functional interface provides a uniform way to create cluster through create function. In | ||
* ClusterInfoMapping, each ClusterConstructor was generated using the intended function. Using | ||
* lambda function, it only needs to have ptr and endpointId to create the intended cluster. | ||
*/ | ||
@FunctionalInterface | ||
public interface ClusterConstructor { | ||
BaseChipCluster create(Long devicePtr, int endpointId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package chip.clusterinfo; | ||
|
||
import chip.devicecontroller.ChipClusters.BaseChipCluster; | ||
import java.util.Map; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* CommandInfo has a functional interface to invoke arbitrary commands based on cluster, callback | ||
* and a map of arguments, a Supplier that provides {@link DelegatedClusterCallback}, and maps the | ||
* parameter and commandParametersInfo. | ||
*/ | ||
public class CommandInfo { | ||
public ClusterCommandFunction commandFunction; | ||
private Supplier<DelegatedClusterCallback> commandCallbackSupplier; | ||
private Map<String, CommandParameterInfo> commandParameters; | ||
|
||
public CommandInfo( | ||
ClusterCommandFunction commandFunction, | ||
Supplier<DelegatedClusterCallback> commandCallbackSupplier, | ||
Map<String, CommandParameterInfo> commandParameters) { | ||
this.commandFunction = commandFunction; | ||
this.commandCallbackSupplier = commandCallbackSupplier; | ||
this.commandParameters = commandParameters; | ||
} | ||
|
||
public ClusterCommandFunction getCommandFunction() { | ||
return commandFunction; | ||
} | ||
|
||
public Supplier<DelegatedClusterCallback> getCommandCallbackSupplier() { | ||
return commandCallbackSupplier; | ||
} | ||
|
||
public Map<String, CommandParameterInfo> getCommandParameters() { | ||
return commandParameters; | ||
} | ||
|
||
/** | ||
* The functional interface provides a uniform way to invoke commands through invokeCommand | ||
* function. In ClusterInfoMapping, each ClusterCommandFunction was generated using the intended | ||
* function. By using lambda function, the app component only needs to have cluster, callback, | ||
* commandArguments to execute the correct function. | ||
*/ | ||
@FunctionalInterface | ||
public interface ClusterCommandFunction { | ||
void invokeCommand( | ||
BaseChipCluster cluster, Object callback, Map<String, Object> commandArguments); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/controller/java/src/chip/clusterinfo/CommandParameterInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package chip.clusterinfo; | ||
|
||
/** CommandParameterInfo captures the name and type of a parameter */ | ||
public class CommandParameterInfo { | ||
public CommandParameterInfo() {} | ||
|
||
public CommandParameterInfo(String name, Class<?> type) { | ||
this.name = name; | ||
this.type = type; | ||
} | ||
|
||
public String name; | ||
public Class<?> type; | ||
} |
6 changes: 6 additions & 0 deletions
6
src/controller/java/src/chip/clusterinfo/DelegatedClusterCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package chip.clusterinfo; | ||
|
||
/** Interface for a callback that delegates to {@link ClusterCommandCallback}. */ | ||
public interface DelegatedClusterCallback { | ||
void setCallbackDelegate(ClusterCommandCallback callback); | ||
} |
Oops, something went wrong.