LTE_BLE_Gateway read and write in characteristic

Hello,

I would like to know if it is possible to provide an example based on the lte_ble_gateway sample for writing and reading the characteristic!

I changed the example and I'm connecting with an nRF52840, but I'm not able to write or read the characteristics.

I noticed that many people also have difficulty in incrementing this in the example, so I think it would be very useful if they could demonstrate this in an example, most topics about this tell the user to base themselves on the nus_client example, but it's not that trivial, the code bases are very different and even based on this code I could not implement it successfully.

The tutorial in the link below demonstrates very well how to perform this implementation based on NUS, but I find a lot of incompatibility when I try to implement the functionality described in the tutorial for the lte_ble_gateway sample. Is it possible to implement this functionality in the sample? Could you give a very brief example of writing and reading the characteristics?

 Building a Bluetooth application on nRF Connect SDK - Contrasting to SoftDevice - Part 2 Central role 

I'm using NCS 2.0.0 and nRF9160DK!

Thank you.

Parents
  • Hi 

    Are there any particular issues you are experiencing when trying to add the NUS code into the lte_ble_gateway example? 

    I can try to make this change on my end, but I won't be able to do this until next week at the earliest. 

    Best regards
    Torbjørn

  • Hello Torbjørn,

    I spent a few days trying to get this integration to work but without success, I'll try to briefly explain the problems encountered!

    1 - Using the LTE_BLE_Gateway example, I was able to connect with the device and identify its service and its characteristics but I could not evolve more than that, I could not write in the characteristics and also I could not enable notification, the errors that appeared were circumvented but simply nothing happened when trying to send commands.

    My goal was just to modify this example to achieve what I want, but I don't see any support for this for this sample, most tickets with this same intention are just answered with "Look at the central_uart sample". So I decided to try to implement the central_uart in ble.c from the BLE_LTE_Gateway sample.

    2 - Implementing the central_uart in ble.c of LTE_BLE_Gateway, I managed to get to the same point, I can connect, identify the service and the characteristics but I can't send data or activate the notification to receive data through the characteristics.

    The first problem is related to uart_init! If I call this function I get "uart init failed to start (err -134)" my uart_0 is active in dts, alias I get the logs through this uart, but I can't do the init, consequently if I try to send something through uart via TeraTerm, I simply get "ERROR".

    As this is not my main objective, I decided to follow and try to send data manually, through the commands below:

        uint8_t send[1] = {0x02};
    
    	uint16_t sizeofsend = (uint16_t)sizeof(send);
    
    	err = bt_nus_client_send(&nus_client, send, sizeofsend);
    		if (err) {
    			LOG_WRN("Failed to send data over BLE connection"
    				"(err %d)", err);
    		}

    I tried to use this simple function in several places, but every time I call to send data the device is reset.

    To facilitate your analysis and support, I am attaching the firmware I am working on. Really I would be very grateful if you could give me a working example to write in a certain characteristic! Most examples only demonstrate the communication between DK's with everything happening automatically, with firmware designed for demonstration, which makes it difficult to visualize ways to write and read characteristics of custom boards.

    lte_ble_gateway.7z

    Thank you.

  • Hello,

    I have updates!

    I tried to use this simple function in several places, but every time I call to send data the device is reset.

    This can be resolved if I exclude gatt_discover(conn) from inside the connected function. I had to add this line because gatt_discover is never called with the default code. This shouldn't happen right?

    When I leave the call to gatt_discover inside the connected function, I can guarantee that the function is called because I can read the service of the device that connected me, see below:

    [00:00:01.351,287] <inf> lte_ble_gw: Scanning successfully started
    [00:00:01.365,203] <inf> lte_ble_gw: Filters matched. Address: C1:47:F5:93:8A:D6 (random) connectable: 1
    [00:00:01.378,784] <inf> lte_ble_gw: Filters matched. Address: C1:47:F5:93:8A:D6 (random) connectable: 0
    [00:00:01.378,814] <wrn> lte_ble_gw: Connecting failed
    [00:00:01.469,024] <inf> lte_ble_gw: Connected: C1:47:F5:93:8A:D6 (random)
    ATT[1]:         UUID: 0x2803    Handle: 0x0011  Value:
            Characteristic: 0xd3ed1001-6869-7abd-c849-7c46f3c03588  Properties: 0x0010
    ATT[2]:         UUID: 0xd3ed1001-6869-7abd-c849-7c46f3c03588    Handle: 0x0012  Value:
    ATT[3]:         UUID: 0x2902    Handle: 0x0013  Value:
            CCCD
    ATT[4]:         UUID: 0x2803    Handle: 0x0014  Value:
            Characteristic: 0xd3ed1002-6869-7abd-c849-7c46f3c03588  Properties: 0x000C
    ATT[5]:         UUID: 0xd3ed1002-6869-7abd-c849-7c46f3c03588    Handle: 0x0015  Value:
    [00:00:01.670,043] <inf> lte_ble_gw: MTU exchange done
    [00:00:02.369,964] <inf> lte_ble_gw: Service discovery completed

    If I remove the gatt_discover I added, the device doesn't restart when I try to send data, but it doesn't run the gatt_discover function either. But I still have problems and I can't send data through ble. I get the following error: Failed to send data over BLE connection(err -128). This is related to socket not connected, but before receiving this I get two connection messages, one that fails and one that I succeed in the connection, so I think that's what is causing the problem. But I don't understand and I can't identify why two simultaneous connection requests are issued. Below we can see the LOG recording the aforementioned connection requests.

    [00:00:01.339,141] <inf> lte_ble_gw: Scan module initialized
    [00:00:01.339,172] <inf> lte_ble_gw: NUS Client module initialized
    [00:00:01.355,804] <inf> lte_ble_gw: Scanning successfully started
    [00:00:01.502,044] <inf> lte_ble_gw: Filters matched. Address: C1:47:F5:93:8A:D6 (random) connectable: 1
    [00:00:01.515,838] <inf> lte_ble_gw: Filters matched. Address: C1:47:F5:93:8A:D6 (random) connectable: 0
    [00:00:01.515,869] <wrn> lte_ble_gw: Connecting failed
    [00:00:01.606,201] <inf> lte_ble_gw: Connected: C1:47:F5:93:8A:D6 (random)
    [00:00:01.807,159] <inf> lte_ble_gw: MTU exchange done
    [00:00:10.515,136] <wrn> lte_ble_gw: Failed to send data over BLE connection(err -128)

    Regarding the UART, I had no evolution, I keep getting just an ERROR when trying to send commands through TeraTerm!

    Thank you. 

Reply
  • Hello,

    I have updates!

    I tried to use this simple function in several places, but every time I call to send data the device is reset.

    This can be resolved if I exclude gatt_discover(conn) from inside the connected function. I had to add this line because gatt_discover is never called with the default code. This shouldn't happen right?

    When I leave the call to gatt_discover inside the connected function, I can guarantee that the function is called because I can read the service of the device that connected me, see below:

    [00:00:01.351,287] <inf> lte_ble_gw: Scanning successfully started
    [00:00:01.365,203] <inf> lte_ble_gw: Filters matched. Address: C1:47:F5:93:8A:D6 (random) connectable: 1
    [00:00:01.378,784] <inf> lte_ble_gw: Filters matched. Address: C1:47:F5:93:8A:D6 (random) connectable: 0
    [00:00:01.378,814] <wrn> lte_ble_gw: Connecting failed
    [00:00:01.469,024] <inf> lte_ble_gw: Connected: C1:47:F5:93:8A:D6 (random)
    ATT[1]:         UUID: 0x2803    Handle: 0x0011  Value:
            Characteristic: 0xd3ed1001-6869-7abd-c849-7c46f3c03588  Properties: 0x0010
    ATT[2]:         UUID: 0xd3ed1001-6869-7abd-c849-7c46f3c03588    Handle: 0x0012  Value:
    ATT[3]:         UUID: 0x2902    Handle: 0x0013  Value:
            CCCD
    ATT[4]:         UUID: 0x2803    Handle: 0x0014  Value:
            Characteristic: 0xd3ed1002-6869-7abd-c849-7c46f3c03588  Properties: 0x000C
    ATT[5]:         UUID: 0xd3ed1002-6869-7abd-c849-7c46f3c03588    Handle: 0x0015  Value:
    [00:00:01.670,043] <inf> lte_ble_gw: MTU exchange done
    [00:00:02.369,964] <inf> lte_ble_gw: Service discovery completed

    If I remove the gatt_discover I added, the device doesn't restart when I try to send data, but it doesn't run the gatt_discover function either. But I still have problems and I can't send data through ble. I get the following error: Failed to send data over BLE connection(err -128). This is related to socket not connected, but before receiving this I get two connection messages, one that fails and one that I succeed in the connection, so I think that's what is causing the problem. But I don't understand and I can't identify why two simultaneous connection requests are issued. Below we can see the LOG recording the aforementioned connection requests.

    [00:00:01.339,141] <inf> lte_ble_gw: Scan module initialized
    [00:00:01.339,172] <inf> lte_ble_gw: NUS Client module initialized
    [00:00:01.355,804] <inf> lte_ble_gw: Scanning successfully started
    [00:00:01.502,044] <inf> lte_ble_gw: Filters matched. Address: C1:47:F5:93:8A:D6 (random) connectable: 1
    [00:00:01.515,838] <inf> lte_ble_gw: Filters matched. Address: C1:47:F5:93:8A:D6 (random) connectable: 0
    [00:00:01.515,869] <wrn> lte_ble_gw: Connecting failed
    [00:00:01.606,201] <inf> lte_ble_gw: Connected: C1:47:F5:93:8A:D6 (random)
    [00:00:01.807,159] <inf> lte_ble_gw: MTU exchange done
    [00:00:10.515,136] <wrn> lte_ble_gw: Failed to send data over BLE connection(err -128)

    Regarding the UART, I had no evolution, I keep getting just an ERROR when trying to send commands through TeraTerm!

    Thank you. 

Children
No Data
Related