edit components

georgecarlo
Posts: 16
Joined: Fri Jan 18, 2019 5:55 am

edit components

Postby georgecarlo » Fri Jan 18, 2019 6:05 am

Hello People,

I am using the kolban's ble libraries for esp32 in my project. My problem is i want guidance on how to properly configure the component.mk for additional libraries and also i have a clash were my project code is in C and the ble example by neil is in C++, i just want to change my project from C to C++ so that all together everything runs from C++
my component .mk has to be configured to add libraries by kolban.
my project C code

Code: Select all

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"

int ledPin = 18; // choose the output pin for the LED
int ledPin2 = 23; // choose the output pin2 for the LED
int inPin = 21;   // choose the input pin (for a pushbutton)
int inPin2 = 4; // choose the input pin2 (for a pushbutton2)
int val = 0;  // variable for reading the pin status
int val2 = 0; // variable for reading the pin2 status


void pbm_task(void *pvParameter)
{
    gpio_pad_select_gpio(ledPin);
    gpio_set_direction(ledPin, GPIO_MODE_OUTPUT);
    gpio_pad_select_gpio(ledPin2);
    gpio_set_direction(ledPin2, GPIO_MODE_OUTPUT);
    gpio_pad_select_gpio(inPin);
    gpio_set_direction(inPin, GPIO_MODE_INPUT);
    gpio_pad_select_gpio(inPin2);
    gpio_set_direction(inPin2, GPIO_MODE_INPUT);
}

void pb1_task(void *pvParameter)
{
    val = gpio_get_level(inPin);
    while(1)
    {
        if(val == 1)
        {
           gpio_set_level(ledPin, 1);
           printf("BUTTON 1 ON!");
           vTaskDelay(1000 / portTICK_PERIOD_MS);
        }
        else
        {
           gpio_set_level(ledPin, 0);
           printf("BUTTON 1 OFF!");
           vTaskDelay(1000 / portTICK_PERIOD_MS);
        }
    }
}

void pb2_task(void *pvParameter)
{
    val2 = gpio_get_level(inPin2);
    while(1)
    {
        if(val2 == 1)
        {
            gpio_set_level(ledPin2, 1);
            printf("BUTTON 2 ON!");
            vTaskDelay(1000 / portTICK_PERIOD_MS);
        }
        else
        {
            gpio_set_level(ledPin2, 0);
            printf("BUTTON 2 OFF!");
            vTaskDelay(1000 / portTICK_PERIOD_MS);
        }
    }
}

void app_main()
{
    xTaskCreate(&pbm_task, "pbm_task", 2048, NULL, 5, NULL);
    xTaskCreate(&pb1_task, "pb1_task", 2048, NULL, 5, NULL);
    xTaskCreate(&pb2_task, "pb2_task", 2048, NULL, 5, NULL);
}

and im using neil's bleserver.cpp as an example and combine my code into C++

Who is online

Users browsing this forum: No registered users and 108 guests