This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

s110/s120 send/receive data

Hello! Working with nrf51822 as s110/s120 device. Can anyone tell me, how can I receve/send data via Blue Tooth?

  • I have the same problem. How do the send/recieve function look like? In the n-AN36 its explained how to set up a service and characteristic but not how the code looks for sending/recieving....

  • If you haven't already done so, you should download the SDK and peruse the examples. There are many examples of standard profiles implemented that send and receive data. For example, if you go to the following path in the SDK you can find a bunch of standard profile examples: nrf51_sdk_v6_0_0_43681\nrf51822\Board\nrf6310\s110

  • yes, where are many examples, but I need multipurpose function like a send(char * bytes, int length) to send data.

  • There is no general function like send(char * bytes, int length) as you say. The nan-36 paper is good starting point to understanding how to transmit data between devices. When you have created a service with characteristics, you can perform five operations on the characteristics: write, write without response, read, notify, and indicate.

    For example, your s120 device can write data to a characteristic in your s110 device, or the s110 device can notify the s120 of a change in a characteristic.

    You can find examples of this in the SDK as John pointed out, or you can check out the documentation which lists all the functions you need. Here you can read about the write function for example: https://devzone.nordicsemi.com/documentation/nrf51/6.0.0/s120/html/a00534.html#ga90298b8dcd8bbe7bbe69d362d1133378

    If you want a function like send(char * bytes, int length), you would have to write it yourself. In the s120 device it would look something like this:

    void send(uint8_t* bytes, int length){	
    
        ble_gattc_write_params_t write_params;
    
        write_params.write_op = BLE_GATT_OP_WRITE_REQ; 
        write_params.handle   = value_handle; // This needs to be the value handle of the char you want to write to
        write_params.offset   = 0;
        write_params.len      = length;
        write_params.p_value  = bytes;
    
        err_code = sd_ble_gattc_write(conn_handle, &write_params);
        //conn handle must be the connection handle to the device you want to  write to
    
    }
    
Related