This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Can not enable notifications of my characteristic with masteremulator.dll

Hello,

For my project, I want to be notified when my device changes the value of my characteristic so i used the HealthThermoDemo example.

here is my code :

const ushort AccelerometreServiceUuid = 0xaaaa;
const ushort Read_CharacteristicUuid = 0xbbbb;


/* Setup pipe Accélérometre*/
BtUuid serviceUuid1 = new BtUuid(AccelerometreServiceUuid);
masterEmulator.SetupAddService(serviceUuid1, PipeStore.Remote, 0xhhhh);


/* Read */
BtUuid charDefUuid2 = new BtUuid(Read_CharacteristicUuid);
int maxDataLength2 = 8;
byte[] data2 = new byte[] { };
masterEmulator.SetupAddCharacteristicDefinition(charDefUuid2, maxDataLength2, data2);
pipeReadNotif = masterEmulator.SetupAssignPipe(PipeType.Receive);

masterEmulator.Run();

But despite a change in value, i don't receive anything with the event :

masterEmulator.DataReceived += OnDataReceived;

You must know, that i realized the same operations as my program with the software Master Control Panel and i get the update of my value.

Here is the log of my program :

/*log :*/
Bonded successfully
Discover pipes
Discovered pipe 1 (characteristic 0xaaaa, service 0xbbbb)
Discovered pipe 2 (characteristic 0xcccc, service 0xbbbb)
Discovered pipe 2 CCCD (descriptor 0xdddd, service 0xbbbb)
Opening pipe 2
/*....*/

thank you

Parents
  • Hello,

    Fortunately, I'm here to help me xD

    so to communicate with several device and keep active notifications, i do like this :

    private void RegisterEventHandlers()
        {
            masterEmulator.DataReceived += OnDataReceived;
        }
    
    
    void OnBackgroundConnectWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            /*...*/
            try
            {
                if (masterEmulator.Connect(DeviceAddressForCalibration, cxParam))
                {
                    masterEmulator.Bond();
                    masterEmulator.DiscoverPipes();
                    masterEmulator.OpenRemotePipe(pipeReadNotif);
                    
                    masterEmulator.SendData(pipeWrite, dataToSend);
                }
            }
            catch (Exception ex)
            {
                DisplayErrorMessage(ex);
            }
            /*...*/
        }
    
    void OnDataReceived(object sender, PipeDataEventArgs e)       
        {
            if (e.PipeNumber == pipeReadNotif)
            {
                masterEmulator.DeleteBondInformation();
                masterEmulator.Disconnect();
            }
        }

Reply
  • Hello,

    Fortunately, I'm here to help me xD

    so to communicate with several device and keep active notifications, i do like this :

    private void RegisterEventHandlers()
        {
            masterEmulator.DataReceived += OnDataReceived;
        }
    
    
    void OnBackgroundConnectWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            /*...*/
            try
            {
                if (masterEmulator.Connect(DeviceAddressForCalibration, cxParam))
                {
                    masterEmulator.Bond();
                    masterEmulator.DiscoverPipes();
                    masterEmulator.OpenRemotePipe(pipeReadNotif);
                    
                    masterEmulator.SendData(pipeWrite, dataToSend);
                }
            }
            catch (Exception ex)
            {
                DisplayErrorMessage(ex);
            }
            /*...*/
        }
    
    void OnDataReceived(object sender, PipeDataEventArgs e)       
        {
            if (e.PipeNumber == pipeReadNotif)
            {
                masterEmulator.DeleteBondInformation();
                masterEmulator.Disconnect();
            }
        }

Children
No Data
Related