- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have a kind of heretic question to "Cypressers". I'm actually developping a ble connection between a sensor and a master dongle.
(I'm unable to create this topic at one time so the following is on the next answer, sorry about that)
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Can you please modify the write button click code as follows:
private void Write_Button_Click(object sender, EventArgs e)
{
AutoResetEvent sync = new AutoResetEvent(false);
CyApiErr err = CyApiErr.OK;
// Setup the descriptor write handler
GATTClientEventCallback.CharacteristicWriteHandler = (CyConnectResult, status) =>
{
if (status != CyStatus.BLE_STATUS_OK)
err = new CyApiErr("Failed to Write: Reason: " + status.ToString());
sync.Set();
};
var WriteByte = new byte[1];
WriteByte = BitConverter.GetBytes(int.Parse(WriteTextBox.Text, System.Globalization.NumberStyles.HexNumber));
Array.Resize(ref WriteByte, 1);
// Initiate write descriptor request to the CCCD
err = GattClient.WriteCharacteristic(new CyGattWriteInfo(CharHandle, WriteByte));
if (err.IsOK)
{
sync.WaitOne();
}
else
{
MessageBox.Show ("Write Failed: Reason :"+err.ToString());
}
}
Regards,
-Madhu Sudhan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My sensor is a CC2650 component but my master is the CY5677 dongle. I'm able to read datas from this sensor from an android application but I'm unable to read it from the dongle with the project linked by Madhu Sudhan (thank to him) at: http://www.cypress.com/forum/proc-ble/cysmart-api-c-example?page=1
I tried to read it from CySmart and it works I have what is show in the attached picture.
So in the goal to be able to write on this characteristic with the example given I changed the CharHandle and the CCCDHandle to :
ushort CharHandle = 0x001E;
ushort CCCDHandle = 0x001F;
But when I launch it I'm able to read it but not write on this characteristic. When I clic on Write, I can see on the debugger the error is : BLE_ERROR_GATT_INVALID_ATTRIBUTE_LEN. I tried to write "A", "4" and "04" but nothing worked.
Does someone can help me with it ? I read the good value so it seems I'm reading the good characteristic but I'm able to write on it with the android application but not with this application, why ?
Best regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Can you please modify the write button click code as follows:
private void Write_Button_Click(object sender, EventArgs e)
{
AutoResetEvent sync = new AutoResetEvent(false);
CyApiErr err = CyApiErr.OK;
// Setup the descriptor write handler
GATTClientEventCallback.CharacteristicWriteHandler = (CyConnectResult, status) =>
{
if (status != CyStatus.BLE_STATUS_OK)
err = new CyApiErr("Failed to Write: Reason: " + status.ToString());
sync.Set();
};
var WriteByte = new byte[1];
WriteByte = BitConverter.GetBytes(int.Parse(WriteTextBox.Text, System.Globalization.NumberStyles.HexNumber));
Array.Resize(ref WriteByte, 1);
// Initiate write descriptor request to the CCCD
err = GattClient.WriteCharacteristic(new CyGattWriteInfo(CharHandle, WriteByte));
if (err.IsOK)
{
sync.WaitOne();
}
else
{
MessageBox.Show ("Write Failed: Reason :"+err.ToString());
}
}
Regards,
-Madhu Sudhan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
It's working perfectly, thank you Madhu Sudhan !
Regards,
John