RadiantRVA
/
rbVectorIQ
share for RS
Fork of rbVectorIQ by
Diff: main.cpp
- Revision:
- 7:0db51a3107fc
- Parent:
- 6:074f5ec7428c
- Child:
- 8:e275405a431d
--- a/main.cpp Fri Dec 09 15:50:13 2016 +0000 +++ b/main.cpp Thu Dec 15 23:25:16 2016 +0000 @@ -55,6 +55,7 @@ #define PATTERN_SNOW 0x08 #define PATTERN_XMAS 0x09 #define PATTERN_ICE 0x0A +#define PATTERN_COL 0x0B #define LEDS_ON 0x01 #define LEDS_OFF 0x02 @@ -80,6 +81,8 @@ uint8_t blue = 159; uint8_t pattern = 0; +char mDeviceName[128]; + uint8_t LEDS_ON_FLAG = 0; // The Nordic UART Service @@ -95,12 +98,14 @@ GattCharacteristic rxCharacteristic (uart_rx_uuid, rxPayload, 1, TXRX_BUF_LEN, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY); GattCharacteristic *uartChars[] = {&txCharacteristic, &rxCharacteristic}; GattService uartService(uart_base_uuid, uartChars, sizeof(uartChars) / sizeof(GattCharacteristic *)); +void setup_advertising(void); void rainbowCycle(int wait, uint8_t numLEDs, neopixel_strip_t m_strip); void candyChase(int wait, uint8_t numLEDs, neopixel_strip_t m_strip); void snowflakes(int wait, uint8_t numLEDs, neopixel_strip_t m_strip); void iceflakes(int delay, uint8_t numLEDs, neopixel_strip_t m_strip); void xmas(int delay, uint8_t numLEDs, neopixel_strip_t m_strip); +void collegiate(int wait, uint8_t numLEDs, neopixel_strip_t m_strip); extern uint32_t ble_radio_notification_init(nrf_app_irq_priority_t irq_priority, nrf_radio_notification_distance_t distance, @@ -110,6 +115,7 @@ { neopixel_init(&m_strip, dig_pin_num, NUM_LEDS); neopixel_clear(&m_strip); + LEDS_ON_FLAG = 0; } void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params) @@ -119,6 +125,8 @@ //clear and remove strip //neopixel_clear(&m_strip); //neopixel_destroy(&m_strip); + //strcpy(mDeviceName, "RRVA Cntd"); + //setup_advertising(); ble.startAdvertising(); } @@ -239,6 +247,9 @@ else if (pattern == PATTERN_XMAS) xmas(200, NUM_LEDS, m_strip); + else if (pattern == PATTERN_COL) + collegiate(100, NUM_LEDS, m_strip); + else neopixel_clear(&m_strip); @@ -254,6 +265,25 @@ //APP_ERROR_CHECK(err_code); } +void setup_advertising(void) +{ + int length = strlen(mDeviceName); + + // setup advertising + ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED); + ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); + ble.accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME, + (const uint8_t *)&mDeviceName, length); + ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS, + (const uint8_t *)uart_base_uuid_rev, sizeof(uart_base_uuid)); + // 100ms; in multiples of 0.625ms. + //ble.setAdvertisingInterval(160); + ble.setAdvertisingInterval(80); + ble.addService(uartService); + ble.startAdvertising(); + //pc.printf("Advertising Start \r\n"); +} + int main(void) { //uint8_t led_error; @@ -274,20 +304,10 @@ //pc.format(8, SerialBase::None, 1); //pc.printf("rbChromaBand Init \r\n"); //pc.attach( uartCB , pc.RxIrq); + + strcpy(mDeviceName, "RRVA BLE"); - // setup advertising - ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED); - ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); - ble.accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME, - (const uint8_t *)"rbCtrl02", sizeof("rbCtrl02") - 1); - ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS, - (const uint8_t *)uart_base_uuid_rev, sizeof(uart_base_uuid)); - // 100ms; in multiples of 0.625ms. - //ble.setAdvertisingInterval(160); - ble.setAdvertisingInterval(80); - ble.addService(uartService); - ble.startAdvertising(); - //pc.printf("Advertising Start \r\n"); + setup_advertising(); while(1) { //pc.putc(pc.getc());