Android Question Create your own peripheral service

Hirogens

Active Member
Licensed User
Longtime User
Hi all,

I have a question about the peripheral library BLE2Peripheral v1. I followed the tutorial from Erel here https://www.b4x.com/android/forum/threads/ble-peripheral.84051/

I have tested it and it's working well (thanks you for this). But what I want to do is simulating an existing device I have and on the peripheral side, I cannot change anything :
It creates a service (UUID = 0001) with two characteristics:
ReadChar (1001) - Other devices should subscribe for notifications on this characteristics.
WriteChar (1002) - Other devices can write to this characteristic.

I want to create my own service with my own UUID and own characteristics inside. I guess it's hard coded in the library or in Peripheral_start() method, so how can I change it or redefine it ? If it's not possible with this library, what can be a solution ?

Thank you !
 

DonManfred

Expert
Licensed User
Longtime User
I guess it's hard coded in the library
they are defined in the hardware.
The BLE just request them from the Hardware...

You can not create your own as far as i know.
 
Upvote 0

Hirogens

Active Member
Licensed User
Longtime User
So you are saying that the phone's hardware using as peripheral can only provide this service with a readChar and writeChar. You cannot add another one with another UUID ? Humm and for example if you want to simulate a DFU on a phone you cannot ? Because you need to create a new service anyway.
 
Upvote 0

Hirogens

Active Member
Licensed User
Longtime User
I investigated the problem and yes I found the code of the start method in the library :

libraryBLEperipheral.PNG


So apparently, the only thing is that it's not possible in B4A yet. I will try to do it in java instead on my peripheral device and I will keep my central device app in B4A. Thank you for your answer :)
 
Upvote 0

Hirogens

Active Member
Licensed User
Longtime User
Yes thank you. I modified the code of the library to add my own UUID and created a new B4A library. Just modifying this, the device is not visible anymore on nrfConnect. Do you know why ? it's a custom UUID, randomly generated, and just changing the "return" line in longUUID() method, device is not detectable... I read the doc (android and BLE), but maybe I missed something.
Thank you for your answer
(Do i need to open a new thread ?)
 
Last edited:
Upvote 0
Top