public final class CommissioningRequest
- Object
- CommissioningRequest
What to add, and where the user would like it to land.
Every field is optional. An empty request is valid and means “open the platform’s add-accessory UI and let the user do everything there”, which is the right call for a plain “add a device” button.
CommissioningRequest req = new CommissioningRequest()
.setSetupPayload(SetupPayload.parse(scanned))
.setStructure(home)
.setRoom(kitchen)
.setSuggestedName("Kettle");
Preferences, not instructions
The structure, room and name are passed to an operating-system flow that owns the interaction, and the user can overrule any of them. Do not assume the accessory ended up where you asked; re-read the graph afterwards.
Constructors
public CommissioningRequest() |
Methods
Inherited methods
Constructor details
CommissioningRequest
public CommissioningRequest()Method details
setSetupPayload
public CommissioningRequest setSetupPayload(SetupPayload setupPayload)The accessory’s onboarding payload, from a scanned QR code or a typed manual code.
Leave it unset to have the platform’s own UI scan one. Setting it skips that step, which is what you want when your app already runs a scanner.
Parameters
setupPayloadSetupPayload- the parsed payload, or
nullto clear it
Returns
getSetupPayload
public SetupPayload getSetupPayload()Returns
null when none was set or it was set rawsetRawSetupPayload
public CommissioningRequest setRawSetupPayload(String rawSetupPayload)An onboarding payload to pass through without parsing it.
For the vendor-extended payloads
SetupPayload.parse(java.lang.String) refuses: the platform’s own
commissioning UI understands them, and refusing to forward one would
make an accessory uncommissionable through this API for no reason
beyond our parser’s scope.
The cost is that nothing is validated, so a mistyped code fails in the
OS sheet rather than in your app. Prefer
setSetupPayload(SetupPayload) and fall back to this only when
parsing threw.
Parameters
rawSetupPayloadString- the code exactly as scanned, or
nullto clear it
Returns
getRawSetupPayload
public String getRawSetupPayload()Returns
null when none was setsetStructure
public CommissioningRequest setStructure(HomeStructure structure)Parameters
structureHomeStructure- the home, or
nullfor the platform’s default
Returns
setStructureId
public CommissioningRequest setStructureId(String structureId)Parameters
structureIdString- the home, or
nullfor the platform’s default
Returns
getStructureId
public String getStructureId()Returns
nullsetRoom
public CommissioningRequest setRoom(HomeRoom room)Parameters
roomHomeRoom- the room, or
nullto let the user choose
Returns
setRoomId
public CommissioningRequest setRoomId(String roomId)Parameters
roomIdString- the room, or
nullto let the user choose
Returns
getRoomId
public String getRoomId()Returns
nullsetSuggestedName
public CommissioningRequest setSuggestedName(String suggestedName)Parameters
suggestedNameString- the name, or
nullfor none
Returns
getSuggestedName
public String getSuggestedName()Returns
nullsetTimeoutMillis
public CommissioningRequest setTimeoutMillis(int timeoutMillis)How long to allow the whole flow, in milliseconds.
Zero, the default, means the platform’s own limit, and that is almost always what you want: a user commissioning an accessory may be up a ladder. They have to power it on, hold a button, sometimes join it to Wi-Fi. A timeout tuned to how long a network call takes will abandon a flow that was going fine.
Parameters
timeoutMillisint- the limit, or zero for the platform default
Returns
Throws
IllegalArgumentException- when the value is negative
setCommissionToThisApp
public CommissioningRequest setCommissionToThisApp(boolean commissionToThisApp)How long the flow is allowed, in milliseconds.
This is a build-wide capability, not a per-accessory switch
The machinery lives in an operating-system app extension that runs
outside your process, and it is generated when the build is made: one
setCommissionToThisApp(true) anywhere in your app turns it on for
every accessory that build commissions, whatever a particular request
says. A false request in such a build does not turn it back off –
nothing at run time can reach into the extension to say so.
It is a request method rather than a build hint because a call is something the build can SEE: the scanner reads this one and generates the extension accordingly, so an app that asks for the capability gets it without also having to remember a hint.
Where the build cannot read the call – an argument computed at run
time, or one call saying true while another says false – it
refuses rather than guessing, and names
ios.home.commissioning.fabric as the way to settle it. Guessing
either way is worse than stopping: “off” ships an app whose request is
quietly ignored, and “on” ships a Matter controller nobody asked for.
CommissioningResult.wasCommissionedToThisApp() reports what actually
happened for each accessory.
What this costs, and what it does not do
Commissioning to the user’s ecosystem – their HomeKit or Google home – is what the flow does by default, and it is what makes the accessory usable at all. This asks for a second administrator: the accessory is additionally commissioned onto a fabric belonging to this app, which is the only way an app can talk to a Matter accessory without going through the ecosystem.
It is not free. On iOS the build ships an operating-system Matter controller inside the generated commissioning extension, and the app carries the key material for its fabric.
Codename One does not yet expose an API for talking to an accessory
over that fabric. What asking for it buys today is that the
accessory is already commissioned when such an API arrives, and that
CommissioningResult.wasCommissionedToThisApp() can be true. Reading
and writing traits still goes through the ecosystem.
Where the platform cannot do it – Android’s Play Services
commissioning, every desktop – this is ignored and
CommissioningResult.wasCommissionedToThisApp() stays false.
Parameters
commissionToThisAppbooleantrueto ask for the second fabric
Returns
isCommissionToThisApp
public boolean isCommissionToThisApp()Returns
true when setCommissionToThisApp(boolean) asked for itgetTimeoutMillis
public int getTimeoutMillis()