favarete / GodotBluetooth

Bluetooth Module for Android Games/Applications made with Godot Engine
MIT License
58 stars 12 forks source link

Compiling for 3.1.1 #7

Open SigmaOrionis opened 5 years ago

SigmaOrionis commented 5 years ago

edit config.py:

def can_build(env, plat):
    return plat=="android"

def configure(env):
    if (env['platform'] == 'android'):
        env.android_add_to_permissions("android/AndroidPermissionsChunk.xml")
        env.android_add_java_dir("android/src")

edit GodotBluetooth.java: comment this line: //import android.support.v7.app.AppCompatActivity;

there is no engine.cfg in godot 3.1.1, add it to project.godot

tested with JDK 1.8.1_181 and godot 3.1.1

thank you for lib, favarete Kind regards

wigglybanana commented 3 years ago

hey , i have done all , with the same configurations but still couldn't figure out how to call the module.

func _ready():
    if(Engine.has_singleton("GodotBluetooth")):
        bluetooth = Engine.get_singleton("GodotBluetooth")
        bluetooth.init(get_instance_id(), false)
    print(Engine.has_singleton("GodotBluetooth"))

this does not work since has_singleton() returns false .

I also tried to go straight forward :

func _ready():
    bluetooth = GodotBluetooth.new()
    bluetooth.init(get_instance_id(), false)

but still it gives me a null erorr

I am sure i have done all right . Compiled with godot 3.1.1 - jdk 1.8.1 , configured the files, added module to project.godot properly , ran it on android , but i cannot call the bluetooth module .

Thanks SigmaOrionis Kind Regards

SigmaOrionis commented 3 years ago
Make sure that on host device all security levels are open for application. First that comes to mind. Regards. Sent from Mail for Windows 10 From: NewcaliburSent: 23. ožujka 2021. 12:01To: favarete/GodotBluetoothCc: SigmaOrionis; AuthorSubject: Re: [favarete/GodotBluetooth] Compiling for 3.1.1 (#7) hey , i have done all , with the same configurations but still couldn't figure out how to call the module.func _ready():    if(Engine.has_singleton("GodotBluetooth")):        bluetooth = Engine.get_singleton("GodotBluetooth")        bluetooth.init(get_instance_id(), false)    print(Engine.has_singleton("GodotBluetooth"))this does not work since has_singleton() returns false .I also tried to go straight forward :func _ready():        bluetooth = GodotBluetooth.new()        bluetooth.init(get_instance_id(), false)but still it gives me a null erorrI am sure i have done all right . Compiled with godot 3.1.1 - jdk 1.8.1 , configured the files, added module to project.godot properly , ran it on android , but i cannot call the blurtooth module .Thanks SigmaOrionisKind Regards—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or unsubscribe. 
wigglybanana commented 3 years ago

Make sure that on host device all security levels are open for application.

how can i assure this ?

SigmaOrionis commented 3 years ago
There must be some security settings which you use while compiling application for example android? Tomorrow I can look up how I did setup for android compilation. Sent from Mail for Windows 10 From: NewcaliburSent: 23. ožujka 2021. 18:13To: favarete/GodotBluetoothCc: SigmaOrionis; AuthorSubject: Re: [favarete/GodotBluetooth] Compiling for 3.1.1 (#7) Make sure that on host device all security levels are open for application. how can i assure this ?—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or unsubscribe. 
wigglybanana commented 3 years ago

Thanks , I got it working by enabling permissions on android export settings which are image

SigmaOrionis commented 3 years ago
Very good 😊 Sent from Mail for Windows 10 From: NewcaliburSent: 23. ožujka 2021. 22:05To: favarete/GodotBluetoothCc: SigmaOrionis; AuthorSubject: Re: [favarete/GodotBluetooth] Compiling for 3.1.1 (#7) Thanks , I got it working by enabling permissions on android export settings which are—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or unsubscribe. 
fadikidess commented 3 years ago

Hi! I am trying to run the scons command, and it generates the following TypeError (in the config.py file): 'SConsEnvironment' object has no attribute 'android_add_to_permissions' I then edited the config.py exactly like what you have done above, but nothing has changed.

I am using Godot version 3.2.2 (since it has C# support for iOS which I will need for later). How can I compile this module for Godot version 3.2.2? (All other steps have been correctly performed, such as setting up the environment variables which works correctly as the Sconstruct file correct identified that Android is the targeted platform, but the error is generated at this module's config.py)

What should I do?

Thank you :)

wigglybanana commented 3 years ago

firstly, sorry to inform you that it is not compatible with younger builds since android structure has changed a lot in 3.2 . and make sure that you are using a valid ndk

fadikidess commented 3 years ago

Thank you for your quick response!

So only the 3.1.1 version is supported, is that correct?

wigglybanana commented 3 years ago

Yes that is correct , i can provide you my builds if you want . It's sheered 8MB .

fadikidess commented 3 years ago

That would be great! Thank you so much! Also does this library work with Bluetooth LE?

wigglybanana commented 3 years ago

Yes, i assume . Will provide them as soon as i reach to my rig.

fadikidess commented 3 years ago

Yes, i assume . Will provide them as soon as i reach to my rig.

Thank you, but you don't need to do that, i just built them and will test them tomorrow, will let you know what happens! :D

Seriously thanks for your support, I really appreciate it!

fadikidess commented 3 years ago

Ok so I got this error when attaching the script:

Parse Error: Method 'get_instance_ID' is not declared in the current class

What did I mess up now? 😂

wigglybanana commented 3 years ago

These code chunks were made in GODOT2 , you might expect those errors.

fadikidess commented 3 years ago

So now I got the apk up and running, but nothing is happening, not even errors are being generated. (I'm not being asked to connect to anything, not even permissions are being asked). My project is using a native mobile ArVr singleton and it has two simple scripts (which is where something is likely to have gone):

This script is the edited global script (For my project I am not using the connected and disconnected signals, so I removed them, will that cause any issue?) ` signal data_received

var bluetooth

func _ready(): if(Engine.has_singleton("GodotBluetooth")): bluetooth = Engine.get_singleton("GodotBluetooth") bluetooth.init(.get_instance_ID(), true) if bluetooth: bluetooth.getPairedDevices(true) pass

GodotBluetooth Callbacks

func _on_data_received(data_received): emit_signal("data_received", data_received) pass`

This script is attached to the ArVr Camera

` extends ARVRCamera onready var global = get_node("/root/global") var speed var x var y var pressed

func _ready(): set_signals() pass func _on_data_received(data_received): var data = int(data_received) pressed = (data / 1000)%10 var r = (data / 100) % 10 var yx = data % 10 var xx = (data / 10) % 10 x = xx -4 y = yx - 4

pass

func _fixed_process(delta): translate(Vector3(0,delta y,delta x)) pass func set_signals(): global.connect("data_received", self, "_on_data_received") pass `

Although its not showing here, all indentations are correctly implemented