- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The code immediately below works fine. The value "5" is successfully written to the characteristic:
uint8 tilt_0 = 5;
tilt_0_Handle.attrHandle = CYBLE_MYSERVICE_TILT_0_CHAR_HANDLE;
tilt_0_Handle.attrHandle.value.val = (uint8 *)&tilt_0;
tilt_0_Handle.attrHandle.value.len = 1;
CyBle_GattsWriteAttributeValue(&tilt_0_Handle, 0, NULL, CYBLE_GATT_DB_LOCALLY_INITITATED);
CyBle_GattsWriteRsp(connectionHandle);
But when the following substitution is made for the value "5" in the first line, the value of the pin (which can be either 1 or 0) is not written to the characteristic:
uint8 tilt_0 = MyDigitalInputPin_Read();
I've also tried writing the output values from the scanning comparator with no success.
Am I using the wrong data type for the pin read?
Thanks.
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your response. It was a timing issue. You are right, I was running the code in an isr. The pin was always reading 0 because I didn't give the light sensitive transistor switch (which the pin was reading) enough time to turn completely on. I powered up the transistor well before calling the isr and the switch read fine. Thanks for your comments.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Pin_Read() should return a uint8 from what I see in the PSOC Creator. My guess would be that it is reading the pin, but the value is not what you expect? Or if you are running the code in an isr, then it is taking too long to run, causing issues?
Maybe try reading the pin value, and buffering it to a value in main, and then send the buffered value in the response?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your response. It was a timing issue. You are right, I was running the code in an isr. The pin was always reading 0 because I didn't give the light sensitive transistor switch (which the pin was reading) enough time to turn completely on. I powered up the transistor well before calling the isr and the switch read fine. Thanks for your comments.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Glad you figured it out; you're welcome
Pratt