Kris Scholte Lubberink
/
SSS_Ble
Ble for smart sOlutions
Diff: source/main.cpp
- Revision:
- 1:9fc54848a198
- Parent:
- 0:fe5389573740
- Child:
- 3:f594022fe519
--- a/source/main.cpp Wed Jan 16 09:50:35 2019 +0000 +++ b/source/main.cpp Mon Mar 25 18:14:12 2019 +0000 @@ -18,24 +18,18 @@ #include <mbed.h> #include "ble/BLE.h" #include "ble/Gap.h" -#include "ble/services/EnvironmentalService.h" #include "GattCallbackParamTypes.h" - #include "mbed.h" - #include "Dht11.h" +#include "mbed.h" +#include "ColorService.h" Serial pc(USBTX, USBRX); -Dht11 sensor(A0); -//DigitalOut sensorPower(PTD24, 1); - -//Serial pc(USBTX, USBRX); // tx, rx DigitalOut led1(LED1, 1); -const static char DEVICE_NAME[] = "MARCO&KRIS-slow"; -static const uint16_t uuid16_list[] = {GattService::UUID_ENVIRONMENTAL_SERVICE}; +const static char DEVICE_NAME[] = "SSS-Wearable"; +static const uint16_t uuid16_list[] = {0xF0C0FF}; -static uint8_t batteryLevel = 50; -static EnvironmentalService* batteryServicePtr; +static ColorService* colorServicePtr; static EventQueue eventQueue(/* event count */ 16 * EVENTS_EVENT_SIZE); @@ -46,16 +40,9 @@ void connectionCallback(const Gap::ConnectionCallbackParams_t *params) { pc.printf("\r\n *******Got connection****** \r\n"); - /* Setup advertising */ - BLE::Instance().gap().startAdvertising(); - pc.printf("****** Restarted advertising? ******\r\n"); } void updateSensorValue() { -// pc.printf("Temp sensing"); - sensor.read(); - pc.printf("T: %d, H: %d\r\n", sensor.getCelsius(), sensor.getHumidity()); - batteryServicePtr->updateHumidity(sensor.getHumidity()); - batteryServicePtr->updateTemperature(sensor.getCelsius()); + pc.printf("Right now, i should update sensor value. This runs only during connection \r\n"); } void blinkCallback(void) @@ -111,7 +98,7 @@ ble.gap().onDisconnection(disconnectionCallback); ble.gap().onConnection(connectionCallback); /* Setup primary service */ - batteryServicePtr = new EnvironmentalService(ble); + colorServicePtr = new ColorService(ble); /* Setup advertising */ ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); @@ -120,7 +107,7 @@ // ble.gattServer().onDataRead(blinkCallback); ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); ble.gap().setAdvertisingInterval(1000); /* 1000ms */ - pc.printf("Advertising slowly"); + pc.printf("Advertising"); ble.gap().startAdvertising(); printMacAddress(); @@ -133,7 +120,7 @@ int main() { - pc.baud (115200); + pc.baud (115200); eventQueue.call_every(500, blinkCallback);