47 lines
1.5 KiB
C++
47 lines
1.5 KiB
C++
#include "ble_plugin.h"
|
|
|
|
// Windows stub - BLE peripheral not yet implemented.
|
|
|
|
#include <flutter/method_channel.h>
|
|
#include <flutter/plugin_registrar_windows.h>
|
|
#include <flutter/standard_method_codec.h>
|
|
|
|
namespace ble {
|
|
|
|
class BlePlugin : public flutter::Plugin {
|
|
public:
|
|
static void RegisterWithRegistrar(flutter::PluginRegistrarWindows* registrar) {
|
|
auto channel = std::make_unique<flutter::MethodChannel<flutter::EncodableValue>>(
|
|
registrar->messenger(), "com.dalimaster.ble",
|
|
&flutter::StandardMethodCodec::GetInstance());
|
|
auto plugin = std::make_unique<BlePlugin>();
|
|
channel->SetMethodCallHandler(
|
|
[plugin_pointer = plugin.get()](const auto& call, auto result) {
|
|
plugin_pointer->HandleMethodCall(call, std::move(result));
|
|
});
|
|
registrar->AddPlugin(std::move(plugin));
|
|
}
|
|
|
|
BlePlugin() {}
|
|
virtual ~BlePlugin() {}
|
|
|
|
private:
|
|
void HandleMethodCall(
|
|
const flutter::MethodCall<flutter::EncodableValue>& method_call,
|
|
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result) {
|
|
if (method_call.method_name().compare("isSupported") == 0) {
|
|
result->Success(flutter::EncodableValue(false));
|
|
} else {
|
|
result->Success();
|
|
}
|
|
}
|
|
};
|
|
|
|
} // namespace ble
|
|
|
|
void BlePluginCApiRegisterWithRegistrar(
|
|
FlutterDesktopPluginRegistrarRef registrar) {
|
|
ble::BlePlugin::RegisterWithRegistrar(
|
|
flutter::PluginRegistrarManager::GetInstance()
|
|
->GetRegistrar<flutter::PluginRegistrarWindows>(registrar));
|
|
} |