- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
(disclosure: I followed the capsense tutorial to get my original code working)
I'm able to successfully send single int values from my app to the BLE device. This is easy enough taken from the example code:
func writeLedCharacteristic(var val: Int8) {
let ns = NSData(bytes: &val, length: sizeof(Int8))
capsenseLedBoard!.writeValue(ns, forCharacteristic: ledCharacteristic, type: CBCharacteristicWriteType.WithResponse)
}
I updated my BLE custom profile for the led characteristic so that it now looks like this (see Download IMG_0327.jpg):
Really only changed the type to uint16
so that it would accept more characters. My rational here was that the capsense characteristic needed to be of type uint16
since more than a single bit was going through. If you can't tell already I'm extremely new to this.
Next I updated my iOS code to try and send the data like this:
let string = "hello"
let bytes: [UInt8] = Array(string.utf8)
let data = NSData(bytes: bytes, length: bytes.count)
capsenseLedBoard!.writeValue(data, forCharacteristic: ledCharacteristic, type: CBCharacteristicWriteType.WithResponse)
I have updated my PSoC code to look like this:
/* only update the value and write the response if the requested write is allowed */
if(CYBLE_GATT_ERR_NONE == CyBle_GattsWriteAttributeValue(&wrReqParam->handleValPair, 0, &cyBle_connHandle, CYBLE_GATT_DB_PEER_INITIATED))
{
UART_UartPutString("did get write request LED");
char t = wrReqParam->handleValPair.value.val[0];
CyBle_GattsWriteRsp(cyBle_connHandle);
UART_UartPutChar(t);
//red_Write(!wrReqParam->handleValPair.value.val[0]);
}
When I run and test my code I don't even get acknowledgement that the iOS device sent anything..aka this is never spit out in HyperTerminal:
UART_UartPutString("did get write request LED");
My initial thought was that I was encoding was wrong so tried changing the led Custom Characteristic type to uint8
how that is still not working!
The other issue is that from what I can tell I should be getting a char
array from this line handleValPair.value.val[0]
in PSoC however I'm not sure how exactly to extract that into an array.
Again, I'm extremely new to this lower level stuff, my C
is amateur at best. Any help is very much appreciated!!
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you tried our 100 projects in 100 days Ble? you may find some examples there that do what you need. Also for more training look at the video training examples on this site. Post your project so we can check it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Shameless bump 😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you tried our 100 projects in 100 days Ble? you may find some examples there that do what you need. Also for more training look at the video training examples on this site. Post your project so we can check it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I appreciate your response! I've looked through a bunch of them and see nothing about sending a string from smartphone to the ble device. Perhaps I missed it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
handleValPair.value.val[0] is just the bit used to turn on or off the LED.