Mrk 1010 BLE peripheral sent data(write value to characteristic ) but central can not receive

Here is my code ,with the same code ,my central devices can sent data to peripheral but not the other way around. Any one knows whats the problem?

 if (chatCharacteristic.written()) {
    if (chatCharacteristic.value()) {   // any value other than 0
      byte reading = 0 ;
      chatCharacteristic.readValue(reading);
      char read2= reading;  
      Serial.print(read2);
  }
}
while(Serial.available()>0){
 byte Byte = Serial.read();
chat2Characteristic.writeValue(Byte);
}

Please post the complete code for your peripheral and your central device. Make sure you use code tags properly.

You need three ' at the beginning and end for each sketch in the edit window? When you click on this icon </> you get.

```
type or paste code here
```

This ensures we can get all the source code. When you do this right, there should be a little icon in the top right corner of the sketch window that copies the code when you click on it.

Peripheral and central code looks very different, and some functions are not available.

I do not know how that should work. If the statement in if() knows the value, why would you need to use readValue.

You should not write the characteristics in a tight loop. Characteristics on peripheral devices are not pipes. They are more like variables. Peripherals do not send data you write to a characteristic. They make it available for central devices to read. So, the central device can miss a value when you write too often.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.