
simple project to control mirrorless camera
Dependencies: mbed BLE_API nRF51822
main.cpp
- Committer:
- vilesovds
- Date:
- 2015-10-22
- Revision:
- 2:ed001667a2b6
- Parent:
- 0:81f1818af032
- Child:
- 3:38ec35b54db8
File content as of revision 2:ed001667a2b6:
#include "mbed.h" #include "ble/BLE.h" #include "PowerSwitch.h" #include "Light.h" #include "ServicePower.h" #include "FlashStore.h" BLE ble; PowerSwitch power(p30); Light light(p6); Serial serial(USBTX, USBRX); // tx, rx FlashStore store(serial); void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *){ ble.startAdvertising(); serial.printf("BLE Disconnected!\r\n"); } void connectionCallback(const Gap::ConnectionCallbackParams_t *params) { serial.printf("BLE Connected!\r\n"); } int main(void){ ble.init(); ble.gap().onDisconnection(disconnectionCallback); ble.gap().onConnection(connectionCallback); //ServiceDeviceInformation deviceService(ble, "Seed", "AEAB00", "AEAB00-010000001", NULL, "1.0.0-alfa", NULL); ServicePower powerService(ble, serial, power, light, store); static const uint16_t bleservices_uuid16_list[] = {GattService::UUID_DEVICE_INFORMATION_SERVICE, GattService::UUID_SCAN_PARAMETERS_SERVICE}; ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)bleservices_uuid16_list, sizeof(bleservices_uuid16_list)); ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); ble.gap().setAdvertisingInterval(1000); ble.gap().startAdvertising(); while (true) { ble.waitForEvent(); } }