Check out our latest project ✨ OpenChapter.io: free ebooks the way its meant to be 📖

GodotBLE

An asset by Fantety
The page banner background of a mountain and forest
GodotBLE thumbnail image
GodotBLE thumbnail image
GodotBLE thumbnail image
GodotBLE hero image

Quick Information

0 ratings
GodotBLE icon image
Fantety
GodotBLE

一个为Godot4.0开发的低功率蓝牙插件,可以帮助你的游戏联合更多有趣的设备A low-power Bluetooth plugin developed for Godot 4.0 to help unite your game with more interesting devices!

Supported Engine Version
4.1
Version String
0.1.0
License Version
MIT
Support Level
community
Modified Date
7 months ago
Git URL
Issue URL

GodotBLE

GitHub code size in bytes GitHub language count


一个为Godot4.0开发的低功率蓝牙插件,可以帮助你的游戏联合更多有趣的设备

概述

这个插件依赖于 SimpleBLE, 使用GDExtension, 但是仅仅支持低功率蓝牙,并不支持经典蓝牙。

平台支持

平台 版本
Windows Windows 10+
Linux 暂时不支持
MacOS 暂时不支持

提供的节点

节点 描述
GodotBle 所有功能都包含在这一个节点当中

怎样在 GDScript 中使用GodotBLE?

在 GodotBle 节点中提供以下一些函数及方法:

方法 描述
init_adapter_list() 用于初始化蓝牙设备适配器
set_adapter(int index) 选择适配器
start_scan() 开始扫描环境当中的蓝牙设备
stop_scan() 停止扫描环境当中的蓝牙设备
bluetooth_enabled() 返回一个布尔值,用于判断蓝牙适配器是否启用。
get_adapters_index_from_identifier(String identifier) 根据适配器名称获取其在适配器列表中的索引。
get_device_index_from_identifier(String identifier) 根据设备名称获取其在设备列表中的索引。
connect_to_device(int index) 连接到指定的蓝牙设备。
show_all_services() 显示已连接蓝牙设备的所有服务。
show_all_devices() 显示当前设备列表中的所有设备。
get_current_adapter_index() 获取当前所选适配器的索引。
get_current_device_index() 获取当前连接设备的索引。

由 GodotBle 节点提供的信号:

信号 描述
on_device_found 发现新设备时触发该信号。返回两个字符串,一个是设备名称,另一个是设备地址。
on_device_update 设备信息更新时触发该信号。返回两个字符串,一个是设备名称,另一个是设备地址。

示例代码:

extends GodotBle

signal start_write

func _ready() -> void:
    print(init_adapter_list())
    set_adapter(0)
    start_scan()
    pass

func _process(delta: float) -> void:
    pass


func _on_on_device_found(identifier: String, address: String) -> void:
    print(identifier,'\t',address)
    if identifier=='ESP32':
        stop_scan()
        print(get_device_index_from_identifier('ESP32'))
        if connect_to_device(get_device_index_from_identifier('ESP32'))==0:
            print("success connnect")
            pass
        print(show_all_services())
        print(get_current_device_index())
        emit_signal("start_write")
        pass
    pass # Replace with function body.


func _on_start_write() -> void:
    print("start_write")
    print(write_data_to_service(3,"r#hello"))
    pass # Replace with function body.

一个为Godot4.0开发的低功率蓝牙插件,可以帮助你的游戏联合更多有趣的设备
A low-power Bluetooth plugin developed for Godot 4.0 to help unite your game with more interesting devices!

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
GodotBLE icon image
Fantety
GodotBLE

一个为Godot4.0开发的低功率蓝牙插件,可以帮助你的游戏联合更多有趣的设备A low-power Bluetooth plugin developed for Godot 4.0 to help unite your game with more interesting devices!

Supported Engine Version
4.1
Version String
0.1.0
License Version
MIT
Support Level
community
Modified Date
7 months ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers