# Mangoh Red wp750x input config

**URL:** <https://mangoh.discourse.group/t/mangoh-red-wp750x-input-config/1351>\
**Category:** mangOH Red\
**Created:** [April 20, 2018, 2:30pm UTC](https://mangoh.discourse.group/t/mangoh-red-wp750x-input-config/1351 "2018-04-20T14:30:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![abalzano](https://avatars.discourse-cdn.com/v4/letter/a/e68b1a/32.png) [@abalzano](https://mangoh.discourse.group/u/abalzano)\
**Post date:** [April 20, 2018, 2:30pm UTC](https://mangoh.discourse.group/t/mangoh-red-wp750x-input-config/1351/1 "2018-04-20T14:30:41Z")

</div>

Hi everyone,  
i have to connect one button to Mangoh Red, i used GPIO22 of CF3 GPIO. Following you can see the code:  
**.adef**  
executables:  
{  
gpioCf3Demo = ( gpioCf3PinComponent )  
}

```
bindings:
{
  gpioCf3Demo.gpioCf3PinComponent.le_gpioPin22 -> gpioService.le_gpioPin22
}

```

processes:  
{  
envVars:  
{  
LE\_LOG\_LEVEL = DEBUG  
}

```
  run:
   {
    ( gpioCf3Demo )
   }
}

```

**.cdef**  
requires:  
{  
api:  
{  
le\_gpioPin22 = le\_gpio.api  
}  
}

cflags:  
{  
“-std=c99”  
}

sources:  
{  
gpioCf3Pin.c  
}

**.c**  
#include “legato.h”  
#include “interfaces.h”

```
static void Pin22ChangeCallback(bool state, void *ctx){
   LE_INFO("button pressed ****************************");
 }

static void Pin22GpioSignal()
{
    le_gpioPin22_SetInput(LE_GPIOPIN22_ACTIVE_HIGH);
    le_gpioPin22_EnablePullDown();
    le_gpioPin22_AddChangeEventHandler(LE_GPIOPIN22_EDGE_BOTH, Pin22ChangeCallback, NULL, 0);

    le_gpioPin22_SetEdgeSense(LE_GPIOPIN22_EDGE_BOTH);
 }

 COMPONENT_INIT
 {
   LE_INFO("This is sample gpioctl Legato CF3 GPIO app by using le_gpio.api\n");

    Pin22GpioSignal();
    return;	
   }

```

I follow this example : [https://github.com/legatoproject/legato-af/tree/master/apps/sample/gpioCf3Demo](https://github.com/legatoproject/legato-af/tree/master/apps/sample/gpioCf3Demo)

The button is connected to pin 11 that correspond to GPIO22, and the other pin is connected to ground. Anyone can tell me what i’m wrong?

Thank you in advance!!!

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/nick/32/1380_2.png) [@nick](https://mangoh.discourse.group/u/nick)\
**Post date:** [April 20, 2018, 5:44pm UTC](https://mangoh.discourse.group/t/mangoh-red-wp750x-input-config/1351/2 "2018-04-20T17:44:50Z")

</div>

Hey @abalzano,

What seems to be the issue here? I’ve been working with the `le_gpio` API quite a bit and your code looks mostly correct to me. Are you having trouble compiling/building/deploying or are you just not seeing the change?

Cheers!

---

<div class="post-metadata">

**Author:** ![abalzano](https://avatars.discourse-cdn.com/v4/letter/a/e68b1a/32.png) [@abalzano](https://mangoh.discourse.group/u/abalzano)\
**Post date:** [April 23, 2018, 8:27am UTC](https://mangoh.discourse.group/t/mangoh-red-wp750x-input-config/1351/3 "2018-04-23T08:27:35Z")

</div>

Hi Nick  
Thank you for your replay, anyway my problem is that i don’t see any change when i press the button. I checked also was enable by AT commands and everithing seems good. Regarding bulding/compilation i don’t have any error.

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/nick/32/1380_2.png) [@nick](https://mangoh.discourse.group/u/nick)\
**Post date:** [April 23, 2018, 8:58pm UTC](https://mangoh.discourse.group/t/mangoh-red-wp750x-input-config/1351/4 "2018-04-23T20:58:48Z")

</div>

Hey @abalzano,

Let’s confirm the app is installed and running. Start by `ssh`'ing into your target by invoking `ssh root@192.168.2.2` (or another IP if you changed it). After logging into the `ssh` session, invoke `app status` or `app status | grep gpioCf3Demo` if you want to only see your new app. It’s also helpful to update versions in your `.adef` file as you go such that you can run `app version <appname>` to confirm the latest version is installed (its not uncommon for Legato to reject apps that fault frequently and roll them back).

If all is running as expected, let me know and we can go from there.

Cheers!

---

<div class="post-metadata">

**Author:** ![abalzano](https://avatars.discourse-cdn.com/v4/letter/a/e68b1a/32.png) [@abalzano](https://mangoh.discourse.group/u/abalzano)\
**Post date:** [April 24, 2018, 7:33am UTC](https://mangoh.discourse.group/t/mangoh-red-wp750x-input-config/1351/5 "2018-04-24T07:33:35Z")

</div>

Hi Nick, the app is runnig, as you can see in the attached picture. Just to be sure, at the moment i connected the push button to GPIO22, without external pull-up resistance, but i have just enable the internal pull-up. Maybe the is something wrong in the phisical connection.

Thank you, have a good day.

---

<div class="post-metadata">

**Author:** ![abalzano](https://avatars.discourse-cdn.com/v4/letter/a/e68b1a/32.png) [@abalzano](https://mangoh.discourse.group/u/abalzano)\
**Post date:** [April 24, 2018, 7:34am UTC](https://mangoh.discourse.group/t/mangoh-red-wp750x-input-config/1351/6 "2018-04-24T07:34:18Z")

</div>

here the picture ![appversion](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/1X/8414a04e74aada9cb8b25821781464fe0df82ab7.png)

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/nick/32/1380_2.png) [@nick](https://mangoh.discourse.group/u/nick)\
**Post date:** [April 24, 2018, 8:48pm UTC](https://mangoh.discourse.group/t/mangoh-red-wp750x-input-config/1351/7 "2018-04-24T20:48:47Z")

</div>

Hey @abalzano,

Definitely double check the physical connections as its always a good thing to try and rule out. The only thing I see in your code that I’ve never tried before is the call to `le_gpioPin22_SetEdgeSense(LE_GPIOPIN22_EDGE_BOTH);`. I suspect this call is not needed since the edge sense is specified when attaching the change handler, but I would be surprised if this would cause issues.

Maybe try polling it every 30 seconds or so and print the value to the logs. See if these values match what you expect. If they are not what you expect, likely that GPIO pin is not working at all (physical or configuration).

I’ve also found it helpful to inspect things you depend on in situations like this. A few handy commands for this:

- `sdir list`: Shows all services and bindings (and shows if any services are waiting).
- `dmesg` and `dmesg | grep i2c`: Show the kernel logs. I’ve seen GPIO failure occur due to i2c problems so the `grep` can be useful.
- `logread | grep gpioService`: Show the logs for `gpioService`. It should log if it’s having any issues.

Hopefully this is helpful,  
Cheers!
