julien coustillas

unread,
May 31, 2018, 4:50:45 AM5/31/18
to MIT App Inventor Forum
Hi Inventors !! 

I am asking for your help. 
Basically I try to connect my Android phone to a Bluetooth LE device (emulated by a Raspberry Pi). If I use an usual app such as nRF Connect or Light Blue it is working. 
But ! With my personal app developed on MIT App Inventor 2, I always get the "OS Code 133" Error. 
Here is my connection blocks. 

Thank You for your help and advice. 

Julien

Ghica

unread,
May 31, 2018, 10:53:25 AM5/31/18
to MIT App Inventor Forum
Can you show more blocks, for example, where are your scanning blocks?
Cheers, Ghica

julien coustillas

unread,
May 31, 2018, 10:57:25 AM5/31/18
to MIT App Inventor Forum


Yes of course, 
I added the scanning blocks. I will try with thunkable tomorrow. 



Julien


gerrikoio

unread,
Jun 2, 2018, 10:05:08 AM6/2/18
to MIT App Inventor Forum
Any particular reason you scanning both for devices and advertising devices.

Miguel Martins

unread,
Jun 2, 2018, 10:35:09 AM6/2/18
to MIT App Inventor Forum
Sorry for hijacking this post, but gerrikoio i've searched everywhere and you were the only person that was able to correctly create an app for Psoc 4 BLE and mit app inventor 2 BLE. If it's possible i'd like to have one of your .aia. files for that mcu so i can send or receive some data. 

In case you're interested in helping me with that email me "sousa_ma...@hotmail.com"

Thank you
Miguel Martins 

julien coustillas

unread,
Jun 4, 2018, 3:24:15 AM6/4/18
to MIT App Inventor Forum
Yes I scan for both because I never get the advertisers with only the advertising scan. Don't know why... 

Julien 

gerrikoio

unread,
Jun 4, 2018, 6:25:12 AM6/4/18
to MIT App Inventor Forum
If your aim is to connect with your BLE device then do not use the advertising scan. Remove those blocks and remove the timer block as not needed.

Once you have started a scan using the StartScanning method you then need to include a "when BluetoothLE1.DeviceFound" block which will trigger each time a new device is found. This will continue until the StopScanning method is used.

A good tip is to then push that list data onto a list view so that you can select your device, for example.

Try that and you should see your devices.
Message has been deleted
Message has been deleted

julien coustillas

unread,
Jun 4, 2018, 10:04:36 AM6/4/18
to MIT App Inventor Forum
Ho, Thank you Gerrikoio for your answer. 

Use the DeviceFound event it is what I have done since the beginning. 
I use the advertisement scan because I am working on devices that are broadcasting some information on their advertisement payload, such as their services . 
I want to display the services of a device when the user select it. I used the scanadvertisement to get the name and adresses and also the information about the services. This part work. 
The next step is to allow the user to connect to get the characteristics of a service and to write/read informations.  

The problem is during the connection. I got the error code 133.

I would like to join you the entire project but google does not let me import neither .aia nor zip file 

Thank you for your help  
Message has been deleted

gerrikoio

unread,
Jun 4, 2018, 4:39:23 PM6/4/18
to MIT App Inventor Forum
Yes, unfortunately, there is a known problem when including the aia files on a forum post in google groups. It has to do with the BLE extension. The suggested method for BLE is to set up a folder on github or create a public folder on google drive for the aia file and then include the link in the post.

If it is important to have the scan for advertisements then my suggestion (never tested this though) is to add in another BLE component and then use two BLE components (BluetoothLE1 and BluetoothLE2) where you use one for the advertising scanning and the other for the connection. Worth a try.

julien coustillas

unread,
Jun 6, 2018, 3:33:11 AM6/6/18
to MIT App Inventor Forum
Thank you for the explanation. I tried my app with Thunkable directly imported from the MIT App Inventor and it worked. 
I removed the scan for advertisement, or use it differently because the behaviour is really weird. But now, it working. I don't understand what is difference between both platform ? 
(So I did not try your idea gerrikoio, just for curiosity, a BLE component is not associated to an hardware component ? , normally we just have one of it, no ?)

gerrikoio

unread,
Jun 6, 2018, 4:26:08 AM6/6/18
to MIT App Inventor Forum
Glad to see that you got it working. Your app should work on both platforms as you are using the same BLE extension.

The BLE component is an instance of the BLE class object, hence you can use more than one. You would use multiple components if you want your phone app to connect with multiple BLE devices, for example. But otherwise, yes, I am not sure whether the phone can handle two scanning processes concurrently as that could be limited by the hardware itself. Worth a try I suppose.
Reply all
Reply to author
Forward
0 new messages