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?

Parents
  • 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
    
    }
    
Reply
  • 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
    
    }
    
Children
No Data
Related