- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello folks,
I'm still working on the CY5677 dongle with the example linked by Madhu Sudhan (thanks to him) at: http://www.cypress.com/forum/proc-ble/cysmart-api-c-example?page=1
I got an issue wich is now solved as mentionned here : http://www.cypress.com/forum/proc-ble/cy5677-cc2650
I'm close to the end of my application but I'm stuck since a long time on an other issue which is notifications are never enable.
I tried to make it work with CYSMART and it's working nicely, same with a phone but never with this application. I tried to solve the issue with the same way Madhu Sudhan solved the last issue but never worked. I join you the code of the notify button :
private void Notify_Button_Click(object sender, System.EventArgs e)
{
AutoResetEvent sync = new AutoResetEvent(false);
CyApiErr err = CyApiErr.OK;
CharHandle = 0x0027;
CCCDHandle = 0x0028;
// Setup the descriptor write handler
GATTClientEventCallback.DescriptorWriteHandler = (CyConnectResult, status) =>
{
if (status != CyStatus.BLE_STATUS_OK)
err = new CyApiErr("Failed to Write: Reason: " + status.ToString());
sync.Set();
};
if (!(NotificationEnabled))
{
var NotifByte = new byte[1];
NotifByte = BitConverter.GetBytes(0x0001);
Array.Resize(ref NotifByte, 1);
// Initiate write descriptor request to the CCCD
err = GattClient.WriteDescriptor(new CyGattWriteInfo(CCCDHandle, NotifByte));
if (err.IsOK)
{
sync.WaitOne();
NotificationEnabled = true;
Notify_Button.Text = "Disable Notification";
}
}
else
{
var NotifByte = new byte[1];
NotifByte = BitConverter.GetBytes(0x0000);
Array.Resize(ref NotifByte, 1);
err = GattClient.WriteDescriptor(new CyGattWriteInfo(CCCDHandle, NotifByte ));
if (err.IsOK)
{
sync.WaitOne();
NotificationEnabled = false;
Notify_Button.Text = "Enable Notification";
}
}
}
Err is variable is ok when I debug so the transmission seems to be well but the principle of activation seems failed. With CySmart I'm able to write "01:00" or "0100" and it's working.
Plus I have a question about that on CySmart I can see what is on the joined picture. With characteristic which haven't notification mod I'm ok to write CharHandle and CCCDHandle nicely but with the notification characteristic I have 3 values as joined 0x0027 to 0x0029. What should I put where ?
Regards,
Guillaume
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I finally figured out what happened here. When we use the following line, an array of 4 bytes is created :
"err = GattClient.WriteDescriptor(new CyGattWriteInfo(CCCDHandle, BitConverter.GetBytes(0x0100)));"
To enable notification we see indeed 4 bytes on CySmart log "Value: [01:00]" BUT these 4 bytes are the printable of a byte in hexa form.
So we have to send an array of 2 bytes to enable notifications. Btw, the handle was indeed 0x0028.
Best regards,
Guillaume
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Double check the endianness of the data you are sending compared with the 01:00 value that you are writing into the cysmart app. (I found that the values I sent in code were opposite endianness of the cysmart applications display values)
0x0028 is the CCCD, so that would be 01:00 to enable notifications.
0x0029 is a characteristic to hold a string of data for "describing" the characteristic. Basically, it is a text field for names/tags/text iirc.
0x0027 I'm not sure what 0x0027 is. It looks like it might be related to the actual data itself? Like the characteristic that holds the data you want to be able to read/write. (I don't have a test unit in front of me atm)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello e.pratt_1639216,
Thank you about your answer.
All of what you said is right, I agree with you about the CCCD, it's making me more comfortable with my understanding about that.
I tried to write 0x0001 in the CCCD 0x0028 which is the data to enable notifications but it doesn't work. I checked if the issue didn't come from the notification event but it's not, the slave just never going into notification state even if the communication is going well so as you said it seems to come from the datas send. I tried to send inverted byte but didn't work too. I tried to replace the line "err = GattClient.WriteDescriptor(new CyGattWriteInfo(CCCDHandle, NotifByte));" by "err = GattClient.WriteDescriptor(new CyGattWriteInfo(CCCDHandle, BitConverter.GetBytes(0x0001)));" but same result: doesn't work.
Regards,
Guillaume
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you say "inverted the byte", you mean you tried 0x0100 as well as 0x0001 for descriptor values?
Fyi: The data for a BLE profile is only stored on one of the devices and has to be transmitted to the other device either with a notification, or with them reading the data. It could be a data mismatch between the Server and Client roles (I don't think so, but I'm not entirely sure the setup you have 🙂 )
The CySmart application should have a log of the data/actions it does, and you should be able to clear it, send the notification enable, and then save the log to see what commands/data is sent by the CySmart application to your dongle.
If you are able to "break" things a little, you could try writing 01:00 to each of the three handles to make sure you are using the correct handle as well 🙂
Since you know the other two applications work (CySmart and the Cy5672), it is merely a matter of figuring out what they are doing differently than you 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes I tried 0x0100, 0x0001 and 0x8000 but nothing worked.
You can be sure the roles Server and clients are correct because I'm developing an other application parallel which has the same role than the dongle CY5677 and it's working 😃
I saved the log and it's usefull, I'm certain about the handle now, I only have to find what to send to enable notification.
Thank you so much about your help, I will post here when I find the good way to do it. 😃
Regards,
Guillaume
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I finally figured out what happened here. When we use the following line, an array of 4 bytes is created :
"err = GattClient.WriteDescriptor(new CyGattWriteInfo(CCCDHandle, BitConverter.GetBytes(0x0100)));"
To enable notification we see indeed 4 bytes on CySmart log "Value: [01:00]" BUT these 4 bytes are the printable of a byte in hexa form.
So we have to send an array of 2 bytes to enable notifications. Btw, the handle was indeed 0x0028.
Best regards,
Guillaume
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Awesome!
Yeah, I haven't worked with the .GetBytes() function, so I skipped over it 😞
Good to see that you figured it out.