ble_write(unsigned char*); for BLE Shield - Red Bear Lab

I'm currently working on a project that involves the BLE Shield by Red Bear Labs and their BLE Controller application. I am trying to understand how the function ble_write(); operates. If I write something like ble_write('H'); it will output an H to the screen on my mobile devices.

My project involves outputting long and integer values to the mobile application. If I write something like:

int steps = 39;

if (ble_connected() )
{
 ble_write(steps);
 ble_do_events();
}

It will compile but it won't appear on the screen of the mobile device. From what I understand, ble_write(); is for unsigned chars yet it compiles fine with integers and longs.

What I am trying to do to me seems like it should be simple and I don't know if someone knows what I'd have to do to make integer and long values appear on the BLE Controller application.

What I am trying to do to me seems like it should be simple and I don't know if someone knows what I'd have to do to make integer and long values appear on the BLE Controller application.

Convert them to strings. sprintf() or itoa() look useful.

I'm assuming the library you're referring to is: GitHub - RedBearLab/nRF8001: Provides simple API for nRF8001 BLE chip.. I have no direct experience with that library but here's my guess. You're actually sending ASCII code 39 which is an apostrophe. So if you want to send the number 39 instead you probably need to convert to a string as PaulS said, try this:

int steps = 39;

if (ble_connected())
{
  char stepsString[6];  //Create a buffer for the conversion of steps to a char array. The maximum characters required to hold an int on an 8 bit microcontroller is 5 characters + null terminator.
  itoa(steps, stepsString, 10);  //convert steps to a char array
  ble_write_bytes(stepsString, strlen(stepsString) + 1);
  ble_do_events();
}

I don't have the hardware or the library installed so I can't test it.