SimpleControls works with the BLEController iOS/Android App. The mbed's pin can acts as DIGITAL_IN, DIGITAL_OUT, PWM, SERVO, ANALOG_IN. The sketch is to show you how to control the pin as one of the abilities.
Dependencies: BLE_API mbed nRF51822
Fork of BLENano_SimpleControls by
Revision 4:dbf70068b442, committed 2016-11-09
- Comitter:
- drkangel
- Date:
- Wed Nov 09 17:58:13 2016 +0000
- Parent:
- 3:f530ca03e014
- Commit message:
- simple test for SAndroide
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f530ca03e014 -r dbf70068b442 main.cpp --- a/main.cpp Thu Jan 07 02:43:53 2016 +0000 +++ b/main.cpp Wed Nov 09 17:58:13 2016 +0000 @@ -28,6 +28,7 @@ #define TXRX_BUF_LEN 20 +#define DIGITAL_LED_OUT_PIN P0_19 #define DIGITAL_OUT_PIN P0_9 //TXD #define DIGITAL_IN_PIN P0_10 //CTS #define PWM_PIN P0_11 //RXD @@ -36,7 +37,8 @@ BLE ble; -DigitalOut LED_SET(DIGITAL_OUT_PIN); +DigitalOut LED_SET(DIGITAL_LED_OUT_PIN); +DigitalOut OUT_SET(DIGITAL_OUT_PIN); DigitalIn BUTTON(DIGITAL_IN_PIN); PwmOut PWM(PWM_PIN); AnalogIn ANALOG(ANALOG_IN_PIN); @@ -82,6 +84,7 @@ { uint8_t buf[TXRX_BUF_LEN]; uint16_t bytesRead; + if (Handler->handle == txCharacteristic.getValueAttribute().getHandle()) { @@ -99,6 +102,13 @@ else LED_SET = 0; } + else if(buf[0] == 0x05) + { + if(buf[1] == 0x01) + OUT_SET = 1; + else + OUT_SET = 0; + } else if(buf[0] == 0xA0) { if(buf[1] == 0x01) @@ -184,6 +194,7 @@ int main(void) { + Ticker ticker; ticker.attach_us(m_status_check_handle, 200000);