MicrosoftDocs / mslearn-mr-adt-in-unity

This is a repo that holds the sample code for the Mixed Reality and Azure Digital Twins in Unity Learn Path
Creative Commons Attribution 4.0 International
65 stars 55 forks source link

mxchip press button send signal to Azure IoT #18

Closed sergiosolorzano closed 1 year ago

sergiosolorzano commented 1 year ago

Can someone share an example or guidance how I can add that when a button in the mxchip IoT device is pressed the signal is sent to Azure IoT? I'm using this example to send devkit data to IoT hub.

I see the function in board_init.c that lights up the led:

`weak void button_a_callback() {

WIFI_LED_ON(); AZURE_LED_ON(); USER_LED_ON(); if (BUTTON_A_IS_PRESSED) { val += 32; if (val > 2047) val = 2047; RGB_LED_SET_R(val); RGB_LED_SET_G(val); RGB_LED_SET_B(val); } //set_led_state(true); I'd like to add something like this` }

and in nx_client.c to set the led state (true or false) when the command is received from Azure IoT:

static void set_led_state(bool level) { if (level) { printf("\tLED is turned ON\r\n"); HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_SET); } else { printf("\tLED is turned OFF\r\n"); HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET); } }

How can I link these two functions, meaning from button_a_callback to call nx_client.c set_led_state function?

Thanks a bunch

sergiosolorzano commented 1 year ago

Apologies, wrong git to post, in case anyone else interested I've re-posted in the correct [repo](https://github.com/azure-rtos/getting-started/issues/349).