void BLECentralRole::handleConnectEvent(bt_conn_t *conn, uint8_t err)
{
    if (_event_handlers[BLEConnected])
    {
        BLEPeripheralHelper *temp = peripheral(conn);
        _event_handlers[BLEConnected](*temp);
    }
}
void BLECentralRole::handleDisconnectEvent(bt_conn_t *conn, uint8_t reason)
{
    if (_event_handlers[BLEDisconnected])
    {
        BLEPeripheralHelper *temp = peripheral(conn);
        _event_handlers[BLEDisconnected](*temp);
        temp->linkLost();
    }
}
예제 #3
0
    // Pin config
    virtual void PinSetMode(MicroFlo::PinId pin, IO::PinMode mode) {

        MAP_SysCtlPeripheralEnable(peripheral(pin));
        if (mode == IO::InputPin) {
            MAP_GPIOPinTypeGPIOInput(portBase(pin), pinMask(pin));
        } else if (mode == IO::OutputPin) {
            MAP_GPIOPinTypeGPIOOutput(portBase(pin), pinMask(pin));
        } else {
            MICROFLO_DEBUG(debug, DebugLevelError, DebugIoOperationNotImplemented);
        }
    }
void BLECentralRole::handleParamUpdated(bt_conn_t *conn, 
                        uint16_t interval,
                        uint16_t latency, 
                        uint16_t timeout)
{
    if (_event_handlers[BLEUpdateParam])
    {
        BLEPeripheralHelper *temp = peripheral(conn);
        temp->setConnectionParameters(interval, interval, latency, timeout);
        _event_handlers[BLEUpdateParam](*temp);
    }
}
예제 #5
0
int main()
{
    BLE& ble = BLE::Instance();

    while(1) {
        {
            events::EventQueue queue;
            printf("\r\n * Device is a peripheral *\r\n\r\n");
            PrivacyPeripheral peripheral(ble, queue);
            peripheral.run();
        }
        {
            events::EventQueue queue;
            printf("\r\n * Device is a central *\r\n\r\n");
            PrivacyCentral central(ble, queue);
            central.run();
        }
    }

    return 0;
}
예제 #6
0
char getc(void) {
    // wait for data in the receive FIFO
    while(*peripheral(UART0_BASE, UART0_FR) & FR_RXFE) { }
    // extract char from receive FIFO
    return *peripheral(UART0_BASE, UART0_DR);
}
예제 #7
0
void putc(char c) {
    // wait for space in the transmit FIFO
    while(*peripheral(UART0_BASE, UART0_FR) & FR_TXFF) { }
    // add char to transmit FIFO
    *peripheral(UART0_BASE, UART0_DR) = c;
}