Example #1
0
//Main function, the entry point
int main(void)
{
	int uart_check = 0,i=0,j=0;
	char str[]="sunny,sunny day";//inputs are given
	char w[]="sunny";
	//Checking the status of UART
	uart_check = wmstdio_init(UART0_ID, 0);
	if (uart_check == -WM_FAIL) {
		wmprintf("Failed to initialize console on uart0\r\n");
		return -1;
	}
    	wmprintf("entered  string is :%s\n",str);//inputs are outputed
	wmprintf("entered word :%s\n",w);
	
	int wcount = count(str,w);//ouputting total words

    wmprintf("word count : %d\n",wcount);
    if (wcount>0)
    {
    	 gpio_led_on()
    }

	gpio_led = (board_led_2()).gpio; //assigning gpio pin to led
	gpio_pushbutton = board_button_2(); //assigning gpio pin to push button


	configure_gpios();
	wmprintf("Press push button to reset the program.");
	while (1)
		;
	return 0;
}
Example #2
0
void reset(void)	//same function as main()
{
	   char str[]="sunny,sunny day";//inputs are given
	   char w[]="sunny";
	   wmprintf("entered  string is :%s\n",str);//inputs are outputed
	   wmprintf("entered word :%s\n",w);

	int wcount = count(str,w);

    wmprintf("word count : %d\n",wcount);
    if (wcount>0)
    {
    	 gpio_led_on()
    }

	gpio_led = (board_led_2()).gpio; //assigning gpio pin to led
	gpio_pushbutton = board_button_2(); //assigning gpio pin to push button


	configure_gpios();
	wmprintf("Press push button to reset the program.");
	while (1)
		;
	return 0;
}
Example #3
0
/* This is an entry point for the application.
   All application specific initialization is performed here. */
int main(void)
{
	int ret = 0;

	/* Initializes console on UART0 */
	ret = wmstdio_init(UART0_ID, 0);
	if (ret == -WM_FAIL) {
		wmprintf("Failed to initialize console on uart0\r\n");
		return -1;
	}

	wmprintf(" GPIO demo application started\r\n");
	wmprintf(" This application demonstrates the"
		 " use of various GPIO driver APIs\r\n");
	wmprintf(" Press button 2 to toggle state of LED\r\n");

	gpio_led = (board_led_2()).gpio;
	gpio_pushbutton = board_button_2();

	wmprintf(" LED Pin : %d\r\n", gpio_led);
	wmprintf(" Pushbutton Pin : %d\r\n", gpio_pushbutton);

	configure_gpios();
	while (1)
		;
	return 0;
}
Example #4
0
/* Configure GPIO pins to be used as LED and push button */
static void configure_gpios()
{
	/* Get the corresponding pin numbers using the board specific calls */
	/* also configures the gpio accordingly for LED */
	led_1 = board_led_1();
	led_2 = board_led_2();
	button_1 = board_button_1();
	button_2 = board_button_2();

    push_button_set_cb((input_gpio_cfg_t){button_1, GPIO_ACTIVE_LOW}, pushbutton_cb, 0, 0, 0);
    push_button_set_cb((input_gpio_cfg_t){button_2, GPIO_ACTIVE_LOW}, pushbutton_cb, 0, 0, 0);
}
Example #5
0
/* callback function invoked on reset to factory */
static void device_reset_to_factory_cb()
{
	/* Clears device configuration settings from persistent memory
	 * and reboots the device.
	 */
	invoke_reset_to_factory();
}

/* board_button_2() is configured to perform reset to factory,
 * when pressed for more than 5 seconds.
 */
static void configure_reset_to_factory()
{
	input_gpio_cfg_t pushbutton_reset_to_factory = {
		.gpio = board_button_2(),
		.type = GPIO_ACTIVE_LOW
	};
	push_button_set_cb(pushbutton_reset_to_factory,
			   device_reset_to_factory_cb,
			   RESET_TO_FACTORY_TIMEOUT, 0, NULL);
}



static char client_cert_buffer[AWS_PUB_CERT_SIZE];
static char private_key_buffer[AWS_PRIV_KEY_SIZE];
#define THING_LEN 126
#define REGION_LEN 16
static char thing_name[THING_LEN];
static char client_id[MAX_SIZE_OF_UNIQUE_CLIENT_ID_BYTES];