Azure / iot-edge-v1

Azure IoT Edge
http://azure.github.io/iot-edge/
Other
524 stars 257 forks source link

DynamicLibrary_LoadLibrary() returned NULL #34

Closed gerrik84 closed 7 years ago

gerrik84 commented 7 years ago

i followed the instructions of sample_ble.md and https://azure.microsoft.com/en-us/documentation/articles/iot-hub-gateway-sdk-physical-device/ at the and when i wana start the /ble_gateway_hl by./build/samples/ble_gateway_hl/ble_gateway_hl ./samples/ble_gateway_hl/src/gateway_sample.json i get some errors...

Error: Time:Thu Sep 29 21:19:15 2016 File:/home/root/azure-iot-gateway-sdk/core/src/module_loader.c Func:ModuleLoader_Load Line:53 ModuleLoader_Load() - DynamicLibrary_LoadLibrary() returned NULL Error: Time:Thu Sep 29 21:19:15 2016 File:/home/root/azure-iot-gateway-sdk/core/src/gateway_ll.c Func:gateway_addmodule_internal Line:202 Failed to add module because the module located at [/home/root/azure-iot-gateway-sdk/build/modules/iothub/libiothub_hl.so] could not be loaded. Error: Time:Thu Sep 29 21:19:15 2016 File:/home/root/azure-iot-gateway-sdk/core/src/gateway_ll.c Func:Gateway_LL_Create Line:87 Gateway_LL_Create(): Unable to add module 'IoTHub'. The gateway will be destroyed. Error: Time:Thu Sep 29 21:19:15 2016 File:/home/root/azure-iot-gateway-sdk/core/src/gateway.c Func:Gateway_Create_From_JSON Line:51 Failed to create gateway using lower level library. Error: Time:Thu Sep 29 21:19:15 2016 File:/home/root/azure-iot-gateway-sdk/samples/ble_gateway_hl/src/main.c Func:main Line:47 An error ocurred while creating the gateway.

darobs commented 7 years ago

Hi @gerrik84, thank you for looking at our project. That error is an indication that the path in the JSON does not point to the library file. The two most likely reason I can think of are:

Based on your output, the module path in the gateway_sample.json should look like this:

"module name": "IoTHub", "module path": "/home/root/azure-iot-gateway-sdk/build/modules/iothub/libiothub_hl.so",

Please check to make sure the file exists at /home/root/azure-iot-gateway-sdk/build/modules/iothub/libiothub_hl.so

Otherwise, please edit ./samples/ble_gateway_hl/src/gateway_sample.json and confirm it is set to the text above. Note that the gateway_sample.json as saved in the repository has placeholders for the module paths, and not the actual file paths.

If those actions don't solve the problem, please post here again, and we'll continue to debug the problem.

Thanks, Dave (@darobs)

gerrik84 commented 7 years ago

Thanks for your quick answear,

i looked up the module path there is no libiothub_hl.so even the directory /home/root/azure-iot-gateway-sdk/build/modules/iothub dont exists. In my case the only directory where i can find a libiothub file is in azure-iot-gateway-sdk/build/modules/iothubhttp/libiothubhttp_hl.so

so i changed my gateway_sample.json to

{
  "module name": "IoTHub",
  "module path": "/home/root/azure-iot-gateway-sdk/build/modules/iothubhttp/libiothubhttp_hl.so",
  "args": {
    "IoTHubName": "XXXXXX",
    "IoTHubSuffix": "azure-devices.net",
    "Transport": "HTTP"
  }

if i run the sample again i get the following

_hl ./samples/ble_gateway_hl/src/gateway_sample.jsons/ble_gateway_hl/blegateway Gateway is running. Error: Time:Fri Sep 30 07:47:10 2016 File:/home/root/azure-iot-gateway-sdk/modules/ble/src/ble_gatt_io_linux_read.c Func:BLEIO_gatt_read_char_by_uuid Line:155 g_tree_lookup() failed. Error: Time:Fri Sep 30 07:47:10 2016 File:/home/root/azure-iot-gateway-sdk/modules/ble/src/bleio_seq_linux_schedule_read.c Func:schedule_read Line:119 BLEIO_gatt_read_char_by_uuid failed with 153. Error: Time:Fri Sep 30 07:47:10 2016 File:/home/root/azure-iot-gateway-sdk/modules/ble/src/bleio_seq_linux.c Func:BLEIO_Seq_Run Line:329 An error occurred while scheduling an instruction of type 0 for characteristic 00002A24-0000-1000-8000-00805F9B34FB Error: Time:Fri Sep 30 07:47:10 2016 File:/home/root/azure-iot-gateway-sdk/modules/ble/src/ble.c Func:on_connect_complete Line:370 BLEIO_Seq_Run failed

i checked the connection to my ble device and it is connected and the mac adress is correct.

i dont use any build flags so why do i have a diffrent directory for my libiothub_hl.so ? Maybe because of the "Transport": "HTTP" in my json ?

gerrik84 commented 7 years ago

the uuid is from https://azure.microsoft.com/en-us/documentation/articles/iot-hub-gateway-sdk-physical-device/ and i use the same device like in the documentation.

darobs commented 7 years ago

Some of the problems I've run into:

There are probably more ways for this setup to fail, but those are the problems I've had, barring the ones you've already confirmed aren't a problem (like incorrect MAC Address).

One thing I noticed is that there was a new commit on the main branch since you cloned the repository, and the documents you're looking at were also updated with that push to main - that's the reason why it didn't find the iothub module when you followed the instructions. As far as I know, the BLE module has not had any bug fixes to the BLE module in recent weeks, so it's unlikely that a slightly older commit is causing Bluetooth problems.

That's all I have for now. If that doesn't help resolve your problem, I'll contact the module author for more advice.

gerrik84 commented 7 years ago

i have double checked the output with the bluetoothctl console.

when i start the ble_gateway_hl and the bluetooth device is not connected i get this

Gateway is running.
Error: Time:Sat Oct  1 08:17:21 2016 File:/home/root/azure-iot-gateway-sdk/modules/ble/src/ble_gatt_io_linux_connect.c Func:on_sequence_error Line:447 Connect failed with - Timeout was reached
Error: Time:Sat Oct  1 08:17:21 2016 File:/home/root/azure-iot-gateway-sdk/modules/ble/src/ble.c Func:on_connect_complete Line:361 BLEIO_gatt_connect asynchronously failed

Info: Caught ctrl+c - quitting...
Gateway is quitting
Error: Time:Sat Oct  1 08:18:49 2016 File:/home/root/azure-iot-gateway-sdk/modules/ble/src/ble_gatt_io_linux_write.c Func:BLEIO_gatt_write_char_by_uuid Line:189 Invalid args or the state of the object is unexpected.
Error: Time:Sat Oct  1 08:18:49 2016 File:/home/root/azure-iot-gateway-sdk/modules/ble/src/bleio_seq_linux_schedule_write.c Func:schedule_write Line:125 BLEIO_gatt_write_char_by_uuid failed with 188.
Error: Time:Sat Oct  1 08:18:49 2016 File:/home/root/azure-iot-gateway-sdk/modules/ble/src/bleio_seq_linux.c Func:BLEIO_Seq_Destroy Line:224 Scheduling WRITE_AT_EXIT instruction at index 8 failed.
Info: Waiting for sequence to be destroyed...
Info: Done waiting for sequence to be destroyed.

When i activate the ble device and run the ble_gateway_hl i get this on the bluetoothctl console

[CHG] Device B0:B4:48:EE:01:84 Connected: yes
[CHG] Device B0:B4:48:EE:01:84 Connected: no
[bluetooth]# ble_gateway_hl

And the ble_gateway_hl output is

Gateway is running.
Error: Time:Sat Oct  1 08:28:39 2016 File:/home/root/azure-iot-gateway-sdk/modules/ble/src/ble_gatt_io_linux_read.c Func:BLEIO_gatt_read_char_by_uuid Line:155 g_tree_lookup() failed.
Error: Time:Sat Oct  1 08:28:39 2016 File:/home/root/azure-iot-gateway-sdk/modules/ble/src/bleio_seq_linux_schedule_read.c Func:schedule_read Line:119 BLEIO_gatt_read_char_by_uuid failed with 153.
Error: Time:Sat Oct  1 08:28:39 2016 File:/home/root/azure-iot-gateway-sdk/modules/ble/src/bleio_seq_linux.c Func:BLEIO_Seq_Run Line:329 An error occurred while scheduling an instruction of type 0 for characteristic 00002A24-0000-1000-8000-00805F9B34FB
Error: Time:Sat Oct  1 08:28:39 2016 File:/home/root/azure-iot-gateway-sdk/modules/ble/src/ble.c Func:on_connect_complete Line:370 BLEIO_Seq_Run failed
^CInfo: Caught ctrl+c - quitting...
Gateway is quitting
Error: Time:Sat Oct  1 08:28:48 2016 File:/home/root/azure-iot-gateway-sdk/modules/ble/src/ble_gatt_io_linux_write.c Func:BLEIO_gatt_write_char_by_uuid Line:176 g_tree_lookup() failed.
Error: Time:Sat Oct  1 08:28:48 2016 File:/home/root/azure-iot-gateway-sdk/modules/ble/src/bleio_seq_linux_schedule_write.c Func:schedule_write Line:125 BLEIO_gatt_write_char_by_uuid failed with 174.
Error: Time:Sat Oct  1 08:28:48 2016 File:/home/root/azure-iot-gateway-sdk/modules/ble/src/bleio_seq_linux.c Func:BLEIO_Seq_Destroy Line:224 Scheduling WRITE_AT_EXIT instruction at index 8 failed.
Info: Waiting for sequence to be destroyed...
Info: Done waiting for sequence to be destroyed.

so it seems the dive is connected but the uuids cant be passed to the device ?

darobs commented 7 years ago

We have a reproduction here, so we will be continuing to investigate this. I've also reached out to the module writer to see if he has steps to find the problem.

Thanks, Dave

darobs commented 7 years ago

Hello again @gerrik84, we're still looking into this. I did have some questions, if you don't mind:

What platform are you using? Which BLE device? We reproduced the problem, but we want to make sure what we find applies to your problem.

Also, something worth trying might be to run bluetoothctl and then run the list-attributes to cause the Bluetooth engine to cache the characteristics, i.e., there should be some output from list-attributes. After that g_tree_lookup() should be able to find the characteristics.

gerrik84 commented 7 years ago

Hello, as gateway i use a Intel Edison with a custom yocto image and bluez 5.34. On the sensor side i use TI CC2650 with FW Version 1.20. When i connect to my sensor on the bluetooth shell i can execute the list-attribute command but nothing is returned. When i try the same via gattool i get :

handle: 0x0002, char properties: 0x02, char value handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0004, char properties: 0x02, char value handle: 0x0005, uuid: 00002a01-0000-1000-8000-00805f9b34fb
handle: 0x0006, char properties: 0x02, char value handle: 0x0007, uuid: 00002a04-0000-1000-8000-00805f9b34fb
handle: 0x0009, char properties: 0x20, char value handle: 0x000a, uuid: 00002a05-0000-1000-8000-00805f9b34fb
handle: 0x000d, char properties: 0x02, char value handle: 0x000e, uuid: 00002a23-0000-1000-8000-00805f9b34fb
handle: 0x000f, char properties: 0x02, char value handle: 0x0010, uuid: 00002a24-0000-1000-8000-00805f9b34fb
handle: 0x0011, char properties: 0x02, char value handle: 0x0012, uuid: 00002a25-0000-1000-8000-00805f9b34fb
handle: 0x0013, char properties: 0x02, char value handle: 0x0014, uuid: 00002a26-0000-1000-8000-00805f9b34fb
handle: 0x0015, char properties: 0x02, char value handle: 0x0016, uuid: 00002a27-0000-1000-8000-00805f9b34fb
handle: 0x0017, char properties: 0x02, char value handle: 0x0018, uuid: 00002a28-0000-1000-8000-00805f9b34fb
handle: 0x0019, char properties: 0x02, char value handle: 0x001a, uuid: 00002a29-0000-1000-8000-00805f9b34fb
handle: 0x001b, char properties: 0x02, char value handle: 0x001c, uuid: 00002a2a-0000-1000-8000-00805f9b34fb
handle: 0x001d, char properties: 0x02, char value handle: 0x001e, uuid: 00002a50-0000-1000-8000-00805f9b34fb
handle: 0x0020, char properties: 0x12, char value handle: 0x0021, uuid: f000aa01-0451-4000-b000-000000000000
handle: 0x0023, char properties: 0x0a, char value handle: 0x0024, uuid: f000aa02-0451-4000-b000-000000000000
handle: 0x0025, char properties: 0x0a, char value handle: 0x0026, uuid: f000aa03-0451-4000-b000-000000000000
handle: 0x0028, char properties: 0x12, char value handle: 0x0029, uuid: f000aa21-0451-4000-b000-000000000000
handle: 0x002b, char properties: 0x0a, char value handle: 0x002c, uuid: f000aa22-0451-4000-b000-000000000000
handle: 0x002d, char properties: 0x0a, char value handle: 0x002e, uuid: f000aa23-0451-4000-b000-000000000000
handle: 0x0030, char properties: 0x12, char value handle: 0x0031, uuid: f000aa41-0451-4000-b000-000000000000
handle: 0x0033, char properties: 0x0a, char value handle: 0x0034, uuid: f000aa42-0451-4000-b000-000000000000
handle: 0x0035, char properties: 0x0a, char value handle: 0x0036, uuid: f000aa44-0451-4000-b000-000000000000
handle: 0x0038, char properties: 0x12, char value handle: 0x0039, uuid: f000aa81-0451-4000-b000-000000000000
handle: 0x003b, char properties: 0x0a, char value handle: 0x003c, uuid: f000aa82-0451-4000-b000-000000000000
handle: 0x003d, char properties: 0x0a, char value handle: 0x003e, uuid: f000aa83-0451-4000-b000-000000000000
handle: 0x0040, char properties: 0x12, char value handle: 0x0041, uuid: f000aa71-0451-4000-b000-000000000000
handle: 0x0043, char properties: 0x0a, char value handle: 0x0044, uuid: f000aa72-0451-4000-b000-000000000000
handle: 0x0045, char properties: 0x0a, char value handle: 0x0046, uuid: f000aa73-0451-4000-b000-000000000000
handle: 0x0048, char properties: 0x10, char value handle: 0x0049, uuid: 0000ffe1-0000-1000-8000-00805f9b34fb
handle: 0x004d, char properties: 0x0a, char value handle: 0x004e, uuid: f000aa65-0451-4000-b000-000000000000
handle: 0x004f, char properties: 0x0a, char value handle: 0x0050, uuid: f000aa66-0451-4000-b000-000000000000
handle: 0x0052, char properties: 0x1a, char value handle: 0x0053, uuid: f000ac01-0451-4000-b000-000000000000
handle: 0x0055, char properties: 0x0a, char value handle: 0x0056, uuid: f000ac02-0451-4000-b000-000000000000
handle: 0x0057, char properties: 0x0a, char value handle: 0x0058, uuid: f000ac03-0451-4000-b000-000000000000
handle: 0x005a, char properties: 0x12, char value handle: 0x005b, uuid: f000ccc1-0451-4000-b000-000000000000
handle: 0x005d, char properties: 0x08, char value handle: 0x005e, uuid: f000ccc2-0451-4000-b000-000000000000
handle: 0x005f, char properties: 0x08, char value handle: 0x0060, uuid: f000ccc3-0451-4000-b000-000000000000
handle: 0x0062, char properties: 0x1c, char value handle: 0x0063, uuid: f000ffc1-0451-4000-b000-000000000000
handle: 0x0066, char properties: 0x1c, char value handle: 0x0067, uuid: f000ffc2-0451-4000-b000-000000000000

After that i have the same behaviour....

darobs commented 7 years ago

Thank you, @gerrik84 - I've got our board reproducing something similar, although we have a slightly newer version of bluez.

darobs commented 7 years ago

Hi @gerrik84 - The problem is our code is reliant on the DBus-Bluez interface as defined in release 5.37. That interface has changed such that 5.34 isn't compatibly with our BLE module. We have tested and support BlueZ version 5.37, is it possible for you to update to 5.37?

I've also discovered we have a similar issue with 5.42. I've created a PBI in our backlog to do better discovery and find a better way to handle different versions of BlueZ.

As of this time, I don't have a better solution for you than to upgrade BlueZ to 5.37, and to tell you we've added the work to support other versions to our task queue.

Gerri84 commented 7 years ago

Hi, sorry that it took me so long to replay... at first thanks for your efforts. I changed the bluez version to 5.37 and unfortunately nothing changed, i get the same error again:

[NEW] Controller 58:A8:39:00:43:DB TransAM [default]
[NEW] Device B0:B4:48:EE:01:84 CC2650 SensorTag
[bluetooth]# exit
 {
      "module name": "SensorTag",
      "module path": "/home/root/azure-iot-gateway-sdk/build/modules/ble/libble_hl.so",
      "args": {
        "controller_index": 0,
        "device_mac_address": "B0:B4:48:EE:01:84",
        "instructions": [
          {
            "type": "read_once",
            "characteristic_uuid": "00002A24-0000-1000-8000-00805F9B34FB"
          },
          {
            "type": "read_once",
            "characteristic_uuid": "00002A25-0000-1000-8000-00805F9B34FB"
          },
          {
            "type": "read_once",
            "characteristic_uuid": "00002A26-0000-1000-8000-00805F9B34FB"
          }, .......

:~/azure-iot-gateway-sdk# ./build/samples/ble_gateway_hl/ble_gateway_hl ./samples/ble_gateway_hl/src/gateway_sample.json Gateway is running.

Error: Time:Fri Nov 11 13:32:32 2016 File:/home/root/azure-iot-gateway-sdk/modules/ble/src/ble_gatt_io_linux_connect.c Func:on_sequence_error Line:447 Connect failed with - Timeout was reached Error: Time:Fri Nov 11 13:32:32 2016 File:/home/root/azure-iot-gateway-sdk/modules/ble/src/ble.c Func:on_connect_complete Line:361 BLEIO_gatt_connect asynchronously failed