You are here

Adding HM-10 Compatibility with Small Changes to Code

6 posts / 0 new
Last post
Jfriesen
Offline
Last seen: 1 month 2 weeks ago
VESC Free
Joined: 2017-10-24 22:49
Posts: 8
Adding HM-10 Compatibility with Small Changes to Code

Hello! I've been playing with a forked version of the vesc-tool and just found an easy way to add HM-10 compatibility alongside the NRF chip which is currently supported. The NRF chip is superior since it can operate at 115200 Baud and I find the HM-10 is stable only to 19200 Baud. I'd make this a pull request, but code is forked and now head is a few commits in front, also the changes are minimal so I'll just outline here. The key thing I found that made this easy was an AT command which creates adds a second characteristic to the HM-10 service UUID. You will need to access the hardware serial of your HM-10 module and send the following AT command (thorough guide here):

AT+FFE21

While your at it you may want to set your BAUD to 19200 to maximize data rate with the following AT command:

AT+BAUD1

The service UUID is different for the HM-10 as compared to the vesc-tool so there's a couple snippets that need to be added to bleuart.cpp to try both UUIDs. First I create to UUIDs to try:

    mServiceUuidtry1 = "0000ffe0-0000-1000-8000-00805f9b34fb";
    mRxUuidtry1 = "0000ffe2-0000-1000-8000-00805f9b34fb";
    mTxUuidtry1 = "0000ffe1-0000-1000-8000-00805f9b34fb";
    mServiceUuidtry2 = "6e400001-b5a3-f393-e0a9-e50e24dcca9e";
    mRxUuidtry2 = "6e400002-b5a3-f393-e0a9-e50e24dcca9e";
    mTxUuidtry2 = "6e400003-b5a3-f393-e0a9-e50e24dcca9e";

These new variables will also need to be declared in the header file.

Then the service discovered method just needs a slight modification to check both possible services:

void BleUart::serviceDiscovered(const QBluetoothUuid &gatt)
{
    if (gatt==QBluetoothUuid(QUuid(mServiceUuidtry1))){
        mServiceUuid = mServiceUuidtry1;
        mRxUuid = mRxUuidtry1;
        mTxUuid = mTxUuidtry1;
        qDebug() << "BLE UART service found!";
        mUartServiceFound = true;
    }
    if (gatt==QBluetoothUuid(QUuid(mServiceUuidtry2))){
        mServiceUuid = mServiceUuidtry2;
        mRxUuid = mRxUuidtry2;
        mTxUuid = mTxUuidtry2;
        qDebug() << "BLE UART service found!";
        mUartServiceFound = true;
    }
}

Cheers,

Jeff

Roger Wolff
Offline
Last seen: 5 months 2 weeks ago
VESC FreeVESC Original
Joined: 2017-05-24 12:27
Posts: 202

 

I wrote this without much formatting and then went back to edit it. I select the commands (one at a time), hit "quote" to make that single line into a quote to distinguish it from the rest. When that doesn't do what it does in 1000 other editors. I'm sorry, but you're left with a mess. 

 

you might be able to do someting with git. Something along the lines of: 
git remote add vedder <url of vedders repository>

Now 

git pull vedder master

will pull vedder's master into your code 

and assuming that your repo is setup to follow your own github stuff,

git push

will upload your repo to the latest with your changes. And a pull request will be uptodate wrt the current code. 

 

 

CTSchorsch
Offline
Last seen: 2 months 2 weeks ago
VESC Free
Joined: 2018-07-13 09:55
Posts: 101

Hi Jfriesen,

i bring this topic back to top :)

I tried to modify my vesc-tool sources in your way to use the hm-10. i compieled well, the hm-10 is detected on the bluetooth le tab, but i can not connect to the vesc.

Debug Output:

qt.bluetooth.bluez: Missing CAP_NET_ADMIN permission. Cannot determine whether a found address is of random or public type.

DEBUG (../vesc_tool/bleuart.cpp:137 void BleUart::addDevice(const QBluetoothDeviceInfo&)): BLE scan found device: "HMSoft"

WARNING (:0 ): Enabling GATT request timeout behavior 20000

DEBUG (../vesc_tool/bleuart.cpp:154 void BleUart::scanFinished()): BLE scan finished

WARNING (../vesc_tool/bleuart.cpp:213 void BleUart::controllerError(QLowEnergyController::Error)): BLE error: QLowEnergyController::Error(UnknownError)

WARNING (:0 ): void QBluetoothSocketPrivate::_q_readNotify() 27 error: -1 "Die Ressource ist zur Zeit nicht verfügbar"

WARNING (../vesc_tool/bleuart.cpp:213 void BleUart::controllerError(QLowEnergyController::Error)): BLE error: QLowEnergyController::Error(UnknownError)

DEBUG (../vesc_tool/bleuart.cpp:226 void BleUart::deviceDisconnected()): BLE service disconnected

 

The modified code ist not executed, my in the serviceDiscovered function is not reached..

 

do have any hint for me ?

 

jesusc
Offline
Last seen: 1 week 2 days ago
VESC Free
Joined: 2019-09-09 07:48
Posts: 6

any news?

jesusc
Offline
Last seen: 1 week 2 days ago
VESC Free
Joined: 2019-09-09 07:48
Posts: 6

any news?

CTSchorsch
Offline
Last seen: 2 months 2 weeks ago
VESC Free
Joined: 2018-07-13 09:55
Posts: 101

Hi,

my Problem was the baud-rate. The HM10 is too slow for 115200, with 9600 everyting works fine

Georg