I don't think you can easily the supplied BLE stack, which is handling this notification. Why don't you create your own customer service, its not that complicated...
1 of 1 people found this helpful
David You should look at 100 PROJECTS IN 100 Days Ble #005. I will attach the program. It uses an ADC and sends data to CySmart and you can use any Cell Phone or the Dongle using the CYSmart Program. I am waiting for an answer from a Cypress engineer on the other forum issue #020 example.
Yes I was looking into that a little bit about the creating a custom profile/service, code is still a little confusing to me but im going to try to follow somewhat of a similar model to how the txpower profile looks, Thanks for input!
This looks like it will help a lot, thank you!
Part of what I have to do in the project as well though is going to have to graph the changing ADC through a terminal program. I have one written already though, which just takes in the number that comes in from the COM Port and graphs it versus time, so that is set.
It will be more so getting the PSoC to continuously sending the changing ADC value to the bluetooth dongle is issue. Thank you for getting this to me though! This will be useful.
I may have more questions a bit later but still, looks like this should get me on about the right track.
from what i am getting when using a custom service, when assigning the actual 16-bit adc value, it would go into the gatts handle as the command:
notificationhandle.value.val = &ADCVal;
where ADC value is the 16-bit ADC_GetResult16(CHANNEL);
I do have it set so notificationhandle.value.len = 2; as in two bytes of data (at least thats how i understand it)
however I am getting an error that says "incompatible pointer types assigning to uint8 from int16" So i am worried that when i test this out, it will not work, or it will not display the entire value (up to 2048). is there a reason that the value.val is always a uint8, or can that be changed?
Since 'notificationhandle.value.val' doesn't know anything about your data, it is just expecting a pointer to a byte array (which means uint8_t in C). Your ADCVal is probably an uint16_t, thats why the compiler complains aboutn incompatible bytes. You can just cast the pointer to uint8_t* and everything will be fine - this is just about the data format, not about the length.
(and on the receiving end, you need to do the reverse - you get a byte array and must parse it into a uint16)
If you could tell me if I have this correct:
On the peripheral side (The PSoC) that has a custom service char handle, the lines of code required to send it over to the dongle as notification would be as such:
uint16_t testval = 1234;
notificationhandle.attrHandle = customServiceCharHandle;
notificationhandle.value.len = 2;
notificationhandle.value.val = (uint8_t*) testval;
CyBle_GattsWriteAttributeValue(¬ificationhandle, 0u, NULL, CYBLE_GATT_DB_LOCALLY_INITIATED);
note on this part, it doesnt seem to recognize my custom handle, and gives a "use of undeclared identifier" error unless i declare it in main code with "CYBLE_GATT_DB_ATTR_HANDLE_T customServiceCharHandle;". I wasn't sure; would that be a problem? It is in the generated source BLE_Custom.h file, so that confuses me a little bit. I believe it would give a "customServiceCharhandle may be used uninitialized in this function" warning, which may be in part why value wont get sent. How would i fix this?
and on the receiving end of the stick (the dongle) to process the number that comes in and display it, would be something like:
<within the TPS Client Event handler (uint32 event, void *eventParam)>
printf("Notification received. Value read:%d dBm\r\n",(int8)(CharValue.value->val));
I do ensure that the device is connected and notifications are enabled, but I am guessing that there is something that has to be changed or I am missing something on the receiving end, in order for it to display "Value read: 1234" If the custom service handle is set and recognized correctly, what could be the reason for it not being able to read that value?
Another part wanted to add was this
CYBLE_CONN_HANDLE_T connHandle; /* Connection handle */
CYBLE_TPS_CHAR_INDEX_T charIndex; /* Characteristic index */
CYBLE_GATT_VALUE_T *value; /* Pointer */
And i thought, if i created a custom structure that would get only the testval, it could work, however I am having trouble understanding the charIndex. What would I need to utilize to get the value to send?
client-server-testval.zip 5.9 MB
I suggest looking at the AppNote explaining how to create a custom service (http://www.cypress.com/file/140826/download ).
the attribute handle is a constant thats created from your service definition, and follows the pattern CYBLE_SERVICENAME_CHARACTERISTICNAME_CHAR_HANDLE .
I cannot help with the receiving end since I never used that (my client was an Android device). But probably the 100 BLE example projects might help you further with that.
Would it be perhaps that the client would need to have a custom service that matches that of the custom service handle in the peripheral server?
Say the server is what has the 0 to 2048 number with its own handle/attribute. Would in turn, the receiver need to have a handle/attribute that matches that of the peripheral in order to recognize it?
Yes, of course the client needs to know the service that the BLE device is using. If the client is also a sPSoC BLE, the could copy over the BLE component to its project, and just swap the roles. Otherwise the cliebnt just needs to know the correct UUIDs for all services and characteristics.
ah alright now its starting to make sense. Going to give it a try and see if this works, thanks! Ill update as I continue developing programs