Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Data-Management-Honka
Diff: BluetoothComm.cpp
- Revision:
- 10:235c0b81c4c7
- Parent:
- 7:d4a32c830e11
- Child:
- 11:56bd3affbbfc
diff -r 57d988783b45 -r 235c0b81c4c7 BluetoothComm.cpp --- a/BluetoothComm.cpp Wed Feb 25 21:59:38 2015 +0000 +++ b/BluetoothComm.cpp Thu Mar 05 23:47:46 2015 +0000 @@ -215,7 +215,7 @@ * @author Michael Ling * @date 2/4/2015 */ -void BluetoothComm::send_values(char* paramList) +void BluetoothComm::send_values(char* paramList, short *dataOut) { char msg[2*_numVars+6]; int len=2; @@ -252,6 +252,17 @@ for (int j = 0; j < len; j++) { //printf("Sending char %x \r\n", msg[j]); _rn42.putc(msg[j]); + + } + if (dataOut != NULL) { + int j; + for (j = 0; j < len-1; j+=2) { + dataOut[j] = (msg[j]<<8)|msg[j+1]; + } + if (j < len) { + dataOut[j] = msg[j] << 8; + } + } memcpy(_lastCmd, msg, 50); free(checksum); @@ -479,7 +490,7 @@ send_read_only_values(); } printf("About to send PARAMLIST\r\n"); - send_values(paramList); + send_values(paramList, NULL); } /** @@ -489,7 +500,7 @@ * @author Michael Ling * @date 2/4/2015 */ -void BluetoothComm::process_write(char* message, int len) +void BluetoothComm::process_write(char* message, int len, short* dataOut) { if (message[2] == END) { _failures += 1; @@ -500,6 +511,7 @@ } return; } + //dataOut = message; if (!msg_check(message, len)) { printf("msg_check failed on write! \r\n"); return; @@ -519,7 +531,7 @@ //printf("Wrote %x to index %d of localValues \r\n", localValues[index], index); } - send_values(paramList); + send_values(paramList, dataOut); write_params_to_sd_card(); //SD_Card.write(localValues) //sendToControlBed(localValues+1, len-2) @@ -532,7 +544,7 @@ * @author Michael Ling * @date 2/4/2015 */ -void BluetoothComm::process (char* message, int len) +void BluetoothComm::process (char* message, int len, short* dataOut) { char c = message[2]; for (int i =0; i < len; i++) { @@ -547,7 +559,7 @@ process_read(message, len); return; } else { - process_write(message, len); + process_write(message, len, dataOut); return; } } @@ -558,7 +570,7 @@ * @author Michael Ling * @date 2/4/2015 */ -void BluetoothComm::attachment() +void BluetoothComm::attachment(short* dataOut) { boardLed1 = !boardLed1; // pc.printf("Entered attachment\r\n"); @@ -584,7 +596,7 @@ _counter = 0; memset(_curMsg, 0, 50); _rn42.rxBufferFlush(); - process(_msg, _len); + process(_msg, _len, dataOut); _len = 0; } else if (_inMsg || _counter > 0 ) { // printf("_inMsg or _counter > 0 \r\n"); @@ -600,7 +612,7 @@ memcpy(_msg, _curMsg, 50); memset(_curMsg, 0, 50); _rn42.rxBufferFlush(); - process(_msg, _len); + process(_msg, _len, dataOut); _len = 0; } }