I have one of Justin’s BLE modules and am getting a strange error.
Error 1 ‘Gadgeteer.Modules.IngenuityMicro.BluetoothSmart’ does not contain a constructor that takes 1 arguments
I am using MF 4.3 and have tried this on a Cerbuino and a Spider. I have uninstalled the SDK and tried a different release.
The constructor wants two sockets. I have tried giving it another socket but it will not run.
@ TWIMC - I just added the a serial “COMx” look into the Cerberus schema to find out the port number belonging to what socket, don’t add it in the gadgeteer designer. I only added the handler and the rest and it works for me on a raptor and in VS2015. I could switch the relais off/on with my mobile phone using some standard app, I thought it is called BLEExplorer (on windows phone).
Hope it helps:
using System;
using Microsoft.SPOT;
using System.IO.Ports;
using Microsoft.SPOT.Hardware;
using System.Threading;
namespace blueRaptor
{
public class Program
{
static OutputPort led = new OutputPort((Cpu.Pin)((3 * 32) + 3), false);
static SerialPort ble = new SerialPort("COM6", 14400);
static OutputPort relais = new OutputPort((Cpu.Pin)((0 * 32) + 9), false);
public static void Main()
{
ble.DataReceived += ble_DataReceived;
ble.Open();
while (true == true)
{
led.Write(true);
Thread.Sleep(250);
led.Write(false);
Thread.Sleep(250);
}
}
static void ble_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Debug.Print("Event fired...");
var xSerialPort = sender as System.IO.Ports.SerialPort;
byte[] tmpBytes = new byte[xSerialPort.BytesToRead];
xSerialPort.Read(tmpBytes, 0, tmpBytes.Length);
string cmd = new string(System.Text.Encoding.UTF8.GetChars(tmpBytes));
Debug.Print(cmd);
switch (cmd)
{
case "Relais=On": // Android = 0052656C6169733D4F6E
// Turn the relais on connected to socket 10 and pin 5
relais.Write(true);
break;
case "Relais=Off": // Android = 0052656C6169733D4F6666
// Turn the relais off connected to socket 10 and pin 5
relais.Write(false);
break;
default:
break;
}
}
}
}
@ Jason - I am setting up a MF 4.2 environment so I can use Justin’s SDK. The code running on my Win 8.1 tablet has connected with the Bluetooth module.
@ Architect - I set up a Cerbuino running MF 4.2 and everything works fine. Boy, do I feel foolish that I did not notice that Justin’s SDKs were a year old. Thank you Architect.