Step to check if GPIO drivers are available
Step to check the current state of the pin
Steps to configure the webhook from Admin Portal
Introduction
A webhook is a system that allows an application to receive notification messages from another application, without requiring any manual interaction. For example, you can use webhooks to send notification messages to your database about new events. Or, you can use them to send event notifications to other services, such as turning on a light.
Users can now use the GPIO pins available on the Gateway to receive the information from the webhook. This is useful if the user wants to connect an external electrical device to the Gateway to get a response from the webhook for an event.
Currently, the Gateway built-in methods allow you to activate one pin with one webhook and this will change the state of one GPIO pin and only one way. So, this means that when an event happens the webhook will be sent to the gateway changing the GPIO pin to the ON or OFF state. To change a state again a new webhook has to be configured which will send the signal to the same GPIO pin to change the state of the pin again.
Step to check if GPIO drivers are available
All gateways that were shipped after June 6th, 2022 come with preinstalled GPIO drivers and thus the methods described in this tutorial will work on them. To check if your gateway has the GPIO functionality enabled connect to it from the same local network as the gateway is on, then go to the link http://camera-gateway.local/ or if you have an older generation of the Gateway firmware type in the local IP address of the Gateway and add the following text after the link to check if the GPIO drivers are available on the gateway:
api/gpio/available
For example,
http://camera-gateway.local/api/gpio/available
will return a page with the word "True" if the drivers are available or a blank page if not as shown in the screenshot below.
Step to check the current state of the pin
To check the current state of the pins use
api/gpio/setOutput?index=11
were "11" is the pin number.
For example,
http://camera-gateway.local/api/gpio/setOutput?index=11
will return a page with the word "0" if the GPIO pin number 11 is not active (has no voltage applied to it) or a "1" if it is active (has 3.3 V).
To change the state of the pin use:
api/gpio/setOutput?index=11&value=1
after the camera address. For example to turn on the voltage on pin 11 use:
http://camera-gateway.local/api/gpio/setOutput?index=11&value=1
The value "1" will enable the pin and the value "0" will disable the pin. For example to turn off pin 11 use:
http://camera-gateway.local/api/gpio/setOutput?index=11&value=0
Below is the GPIO pin layout for the Gateway. Please note that these commands are only for the Gateways that were purchased from us and only for the version with the metal case. The legacy OS image of the Raspberry that we offered in the past is different and it does not have the GPIO drivers.
Steps to configure the webhook from Admin Portal
To use webhooks using GPIO the user needs to create two Webhooks with different event types i.e. one for enabling the device state connected to the GPIO and one to turn off the device connected to the same GPIO.
To create a webhook, from the Integrator account, go to the customer tab and then select Customer.
Then go to the Alert Tab in that customer and select webhooks. Click on Create Webhooks to create a new Webhook
In the General tab select the Delivery Method as Push gateway, Enter the Name for the Webhook and the Registration code of the Gateway, please note the gateway Registration code can be found on the top right side of the page.
Then enter the path used to set the status of the GPIO pin. For example, to turn on pin 11 user:
api/gpio/setOutput?index=11&value=1
Change the GPIO pin number by changing the value in "index=". Set the value="1" for enabling the GPIO (3.3 Volts will be supplied through the pin) and the value="0" for disabling the GPIO pin (no voltage will be supplied through the pin).
Then set the HTTP Method to GET, please don't select POST as then the webhooks won't work with the gateway
In the next step, select the desired events for which the webhooks should be set up to enable the device to connect to the GPIO pins.
Then select the role from the drop-down list to select what cameras will be used for the webhook. Then select the payload type from the drop-down. Then click on create to create a webhook.
The following shows the use case of GPIO with the webhook which we created above.
Comments
0 comments
Please sign in to leave a comment.