Hi guys,
I'm having trouble getting my arduino 101 to appear on my cell phone's bluetooth list. My code is listed below.
I was getting it to appear and making connections prior to adding the IOTCharacteristic attribute shown in the line below to the ArduinoIOT peripheral.
ArduinoIOT.addAttribute(IOTCharacteristic);
It seems as soon as I added that, the arduino quit appearing on my device list. Any help would be appreciated.
#include <SPI.h>
#include <Ethernet.h>
#include <CurieBLE.h>
#include "Mudbus.h"
Mudbus Mb;
BLEPeripheral ArduinoIOT;
BLEService IOTservice("fbd6d91a-118a-11e7-93ae-92361f002671");
BLEUnsignedCharCharacteristic IOTCharacteristic("fbd6d91a-118a-11e7-93ae-92361f002671", BLERead |
BLENotify);
int i=0;
//signed int Mb.R[0 to 125] and bool Mb.C[0 to 128]
//Modbus on Port 502 (defined in Mudbus.h)
void setup()
{
Serial.begin(9600);
uint8_t mac[] = { 0x90, 0xA2, 0xDA, 0x10, 0xD0, 0x96 };
uint8_t ip[] = { 192, 168, 0, 12 };
uint8_t gateway[] = { 192, 168, 0, 1 };
uint8_t subnet[] = { 255, 255, 255, 0 };
Ethernet.begin(mac, ip, gateway, subnet);
ArduinoIOT.setLocalName("IOT");
ArduinoIOT.addAttribute(IOTCharacteristic);
ArduinoIOT.addAttribute(IOTservice);
ArduinoIOT.setAdvertisedServiceUuid(IOTservice.uuid());
ArduinoIOT.begin();
}
void loop()
{
BLECentral central = ArduinoIOT.central();
Mb.Run();
if (central) {
Serial.print("Connected to: ");
Serial.println(central.address());
while(central.connected()){
i += 1;
IOTCharacteristic.setValue(i);
}
}
else{
Serial.println("Not connected");
}
delay(2000);
}