Kris Scholte Lubberink
/
SSS_Ble
Ble for smart sOlutions
source/main.cpp@11:d6ed1437c2ee, 2019-06-20 (annotated)
- Committer:
- kris@kris-X682X
- Date:
- Thu Jun 20 13:20:24 2019 +0200
- Revision:
- 11:d6ed1437c2ee
- Parent:
- 10:d845189d146e
Refactored
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
krissl | 0:fe5389573740 | 1 | /* mbed Microcontroller Library |
krissl | 0:fe5389573740 | 2 | * Copyright (c) 2006-2014 ARM Limited |
krissl | 0:fe5389573740 | 3 | * |
krissl | 0:fe5389573740 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
krissl | 0:fe5389573740 | 5 | * you may not use this file except in compliance with the License. |
krissl | 0:fe5389573740 | 6 | * You may obtain a copy of the License at |
krissl | 0:fe5389573740 | 7 | * |
krissl | 0:fe5389573740 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
krissl | 0:fe5389573740 | 9 | * |
krissl | 0:fe5389573740 | 10 | * Unless required by applicable law or agreed to in writing, software |
krissl | 0:fe5389573740 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
krissl | 0:fe5389573740 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
krissl | 0:fe5389573740 | 13 | * See the License for the specific language governing permissions and |
krissl | 0:fe5389573740 | 14 | * limitations under the License. |
krissl | 0:fe5389573740 | 15 | */ |
krissl | 0:fe5389573740 | 16 | |
krissl | 0:fe5389573740 | 17 | #include <events/mbed_events.h> |
krissl | 0:fe5389573740 | 18 | #include <mbed.h> |
krissl | 0:fe5389573740 | 19 | #include "ble/BLE.h" |
krissl | 0:fe5389573740 | 20 | #include "ble/Gap.h" |
krissl | 0:fe5389573740 | 21 | #include "GattCallbackParamTypes.h" |
krissl | 1:9fc54848a198 | 22 | #include "mbed.h" |
krissl | 1:9fc54848a198 | 23 | #include "ColorService.h" |
kris@kris-X682X | 6:ee9c86f06eae | 24 | #include "BleDeviceCentral.h" |
kris@kris-X682X | 6:ee9c86f06eae | 25 | #include "BleDevicePeripheral.h" |
kris@kris-X682X | 10:d845189d146e | 26 | #include "MyStripSingleton.h" |
kris@kris-X682X | 6:ee9c86f06eae | 27 | #define MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED true |
kris@kris-X682X | 10:d845189d146e | 28 | MyStripSingleton* MyStripSingleton::instance = 0; |
kris@kris-X682X | 6:ee9c86f06eae | 29 | |
krissl | 0:fe5389573740 | 30 | int main() |
krissl | 0:fe5389573740 | 31 | { |
kris@kris-X682X | 6:ee9c86f06eae | 32 | BLE& ble = BLE::Instance(); |
kris@kris-X682X | 6:ee9c86f06eae | 33 | events::EventQueue queue; |
kris@kris-X682X | 6:ee9c86f06eae | 34 | printf(" Is filename capture enabled? \t\t"); |
kris@kris-X682X | 8:369b80cef5ae | 35 | #if MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED |
kris@kris-X682X | 6:ee9c86f06eae | 36 | printf(" Enabled filename capture"); |
kris@kris-X682X | 8:369b80cef5ae | 37 | #endif |
kris@kris-X682X | 6:ee9c86f06eae | 38 | |
kris@kris-X682X | 7:9cda1b0f25ae | 39 | BleDevicePeripheral peripheral(ble, queue); |
kris@kris-X682X | 7:9cda1b0f25ae | 40 | BleDeviceCentral central(ble, queue); |
kris@kris-X682X | 10:d845189d146e | 41 | MyStripSingleton* inst = MyStripSingleton::getInstance(); |
kris@kris-X682X | 10:d845189d146e | 42 | MyStripSingleton::getInstance()->colorWipe(1, 0x00FF00); |
kris@kris-X682X | 7:9cda1b0f25ae | 43 | |
kris@kris-X682X | 10:d845189d146e | 44 | MyStripSingleton::getInstance()->blink(10, 2); |
kris@kris-X682X | 10:d845189d146e | 45 | MyStripSingleton::getInstance()->flash(1, 0xFFFF00); |
kris@kris-X682X | 6:ee9c86f06eae | 46 | |
kris@kris-X682X | 6:ee9c86f06eae | 47 | while(1) { |
kris@kris-X682X | 6:ee9c86f06eae | 48 | printf("\r\n PERIPHERAL \r\n\r\n"); |
kris@kris-X682X | 7:9cda1b0f25ae | 49 | peripheral.run(15000); |
kris@kris-X682X | 6:ee9c86f06eae | 50 | peripheral.stop(); |
kris@kris-X682X | 6:ee9c86f06eae | 51 | |
kris@kris-X682X | 6:ee9c86f06eae | 52 | printf("\r\n CENTRAL \r\n\r\n"); |
kris@kris-X682X | 8:369b80cef5ae | 53 | central.run(10000); |
kris@kris-X682X | 6:ee9c86f06eae | 54 | central.stop(); |
kris@kris-X682X | 6:ee9c86f06eae | 55 | } |
krissl | 0:fe5389573740 | 56 | return 0; |
krissl | 0:fe5389573740 | 57 | } |
krissl | 3:f594022fe519 | 58 |