Skip to content
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
17 changes: 7 additions & 10 deletions examples/GeneratorShowcase/GeneratorShowcase.h
Original file line number Diff line number Diff line change
Expand Up @@ -1858,26 +1858,23 @@ namespace Plugin {
Example::JSimpleInstanceObjects::Event::StateChanged(*this, object, device->State(), client);
}
}
void OnPinChangedEventRegistration(Example::ISimpleInstanceObjects::IDevice* object, const string& client, const PluginHost::JSONRPCSupportsEventStatus::Status status) override
void OnPinChangedEventRegistration(Example::ISimpleInstanceObjects::IDevice* object, const string& client, const string& index, const PluginHost::JSONRPCSupportsEventStatus::Status status) override
{
string name;
static_cast<const Example::ISimpleInstanceObjects::IDevice*>(object)->Name(name);

TRACE(Trace::Information, (_T("Client '%s' %s for device '%s' pin state change notifications"), client.c_str(),
status == PluginHost::JSONRPCSupportsEventStatus::Status::registered? "registered" : "unregistered", name.c_str()));
TRACE(Trace::Information, (_T("Client '%s' %s for device '%s' pin %s state change notifications"), client.c_str(),
status == PluginHost::JSONRPCSupportsEventStatus::Status::registered? "registered" : "unregistered", name.c_str(), index.c_str()));

// A JSON-RPC client registered for "pinchanged" notifications, let them know the state if the pin is lit already.
// Only the registering client will recieve this extra notification, via the default sendif method generated.
// The client designator also carries index of the pin.
if (status == PluginHost::JSONRPCSupportsEventStatus::Status::registered) {
ImaginaryHost::DeviceImpl* device = static_cast<ImaginaryHost::DeviceImpl*>(object);

device->IteratePins([this, object, client](const uint8_t index, const bool high) {

if (high == true) {
Example::JSimpleInstanceObjects::Event::PinChanged(*this, object, index, true, client);
}
});
const uint8_t pin = ::atoi(index.c_str());
if (device->PinStatus(pin) == true) {
Example::JSimpleInstanceObjects::Event::PinChanged(*this, object, pin, true, client);
}
}
}

Expand Down
26 changes: 11 additions & 15 deletions examples/GeneratorShowcase/doc/GeneratorShowcasePlugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -2026,7 +2026,7 @@ Signals completion of the Connect method.

### Parameters

> The *address* parameter shall be passed within the *id* parameter to the ``register`` call, i.e. ``<address>.<client-id>``.
> The *address* parameter shall be passed as index to the ``register`` call, i.e. ``register@<address>``.

### Notification Parameters

Expand All @@ -2043,10 +2043,10 @@ Signals completion of the Connect method.
{
"jsonrpc": "2.0",
"id": 42,
"method": "GeneratorShowcase.1.register",
"method": "GeneratorShowcase.1.register@[11,22]",
"params": {
"event": "bindingChanged",
"id": "[11,22].myid"
"id": "myid"
}
}
```
Expand All @@ -2056,16 +2056,14 @@ Signals completion of the Connect method.
```json
{
"jsonrpc": "2.0",
"method": "[11,22].myid.bindingChanged",
"method": "myid.bindingChanged@[11,22]",
"params": {
"bound": false
}
}
```

> The *client ID* parameter is passed within the notification designator, i.e. ``<address>.<client-id>.bindingChanged``.

> The *address* parameter is passed within the notification designator, i.e. ``<address>.<client-id>.bindingChanged``.
> The *client ID* parameter is passed within the notification designator, i.e. ``<client-id>.bindingChanged@<address>``.

<a id="notification_statusChanged"></a>
## *statusChanged [<sup>notification</sup>](#head_Notifications)*
Expand Down Expand Up @@ -2214,7 +2212,7 @@ Signals pin state changes.

### Parameters

> The *pin* parameter shall be passed within the *id* parameter to the ``register`` call, i.e. ``<pin>.<client-id>``.
> The *pin* parameter shall be passed as index to the ``register`` call, i.e. ``register@<pin>``.

### Notification Parameters

Expand All @@ -2231,10 +2229,10 @@ Signals pin state changes.
{
"jsonrpc": "2.0",
"id": 42,
"method": "GeneratorShowcase.1.device#id1::register",
"method": "GeneratorShowcase.1.device#id1::register@0",
"params": {
"event": "pinChanged",
"id": "0.myid"
"id": "myid"
}
}
```
Expand All @@ -2244,18 +2242,16 @@ Signals pin state changes.
```json
{
"jsonrpc": "2.0",
"method": "0.myid.device#id1::pinChanged",
"method": "myid.device#id1::pinChanged@0",
"params": {
"high": false
}
}
```

> The *client ID* parameter is passed within the notification designator, i.e. ``<pin>.<client-id>.device#<device-id>::pinChanged``.

> The *pin* parameter is passed within the notification designator, i.e. ``<pin>.<client-id>.device#<device-id>::pinChanged``.
> The *client ID* parameter is passed within the notification designator, i.e. ``<client-id>.device#<device-id>::pinChanged@<pin>``.

> The *device instance id* parameter is passed within the notification designator, i.e. ``<pin>.<client-id>.device#<device-id>::pinChanged``.
> The *device instance id* parameter is passed within the notification designator, i.e. ``<client-id>.device#<device-id>::pinChanged@<pin>``.

<a id="notification_added"></a>
## *added [<sup>notification</sup>](#head_Notifications)*
Expand Down
Loading