EDIT: I used a workaround to get my project working but my question still remains. I just used the template project to send data to my app and manipulated the received data inside the app. I must say I was quite disappointed by community support.
Hello there,
I have successfully implemented a working prototype for my project using an example project (nrf-ble-mpu-simple) posted in this answer. I'm using a Waveshare BLE400 board flashed with S130_nRF51_2.0.1 which works perfectly with "pca10028" projects. I also modified the main code a bit so that I can calibrate the MPU by calculating and subtracting offset errors and I represented the raw accelerometer value in terms of g. I also attempted to send the modified accelerometer values over BLE and that's where I failed.
I need to receive the accelerometer values over BLE using an Android application and the app looks for a char array with size of 18 to parse properly (6 data for each axis i.e. 1.0400 or -0.354). I was able to easily send char array data over BLE using Arduino 101 so that's why I made the app to look for a char array.
My question is that, how can I modify the sample project so that it sends a char array with 18 elements over BLE?
I already defined a custom struct in app_mpu.h that contains axis data with char arrays (holds the data correctly)
typedef struct {
char z[6];
char y[6];
char x[6];
}accCharStruct;
and a custom function in ble_mpu.c to hopefully send the data over (doesn't work, all I get from BLE using nRF Connect App is (0x) 00-00-00-00-00-00; my own app just crashes when it receives data)
void bleUpdateChar(ble_mpu_t *p_mpu, accCharStruct *accChar){
if(p_mpu->conn_handle != BLE_CONN_HANDLE_INVALID){
uint16_t len = sizeof(accChar);
ble_gatts_hvx_params_t hvx_params;
memset(&hvx_params, 0, sizeof(hvx_params));
hvx_params.handle = p_mpu->accel_char_handles.value_handle;
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
hvx_params.offset = 0;
hvx_params.p_len = &len;
hvx_params.p_data = (uint8_t*)accChar;
}
}
and of course I added the definition of the function to header file ble_mpu.h.
void bleUpdateChar(ble_mpu_t *p_mpu, accCharStruct *accChar);
As I'm not an experienced C programmer and it has been about a month since I began using an nRF51822 product so I didn't have much time to practice; I'm sorry if I made some fundamental mistake.
Thanks in advance.