Hello,
I am trying to connect to an adafruit bluefruit LE micro with a windows 10 surface pro 3.
I have loaded an app onto the device using Arduino IDE 1.6.5
When I try to enumerate the list. Nothing show up?
ARDUINO CODE
****************
#include <timerone.h>
#include "DHT.h"
#include <spi.h>
#include <bleperipheral.h>
#define BLE_REQ 10
#define BLE_RDY 2
#define BLE_RST 9
#define DHTTYPE DHT22
#define DHTPIN 3
DHT dht(DHTPIN, DHTTYPE);
BLEPeripheral blePeripheral = BLEPeripheral(BLE_REQ, BLE_RDY, BLE_RST);
BLEService tempService = BLEService("CCC0");
BLEFloatCharacteristic tempCharacteristic = BLEFloatCharacteristic("CCC1", BLERead | BLENotify);
BLEDescriptor tempDescriptor = BLEDescriptor("2901", "Temp Celsius");
BLEService humidityService = BLEService("DDD0");
BLEFloatCharacteristic humidityCharacteristic = BLEFloatCharacteristic("DDD1", BLERead | BLENotify);
BLEDescriptor humidityDescriptor = BLEDescriptor("2901", "Humidity Percent");
volatile bool readFromSensor = false;
float lastTempReading;
float lastHumidityReading;
void setup() {
Serial.begin(115200);
#if defined (__AVR_ATmega32U4__)
delay(5000); #endif
blePeripheral.setLocalName("Temperature");
blePeripheral.setAdvertisedServiceUuid(tempService.uuid());
blePeripheral.addAttribute(tempService);
blePeripheral.addAttribute(tempCharacteristic);
blePeripheral.addAttribute(tempDescriptor);
blePeripheral.setAdvertisedServiceUuid(humidityService.uuid());
blePeripheral.addAttribute(humidityService);
blePeripheral.addAttribute(humidityCharacteristic);
blePeripheral.addAttribute(humidityDescriptor);
blePeripheral.setEventHandler(BLEConnected, blePeripheralConnectHandler);
blePeripheral.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);
blePeripheral.begin();
Timer1.initialize(2 * 1000000); Timer1.attachInterrupt(timerHandler);
Serial.println(F("BLE Temperature Sensor Peripheral"));
}
void loop() {
blePeripheral.poll();
if (readFromSensor) {
setTempCharacteristicValue();
setHumidityCharacteristicValue();
readFromSensor = false;
}
}
void timerHandler() {
readFromSensor = true;
}
void setTempCharacteristicValue() {
float reading = dht.readTemperature();
if (!isnan(reading) && significantChange(lastTempReading, reading, 0.5)) {
tempCharacteristic.setValue(reading);
Serial.print(F("Temperature: ")); Serial.print(reading); Serial.println(F("C"));
lastTempReading = reading;
}
}
void setHumidityCharacteristicValue() {
float reading = dht.readHumidity();
if (!isnan(reading) && significantChange(lastHumidityReading, reading, 1.0)) {
humidityCharacteristic.setValue(reading);
Serial.print(F("Humidity: ")); Serial.print(reading); Serial.println(F("%"));
lastHumidityReading = reading;
}
}
boolean significantChange(float val1, float val2, float threshold) {
return (abs(val1 - val2) >= threshold);
}
void blePeripheralConnectHandler(BLECentral& central) {
Serial.print(F("Connected event, central: "));
Serial.println(central.address());
}
void blePeripheralDisconnectHandler(BLECentral& central) {
Serial.print(F("Disconnected event, central: "));
Serial.println(central.address());
}
********************************************
End of Arduino code
********************************************
This is the C# I am trying. I copied it from several examples that are around.
*********************************************************
async void Initialize()
{
var devices = await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromShortId(0xCCC0));
GattDeviceService Firstdevice = await GattDeviceService.FromIdAsync(devices[0].Id);
serviceNameTextBlock.Text = "Using service: " + devices[0].Name;
GattCharacteristic FirstdeviceCharacteristic =
Firstdevice.GetCharacteristics(
GattCharacteristicUuids.TemperatureMeasurement)[0];
FirstdeviceCharacteristic.ValueChanged += temperatureMeasurementChanged;
await FirstdeviceCharacteristic
.WriteClientCharacteristicConfigurationDescriptorAsync(
GattClientCharacteristicConfigurationDescriptorValue.Notify);
}
***********************************
End of c# example
***********************************
It complies an und ok.... BUt the list is empty
"Enumeration yielded no results"
If I try to find all device with
var devices = await DeviceInformation.FindAllAsync();
It show every device except the bluefruit
It seem like I can't find the service they way I am trying?
Any help greatly appreciated