Azure / azure-iot-arduino

Azure IoT library for the Arduino
Other
168 stars 95 forks source link

Lock/Unlock/Lock_Deinit undefined #44

Open compulim opened 7 years ago

compulim commented 7 years ago

Versions:

I am trying to use device twin functions (and direct methods) from the SDK, namely, IoTHubDeviceTwin_CreateXXX macros.

But when I compile my code, it said,

libraries\AzureIoTHub\sdk\iothub_client.c.o: In function `iothub_ll_device_twin_callback':

C:\Users\JohnDoe\Documents\Arduino\libraries\AzureIoTHub\src\sdk/iothub_client.c:1336: undefined reference to `Lock'

C:\Users\JohnDoe\Documents\Arduino\libraries\AzureIoTHub\src\sdk/iothub_client.c:1336: undefined reference to `Unlock'

C:\Users\JohnDoe\Documents\Arduino\libraries\AzureIoTHub\src\sdk/iothub_client.c:1336: undefined reference to `Lock_Deinit'

libraries\AzureIoTHub\sdk\iothub_client.c.o:(.text.garbageCollectorImpl$isra$0+0x48): undefined reference to `Lock'

Searching thru all files under C:\Users\JohnDoe\Documents\Arduino\libraries\AzureIoTUtility, I only see Lock/Unlock/Lock_Deinit declared in src\azure_c_shared_utility\lock.h, but found nothing in *.c files.

photomoose commented 7 years ago

I'm also getting this error. I believe the function definitions should be getting generated by the MOCKABLE_FUNCTION macro, as defined in lock.h (line 50) and umock_c_prod.h (line 30). If you explicitly define the function yourself, you also get a duplicate function definition error...so it would appear the function is there...

From what I've read, the "undefined reference to 'xxx'" error is a linking error rather than a compilation error.... and that's about as far as I have got with this problem.

Any suggestions would be mostly appreciated!

tameraw commented 7 years ago

@compulim - Thanks for reporting this, but currently Twin functionality is not supported on Arduino.

photomoose commented 7 years ago

@tameraw When you say "twin functionality is not supported", do you mean twin functionality overall or just the functionality defined in serializer_devicetwin.h?

I've been trying to send a serialized model similar to below using IoTHubClient_LL_SendReportedState and although the message appears to be accepted by the hub client, the callback gets invoked with a status code of 400. Do you know why this happens?

DECLARE_MODEL(Telemetry,
    WITH_DATA(ascii_char_ptr, DeviceId),
    WITH_DATA(float, TempC),
    WITH_REPORTED_PROPERTY(long, RSSI)
);
JetstreamRoySprowl commented 6 years ago

Twin is now [supported on Huzzah:] (https://github.com/Azure-Samples/iot-hub-c-huzzah-getstartedkit/tree/master/device_twin).

The Lock family are not relevant to Arduino because it is single-thread only. Make sure you don't use any of the non-LL files (like iothub_client.c ; use iothub_client_ll.c instead) and it'll be okay.