Redbear Nano firmware using Sandroide and showing how to send custom strings and parameters to the Android application
Dependencies: BLE_API MbedJSONValue mbed nRF51822
Fork of BLE_RedBearNano-SAndroidEDevice by
Diff: main.cpp
- Revision:
- 3:16b7d807fa8c
- Parent:
- 2:6c45738bba43
- Child:
- 4:2ef9b332fa7c
diff -r 6c45738bba43 -r 16b7d807fa8c main.cpp --- a/main.cpp Mon Jul 24 09:36:09 2017 +0000 +++ b/main.cpp Thu Oct 05 15:00:10 2017 +0000 @@ -77,14 +77,14 @@ AnalogIn analogs[] = {P0_1, P0_2, P0_3, P0_4, P0_5, P0_6}; int mapAnalogs[] = {-1, 0, 1, 2, 3, 4, 5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; - - void enqueueItem(Queue *queue, uint8_t *buf, int len) { - NODE *item = NULL; - item = (NODE*) malloc(sizeof (NODE)); - memcpy(item->data.payload, buf, len); - item->data.length = len; - Enqueue(queue, item); + if (ble.getGapState().connected) { + NODE *item = NULL; + item = (NODE*) malloc(sizeof (NODE)); + memcpy(item->data.payload, buf, len); + item->data.length = len; + Enqueue(queue, item); + } } void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params) @@ -470,16 +470,6 @@ void changeGcdTiming(){ - /*if (gcdChanged) { - gcdChanged =false; - if (gcd>0) { - pTicker->attach(NULL,5); - pTicker->attach(triggerSensor, 0.001*gcd); - } else { - pTicker->attach(NULL,5); - } - }*/ - uint8_t buf[TXRX_BUF_LEN]; int len = sprintf((char *)buf,"check-gcd %d",gcd); enqueueItem(toSendQueue, buf, len); @@ -498,11 +488,6 @@ pinGroups[i]=NO_GROUP; } - initPin(7,PIN_OUTPUT); - initPin(28,PIN_OUTPUT); - writeDigital(7,true); - writeDigital(28,false); - ble.init(); ble.onDisconnection(disconnectionCallback); ble.onDataWritten(WrittenHandler);