Esempio n. 1
0
        /// <summary>
        /// Pipe setup is performed by sequentially adding services, characteristics and
        /// descriptors. Pipes can be added to the characteristics and descriptors one wants
        /// to have access to from the application during runtime. A pipe assignment must
        /// be stated directly after the characteristic or descriptor it shall apply for.
        /// The pipe type chosen will affect what operations can be performed on the pipe
        /// at runtime. <see cref="Nordicsemi.PipeType"/>.
        /// </summary>
        ///
        public void PerformPipeSetup()
        {
            /* GAP service */
            BtUuid uartOverBtleUuid = new BtUuid("6e400001b5a3f393e0a9e50e24dcca9e");

            masterEmulator.SetupAddService(uartOverBtleUuid, PipeStore.Remote);

            /* UART RX characteristic (RX from peripheral's viewpoint) */
            BtUuid uartRxUuid      = new BtUuid("6e400002b5a3f393e0a9e50e24dcca9e");
            int    uartRxMaxLength = 20;

            byte[] uartRxData = null;
            masterEmulator.SetupAddCharacteristicDefinition(uartRxUuid, uartRxMaxLength,
                                                            uartRxData);
            /* Using pipe type Transmit to enable write operations */
            UartRxPipe = masterEmulator.SetupAssignPipe(PipeType.Transmit);

            /* UART TX characteristic (TX from peripheral's viewpoint) */
            BtUuid UartTxUuid      = new BtUuid("6e400003b5a3f393e0a9e50e24dcca9e");
            int    uartTxMaxLength = 20;

            byte[] uartTxData = null;
            masterEmulator.SetupAddCharacteristicDefinition(UartTxUuid, uartTxMaxLength,
                                                            uartTxData);
            /* Using pipe type Receive to enable notify operations */
            UartTxPipe = masterEmulator.SetupAssignPipe(PipeType.Receive);
        }
Esempio n. 2
0
        private void PerformPipeSetup()
        {
            const ushort EcgServiceUuid            = 0xFFF0;
            const ushort EcgNotiCharacteristicUuid = 0xFFF2;
            // const ushort ecgNotificationUuid = 0x2902;

            /* Setup pipe Temperature Measurement*/
            BtUuid    serviceUuid1 = new BtUuid(EcgServiceUuid);
            PipeStore pipeStoreR   = PipeStore.Remote;

            masterEmulator.SetupAddService(serviceUuid1, pipeStoreR);

            BtUuid charDefUuid1  = new BtUuid(EcgNotiCharacteristicUuid);
            int    maxDataLength = 20;

            byte[] data = new byte[] { };
            masterEmulator.SetupAddCharacteristicDefinition(charDefUuid1, maxDataLength, data);
            PipeType pipeType1 = PipeType.Receive;

            pipeElecData         = masterEmulator.SetupAssignPipe(pipeType1);
            pipeElecNotification = masterEmulator.SetupAssignPipe(PipeType.Transmit);
        }