<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Read GPIO pin status through a characteristic.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/27058/read-gpio-pin-status-through-a-characteristic</link><description>Hi, 
 I am new to nrf and trying to make some new services and characteristics for my device.
I followed the advertising , services and characteristics tutorial and was successfully able to make a new service and new characteristic. 
 But now I want</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 19 Dec 2016 06:42:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/27058/read-gpio-pin-status-through-a-characteristic" /><item><title>RE: Read GPIO pin status through a characteristic.</title><link>https://devzone.nordicsemi.com/thread/106328?ContentTypeID=1</link><pubDate>Mon, 19 Dec 2016 06:42:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad8b5d9a-b08d-4820-a1e1-3f5f7b17da56</guid><dc:creator>Priya</dc:creator><description>&lt;p&gt;Thanks Jorgen, It worked for me :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO pin status through a characteristic.</title><link>https://devzone.nordicsemi.com/thread/106321?ContentTypeID=1</link><pubDate>Fri, 16 Dec 2016 13:27:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb52a7d5-f35b-42f0-afd7-c77e5fb96813</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Yes, I forgot to mention the addition of the &lt;em&gt;&amp;amp;&lt;/em&gt; sign, I have updated my initial answer to include this change.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO pin status through a characteristic.</title><link>https://devzone.nordicsemi.com/thread/106326?ContentTypeID=1</link><pubDate>Fri, 16 Dec 2016 13:21:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f2030fb4-d47a-4b86-b4e2-d387f0db1048</guid><dc:creator>Priya</dc:creator><description>&lt;p&gt;Thanks Jorgen, let me try them and get back to you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO pin status through a characteristic.</title><link>https://devzone.nordicsemi.com/thread/106325?ContentTypeID=1</link><pubDate>Fri, 16 Dec 2016 13:19:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e7267f71-ba87-4240-929c-6ba3f7d10289</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I have created examples for both GPIO/Timer and GPIOTE sense alternatives: &lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/gpio_5F00_char_5F00_example.zip"&gt;gpio_char_example.zip&lt;/a&gt;,
&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/gpiote_5F00_sense_5F00_char_5F00_example.zip"&gt;gpiote_sense_char_example.zip&lt;/a&gt;. Please have a look at these. They are both tested with PCA10028 (nRF51 DK) and PCA10040 (nRF52 DK) boards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO pin status through a characteristic.</title><link>https://devzone.nordicsemi.com/thread/106324?ContentTypeID=1</link><pubDate>Fri, 16 Dec 2016 13:06:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c05bc76-d005-442b-b7f4-db71dbef6def</guid><dc:creator>Priya</dc:creator><description>&lt;p&gt;Yes, I have enabled the notifications through my app. But after that also I am getting a constant value 0x01. (I don&amp;#39;t know, what does it mean.)&lt;/p&gt;
&lt;p&gt;I have changed attr_char_value.p_value     = value; to attr_char_value.p_value     = &amp;amp;value; because with the previous one it was giving error of invalid conversion from uint8_t to uint8_t*.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO pin status through a characteristic.</title><link>https://devzone.nordicsemi.com/thread/106323?ContentTypeID=1</link><pubDate>Fri, 16 Dec 2016 12:56:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:850b117f-1893-48f5-b494-1ba068c36731</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You should also be able to do the update of the characteristics using GPIO sensing/GPIOTE. Comment out the content of the timer_timeot_handler() function, add the following GPIOTE handler function:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void gpiote_event_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    int32_t temperature = 0;
    temperature = nrf_drv_gpiote_in_is_set(INPUT_PIN);
	our_temperature_characteristic_update(&amp;amp;m_our_service, &amp;amp;temperature);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In main(), add the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_drv_gpiote_init();
nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
nrf_drv_gpiote_in_init(INPUT_PIN , &amp;amp;config, gpiote_event_handler);
nrf_drv_gpiote_in_event_enable(INPUT_PIN, true);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO pin status through a characteristic.</title><link>https://devzone.nordicsemi.com/thread/106322?ContentTypeID=1</link><pubDate>Fri, 16 Dec 2016 12:50:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f09b571-bdb6-4425-af2f-d1121fe5a5ed</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Yes, I have tested it. Have you remembered to enable notifications after connecting to the device?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO pin status through a characteristic.</title><link>https://devzone.nordicsemi.com/thread/106327?ContentTypeID=1</link><pubDate>Fri, 16 Dec 2016 11:15:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d16ba7f-49c0-427c-a915-170e0138d5a4</guid><dc:creator>Priya</dc:creator><description>&lt;p&gt;Hi @jorgen, I am doing as accordingly you instructed me. but nothing changes. please help me what should i need to change? Have you tested..is this working?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO pin status through a characteristic.</title><link>https://devzone.nordicsemi.com/thread/106320?ContentTypeID=1</link><pubDate>Fri, 16 Dec 2016 10:04:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:135fd934-b044-4b8c-8d1c-f3bfc40d362a</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;If you followed the characteristics tutorial to the end, you should have a characteristics reporting temperature gathered from the IC at a regular interval. If you want to change the application to report state of a pin on this charactersistics instead, this is the changes you need to make:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Define the pin: &lt;code&gt;#define INPUT_PIN 28&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Configure pin as input in main(): &lt;code&gt;nrf_gpio_cfg_input(INPUT_PIN , NRF_GPIO_PIN_NOPULL);&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Change &lt;em&gt;timer_timeout_handler()&lt;/em&gt; function to read pin state and pass this to the characteristic update function:&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;pre&gt;&lt;code&gt;static void timer_timeout_handler(void * p_context)
{
   int32_t pin_state = 0;
   pin_state = nrf_gpio_pin_read(INPUT_PIN);
   our_temperature_characteristic_update(&amp;amp;m_our_service, &amp;amp;pin_state);
   nrf_gpio_pins_toggle(BSP_LED_2);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;The characteristics should now be updated with the pin state on any change.&lt;/p&gt;
&lt;p&gt;If you want the characteristics to be only 1 byte long, and also report the correct pin state on initialization, you also have to change the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In &lt;em&gt;our_char_add()&lt;/em&gt;, change &lt;code&gt;attr_char_value.max_len&lt;/code&gt;, &lt;code&gt;attr_char_value.init_len&lt;/code&gt;, &lt;code&gt;value&lt;/code&gt; and &lt;code&gt;attr_char_value.p_value&lt;/code&gt; to:&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;pre&gt;&lt;code&gt;attr_char_value.max_len  = 1;
attr_char_value.init_len = 1;
uint8_t value            = nrf_gpio_pin_read(INPUT_PIN);
attr_char_value.p_value  = &amp;amp;value;
&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;ul&gt;
&lt;li&gt;In &lt;em&gt;our_temperature_characteristic_update()&lt;/em&gt;, change &lt;code&gt;len&lt;/code&gt; to 1.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO pin status through a characteristic.</title><link>https://devzone.nordicsemi.com/thread/106318?ContentTypeID=1</link><pubDate>Thu, 15 Dec 2016 14:05:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ffe62828-5659-4e92-8d93-48cbc52b887d</guid><dc:creator>Priya</dc:creator><description>&lt;p&gt;Hi jorgen, my gpio pin is acting as an input.
If I&amp;#39;m not wrong then it means it will update the value but i couldn&amp;#39;t be able to read it through the characteristic?
Please help me in finding the solution.
If there are some examples available which can help me regarding this stuff please help me!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read GPIO pin status through a characteristic.</title><link>https://devzone.nordicsemi.com/thread/106319?ContentTypeID=1</link><pubDate>Thu, 15 Dec 2016 12:27:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:816b0a80-53bb-403f-8064-0fb70a88ed6d</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Should the pin be input or output? I&amp;#39;m not aware of any way you can read the GPIO state from the characteristics, but you can run a periodic timer that updates the characteristics value with the state of the pin at a given interval.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>