- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
So I've setup a small BLE program, with a read and write. I can find it with the cypress app "CySmart" on my Android phone. Now my question is, how can I make this connection with a selfmade android app? I need to be able to, lets say turn on a led, and maybe recive somthing from the PSoC to display on the app to start with, but i cant find any good guide on how to get startet. I've made some android apps, but never used BLE.
Here is my PSoC creator project: Project File
For the android studio app, I've startet a project, but I think i need some help: Android studio project
Regards Mads
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Additionally, you can find a video tutorial and source code for a simple BLE app in the links mentioned below:
- How to Create a PSoC Android BLE App: Lesson 1 Getting Started - YouTube
- https://www.cypress.com/training/psoc-4-ble-101-video-tutorial-series-how-create-products-using-psoc...
- bleapp/AndroidStudio/BLE101 at master · cypresssemiconductorco/bleapp · GitHub
Although this series makes use of PSoC4, the Android App side of it still remains the same and can be reused for PSoC6.
Regards,
Dheeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mads,
The source code for CySmart Android application is available for free. You can find the source files and corresponding documents here. You can use them as a starting point to analyze/reuse and understand the firmware flow.
https://www.cypress.com/documentation/software-and-drivers/cysmart-mobile-app
You can also use other company Android applications for BLE if they share the source code. Since the BLE is a universal standard protocol the vendor is independant.
Please use the above documentation and start writing the application. If you are stuck or if you need any information in particular please post in the same thread.
Hope this helps !
Thanks
Ganesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So I've made this app, where I find all BLE Devices with a name. But how can I make one of the specific fields, clickable and automatic connect to the device, so I can start writing/reading from it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In your MainActivity.java, you have the function OnItemClick that needs to be implemented to identify which device was clicked in the list. You can implement it something like this:
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Used in future BLE tutorials
if(parent == listView){BTLE_Device bleDevice = (BTLE_Device) parent.getItemAtPosition(position);
Utils.toast(getApplicationContext(), "Selected Device: " + bleDevice.getName());
Utils.toast(getApplicationContext(), "Device RSSI: " + bleDevice.getRSSI());
Utils.toast(getApplicationContext(), "Address: " + bleDevice.getAddress());
mBTLeScanner.connectDevice(getApplicationContext(), bleDevice.getAddress());
}
}
You need to then add the connectDevice function. I have added it to the file Scanner_BTLE.java for now. And to understand when the connection is successful you will need to implement GattCallbacks to track the various events. I have implemented the basic structure for these in the files attached. You can build on top of this.
Hope this helps
Regards,
Dheeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the input, I took some inspiration and did it like this Link to project
What I did is like you said, make a onItemClick, and this I made an intent with the mac adress, so I know what device i clicked. Then in the new activity I GettCallback, that i use in the onCreat.
First I get the device by It's MAC-addr: BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(DeviceAddress);
Then I use the GattCallback to conect: device.connectGatt(this, false, mGattCallback);mBTLeScanner.stop();
I think this might work, or should i impliment the gattCallback in Scanner_BTLE.java?
Another bug I found is when I click "Start scan" then it scans for devices 7,5sec but if i click my device after 2sec then it connects to the device, but then when the 7,5sec is done it dissconnect the device. It's because it's running stopScan(); --> mBTLeScanner.stop();
so i have to cancel this call somehow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you try increasing the connection interval (probably ~20ms)? Change the slave latency to 10. Check if it works with this change.
This issue was seen sometime back and this solution seemed to work for the user: Re: BLE disconnects immediately after connection
Regards,
Dheeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I dont think thats the issue here, i think it might be because the code is not all done yet.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use the CySmart app and verify if all the functionality is working correctly and if you can observe the same issue. If not, we can debug the custom Android app code. Since I don't see the PSoC Creator project attached, I just want to make sure that everything is working from the PSoC side.
Regards,
Dheeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So I'm creating a BLE connection between my PSoC 6 BLE and a Android App, the connection is etablished and works. But I dont get the read value from the PSoC.
If i use the app CySmart and read, it works perfectly. So I think i might do somthing wrong in my app part.
Here is the app: app Link
PSoC project: psoc Link
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Additionally, you can find a video tutorial and source code for a simple BLE app in the links mentioned below:
- How to Create a PSoC Android BLE App: Lesson 1 Getting Started - YouTube
- https://www.cypress.com/training/psoc-4-ble-101-video-tutorial-series-how-create-products-using-psoc...
- bleapp/AndroidStudio/BLE101 at master · cypresssemiconductorco/bleapp · GitHub
Although this series makes use of PSoC4, the Android App side of it still remains the same and can be reused for PSoC6.
Regards,
Dheeraj