New to Evothings, First Question

Ask, and ye shall receive.
DonPancoe
Posts: 25
Joined: 06:53, 20 Nov 2014
Location: Philadelphia, PA, USA
Contact:

New to Evothings, First Question

Postby DonPancoe » 21:26, 20 Nov 2014

I am excited to have just discovered Evothings and I fully intend to do my own reading and research, but I wondered if anyone could provide some hints to quickly get Evothings talking to my Microduino-BT, which is a BLE shield based upon the Huamao HM-10, which itself is based on the TI CC2540 BLE SoC. Any and all assistance will be most appreciated.

Don

ardiri
Posts: 58
Joined: 16:13, 28 May 2014

Re: New to Evothings, First Question

Postby ardiri » 11:25, 21 Nov 2014

this board is very similar to the Bluno - which was posted on a while ago here

viewtopic.php?f=3&t=140

on one of the links you provided; there was a zip file "BLE debug uart1.zip" that contains a .ino sketch. from what it looks like, Serial1 is used to directly access the BLE communications channel and you should be able to use any of our simple "Arduino BLE" examples to connect to it - all you need to know is the appropriate UUID for the board.

Code: Select all

String tmp="";

void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);
};

void loop() {

  while (Serial1.available() > 0)  {
    tmp += char(Serial1.read());
    delay(2);
  }

  if(tmp.length() > 0) {
    Serial.println(tmp);
    tmp = "";
  }

  if (Serial.available()) {
    Serial1.write(Serial.read());
  }
}


the Bluno uses the exact same TI BLE chip (CC2540) and you should able to use a BLE discovery tool such as LightBlue to see what services and characteristics exist on the device and try to connect to them directly - each manufacturer may have a different UUID and BLE name associated to each set of boards/shields.
// Aaron
Chief Technology Officer
Evothings AB http://www.evothings.com/

DonPancoe
Posts: 25
Joined: 06:53, 20 Nov 2014
Location: Philadelphia, PA, USA
Contact:

Re: New to Evothings, First Question

Postby DonPancoe » 16:29, 21 Nov 2014

Thanks for the info. I will try to play with it over the weekend.

I was worried that something non-standard might be going on in the microcontroller code on the HM-10, but you are right in that it has to be advertised as a standard service on the radio side in order for it to connect to other devices. I just need to learn what that service is and what its characteristics are.

Don

DonPancoe
Posts: 25
Joined: 06:53, 20 Nov 2014
Location: Philadelphia, PA, USA
Contact:

Re: New to Evothings, First Question

Postby DonPancoe » 19:38, 23 Nov 2014

Still working on this, but I will share as I go in case that helps anyone else.

Here is what I find using BLE Discovery...

Code: Select all

LOG: Stopping scan...
LOG: connect(00:17:EA:92:CC:1A)
LOG: connect 1 state 2
LOG: connected, requesting services...
LOG: s1: 0 00001800-0000-1000-8000-00805f9b34fb. 5 chars.
LOG:  c4: 00002a00-0000-1000-8000-00805f9b34fb. 0 desc.
LOG:   properties: PROPERTY_READ
LOG:   writeType: WRITE_TYPE_DEFAULT
LOG:  c5: 00002a01-0000-1000-8000-00805f9b34fb. 0 desc.
LOG:   properties: PROPERTY_READ
LOG:   writeType: WRITE_TYPE_DEFAULT
LOG:  c6: 00002a02-0000-1000-8000-00805f9b34fb. 0 desc.
LOG:   properties: PROPERTY_READ PROPERTY_WRITE
LOG:   writeType: WRITE_TYPE_DEFAULT
LOG:  c7: 00002a03-0000-1000-8000-00805f9b34fb. 0 desc.
LOG:   properties: PROPERTY_READ PROPERTY_WRITE
LOG:   writeType: WRITE_TYPE_DEFAULT
LOG:  c8: 00002a04-0000-1000-8000-00805f9b34fb. 0 desc.
LOG:   properties: PROPERTY_READ
LOG:   writeType: WRITE_TYPE_DEFAULT
LOG: s2: 0 00001801-0000-1000-8000-00805f9b34fb. 1 chars.
LOG:  c9: 00002a05-0000-1000-8000-00805f9b34fb. 1 desc.
LOG:   properties: PROPERTY_INDICATE
LOG:   writeType: WRITE_TYPE_DEFAULT
LOG:   d11: 00002902-0000-1000-8000-00805f9b34fb
LOG: s3: 0 0000ffe0-0000-1000-8000-00805f9b34fb. 1 chars.
LOG:  c10: 0000ffe1-0000-1000-8000-00805f9b34fb. 2 desc.
LOG:   properties: PROPERTY_READ PROPERTY_WRITE_NO_RESPONSE PROPERTY_NOTIFY
LOG:   writeType: WRITE_TYPE_NO_RESPONSE
LOG:   d12: 00002902-0000-1000-8000-00805f9b34fb
LOG:   d13: 00002901-0000-1000-8000-00805f9b34fb
LOG: rd 13
LOG: rdw 13: HMSoft

I've downloaded this Android app (apk) from Huamao, http://huamaosoft.cn/HMBLEComAssistant.rar, and used it to get bi-directional serial communication working over BLE between a Nexus 7 and my laptop with a USB-TTL converter. I also de-compiled and examined the code, but it seems quite complicated for the simple function it is performing (basically a serial terminal). It will take me a while to fully understand it, if I even can with reasonable effort, but I did find explicit references to UUID_NOTIFY being ffe1 (c10) and UUID_SERVICE being ffe0 (s3). Curious what the other UUIDs are for, and wondering if they might be something useful.

Don

DonPancoe
Posts: 25
Joined: 06:53, 20 Nov 2014
Location: Philadelphia, PA, USA
Contact:

Re: New to Evothings, First Question

Postby DonPancoe » 21:39, 24 Nov 2014

I was successful in sending ASCII chars from the Evothings app to the Microduino-BT/HM-10 with the Arduino LED On/Off BLE example. I had to first change the code of index.html starting at line 92 so that it would connect specifically to my BLE device. Just FYI, the default name of the HM-10 is "HMSoft" but I changed that to "HMSoft531" to indicate this particular device has been flashed with the latest firmware, v5.31.

Code: Select all

      evothings.arduinoble.connect(
         'HMSoft531', // Name of BLE shield. << was 'arduinoble'
         function(device)
         {
            app.device = device;
            app.showMessage('Connected! Touch buttons to turn LED on/off.');
         },
         function(errorCode)
         {
            app.showMessage('Connect error: ' + errorCode + '.');
         });

Next, I needed to edit arduinoble.js to write to the proper characteristic of the HM-10 (0xffe1), starting at line 97,

Code: Select all

      device.writeDataArray = function(uint8array)
      {
         device.writeCharacteristic(
            '0000ffe1-0000-1000-8000-00805f9b34fb', // << was '713d0003-503e-4c75-ba94-3148f18d941e'
            uint8array,
            function()
            {
               console.log('writeCharacteristic success');
            },
            function(errorCode)
            {
               console.log('writeCharacteristic error: ' + errorCode);
            });
      };

Lastly, I had to change the write command to send the specific value I wanted to send. Starting from line 66 of index.html,

Code: Select all

   app.ledOn = function()
   {
      app.device && app.device.writeDataArray(new Uint8Array([102])); // '102' is ASCII char 'f', value was '1'
   }

I also figured out I could transmit multiple chars/bytes at once since the HM-10 can send up to 20 bytes at a time (per the BLE specification). I simply separated the bytes in the array by commas. For example to send the ASCII string 'fgh' I would send Uint8Array([102,103,104]).

I am now trying to set up bi-directional communication between the app and the peripheral. However, in the Arduino BLE example, specifically app.js, it is written based on the peripheral having separate characteristics for write and read, whereas the HM-10 seems to only have one for both (0xffe1 is the only characteristic of service 0xffe0 advertised). I will continue to work on that but, again, any hints would be most appreciated.

Thanks,
Don

User avatar
micke
Posts: 256
Joined: 20:49, 18 Nov 2013

Re: New to Evothings, First Question

Postby micke » 15:48, 27 Nov 2014

Hi Don,

Thanks a lot for sharing your findings. I guess you could just test to use the single characteristic available for both reading and writing. Don't have personal experience from this particular case, but it would be straightforward to try. I don't know about setting up notifications on the characteristic and at the same time write to it. Perhaps that would work too, but I would start with the basic case of "normal" reading and writing. Did some googling for this, but did not find anything.

Best, Mikael


Return to “Questions and answers”

Who is online

Users browsing this forum: No registered users and 17 guests