code works using esp32 but not with arduino mega 2560

my code work with the sp32 but im trying to put in on the arduino mega2560 and Im getting this error. any help would be appreciated. I am a newbie

exit status 1
BLEDevice.h: No such file or directory

/*
Video: ESP32 Technical Tutorials: BLE Notifications - YouTube
Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleNotify.cpp
Ported to Arduino ESP32 by Evandro Copercini
updated by chegewara

Create a BLE server that, once we receive a connection, will send periodic notifications.
The service advertises itself as: 442f1570-8a00-9a28-cbe1-e1d4212d53eb
And has a characteristic of: 442f1570-8a00-9a28-cbe1-e1d4212d53eb

The design of creating the BLE server is:

  1. Create a BLE Server
  2. Create a BLE Service
  3. Create a BLE Characteristic on the Service
  4. Create a BLE Descriptor on the characteristic
  5. Start the service.
  6. Start advertising.

A connect hander associated with the server starts a background task that performs notification
every couple of seconds.
*/
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>

BLEServer* pServer = NULL;
BLECharacteristic* pCharacteristic = NULL;
bool deviceConnected = false;
bool oldDeviceConnected = false;
uint32_t value = 0;

// See the following for generating UUIDs:
// https://www.uuidgenerator.net/

#define SERVICE_UUID "442f1570-8a00-9a28-cbe1-e1d4212d53eb"
#define CHARACTERISTIC_UUID "442f1571-8a00-9a28-cbe1-e1d4212d53eb"
#define CHARACTERISTIC_UUID2 "442f1572-8a00-9a28-cbe1-e1d4212d53eb"

class MyServerCallbacks: public BLEServerCallbacks {
void onConnect(BLEServer* pServer) {
deviceConnected = true;
BLEDevice::startAdvertising();
};

void onDisconnect(BLEServer* pServer) {
deviceConnected = false;
}
};

void setup() {
Serial.begin(115200);

// Create the BLE Device
BLEDevice::init("GRANBOARD");

// Create the BLE Server
pServer = BLEDevice::createServer();
pServer->setCallbacks(new MyServerCallbacks());

// Create the BLE Service
BLEService *pService = pServer->createService(SERVICE_UUID);

// Create a BLE Characteristic
pCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_WRITE |
BLECharacteristic::PROPERTY_NOTIFY |
BLECharacteristic::PROPERTY_INDICATE
);

// https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.descriptor.gatt.client_characteristic_configuration.xml
// Create a BLE Descriptor
pCharacteristic->addDescriptor(new BLE2902());

// Start the service
pService->start();

// Start advertising
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
pAdvertising->addServiceUUID(SERVICE_UUID);
pAdvertising->setScanResponse(false);
pAdvertising->setMinPreferred(0x00); // set value to 0x00 to not advertise this parameter
BLEDevice::startAdvertising();
Serial.println("Waiting a client connection to notify...");
}

void loop() {

}

The Arduino Mega doesn't have Bluetooth. The Arduino Mega Core doesn't have any Bluetooth libraries. You cannot include the BLEDevice header/library in a sketch for the Arduino Mega, because the library doesn't exist for the Mega.

Pieter

Also next time you post code here, do it inside code tags as the forum guidelines suggest.

thank you for your response im extremly new to this. Ive got the bluetooth 4.0 hm-10 module hooked up to the mega

Okay, so how would the program know which serial port you have the bluetooth module connected to?