Reply
Posts: 28
Registered: ‎10-19-2015
Accepted Solution

BLE113 Firmware update only works once

Hi,

 

I'm currently developing a firmware for the bluegiga BLE113. I'm using the DKBLE Development Kit for flashing the firmware. Updating the firmeware using the BLW SW Update Tool works fine, but only once. If I change something within the code afterwards the new firmeware will not be updated, although the Update Tool says otherwise.

 

Is there some kind of cache or do I miss something will updating my firmeware? I've attached my BGDemo project containing my current firmeware.

 

Thanks in advance.

 

Florian

Posts: 2,738
Registered: ‎09-01-2015

Re: BLE113 Firmware update only works once

How are you testing your design? If you are using iPhone as the remote device, then iPhone will keep a copy of the GATT database in cache.

 

If you change your GATT and update firmware, the iPhone app may still show the old GATT because it is using the cached data.

 

If this is the case, one easy workaround seems to be turn Bluetooth off and then back on.

Posts: 28
Registered: ‎10-19-2015

Re: BLE113 Firmware update only works once

Hi,

 

thanks for the workaround. You were right. I had to reset the iPhones cache in order to see the new characteristics. But still it did solve all of my problems concerning the update.

 

In my gatt.xml I have two manufacturer specific characteristics within my own service. Yet, if a use: 

 

# connection event listener
event connection_status(connection, flags, address, address_type, conn_interval, timeout, latency, bonding)
	# device now connected
	call attributes_write(testvalue,0,10,"Hello Test")

end

 my iPhone App onyl receives a nil-value within the desired characteristic. My gatt.xml's configuration looks like this:

	<!-- Manufacturer specific, use for own characteristics -->
	<service uuid="20020db0-73d9-11e5-8bcf-feff819cdc9f" advertise="true">
		<description>Test Values</description>
		<characteristic uuid="18f115da-756d-11e5-8bcf-feff819cdc9f" id="button1value">
			<properties read="true" write="true"/>
			<value type="utf-8" variable_length="true"/>
		</characteristic>
		
		<characteristic uuid="3872bb56-73d9-11e5-8bcf-feff819cdc9f" id="testvalue">
			<properties read="true" write="true"/>
			<value type="utf-8" variable_length="true"/>
		</characteristic>
	</service>

What am I missing?

 

Thanks in advance again!

 

 

Posts: 2,738
Registered: ‎09-01-2015

Re: BLE113 Firmware update only works once

Are you using some 3rd party iOS app for testing or have you written your own app?

 

Are you sure that you are using the correct handle when reading the values from the remote device? The attribute handles are found in attributes.txt, in your case it is like this:

button1value 13
testvalue 15

 

Have you tried reading some of the other characteristics, like the Device Name (UUID 2A00)?

 

Posts: 28
Registered: ‎10-19-2015

Re: BLE113 Firmware update only works once

I'm using my own app. Currently I'm using the CoreBluetooth Framework from Apple as described in this link: Apple-CoreBluetooth under iOS 9 with Swift 2 as programming language.

 

Yes, I've tried other characteristics like Device Name (UUID 2A00) which work as designed. What do you mean with correct handle? Because in iOS I can only check for certain UUIDs not for IDs as used in the gatt.xml file. For example:

 

    func peripheral(peripheral: CBPeripheral, didUpdateNotificationStateForCharacteristic characteristic: CBCharacteristic, error: NSError?) {
        if(BLE_CHARACTERISTICS.contains(characteristic.UUID)){
            print("Got new notification for new value for characteristic", characteristic.UUID)
            if(characteristic.value != nil){
                let str = Utility.hex2Unicode(characteristic.value)
                delegate.updateForCharacteristic(characteristic, value: str) // notify delegates
            }else{
                print("Value received was unfortunately nil :-(")
            }
        }
    }
Posts: 2,738
Registered: ‎09-01-2015

Re: BLE113 Firmware update only works once

OK, I am not at all familiar with app development for iOS.

 

One thing you could try: use some generic 3rd party app (such as BLExplr) and try to see if your custom characteristic can be read with that. If it works, then you know the problem is in your own phone app. If it doesn't, then the problem must be in the module firmware.

 

Posts: 28
Registered: ‎10-19-2015

Re: BLE113 Firmware update only works once

I tried BLExplr, but unfortunately the App hangs up while reading the characteristics of my own service. First I thought it was my app but I had the same problems while using the firmware which comes with the DKBLE Dev Kit.

	<service uuid="81b22eb3-83f0-400a-af03-c5dd7724caf9" advertise="true">
		<description>Test Values</description>
		<characteristic uuid="029e0b8a-54e9-407b-a393-6c4cb3c3b133" id="button1value">
			<properties read="true" write="true"/>
			<value type="utf-8" variable_length="true" length="255"/>
		</characteristic>
		
		<characteristic uuid="25c75354-98f5-4090-967f-bcd6ab000a9c" id="testvalue">
			<properties read="true" write="true"/>
			<value type="utf-8" variable_length="true" length="255"/>
		</characteristic>
	</service>

When using the variable_length attribute in the value tag of the characteristic: Do I need to also define the length attribute or is this only optional in this case? And furthermore do I need to set a "default" value in the gatt.xml or is a closing tag also possible as used in my code above?

 

 

 

Posts: 2,738
Registered: ‎09-01-2015

Re: BLE113 Firmware update only works once

For variable length characteristics, you need to specify also the maximum length. This is mentioned in Bluetooth Smart Profile Toolkit Developer Guide, Section 4.2.3.

 

Example: <value variable_length="true" length="20" />

 

Same document as mentioned above, page 13: "There are two ways to specify the length (in bytes) of a characteristic. One way is to use the length="..." attribute

inside the <value> tag, and the other is to provide the information as the tag content."

 

So if you use the "length" attribute in your XML there is no need to set the default value. And default value for non-const values is actually not a default value, it is just an alternative way to specify how much space needs to be allocated for the value. The default / initial value must be set at runtime by your application.

 

 

 

Posts: 28
Registered: ‎10-19-2015

Re: BLE113 Firmware update only works once

Ok, so just for clarification: my code as mentioned below is correct and should send a test message if a device connects to my BLE113 peripheral?

 

gatt.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<configuration>

    <service uuid="1800">
      <description>Generic Access Profile</description>

      <characteristic uuid="2a00">
        <properties read="true" const="true" />
        <value>Device Name</value>
      </characteristic>

      <characteristic uuid="2a01">
        <properties read="true" const="true" />
        <value type="hex">0832</value>
      </characteristic>
	  
    </service>

    <service uuid="180A" >
	
        <characteristic uuid="2A29">
            <properties read="true" const="true" />
            <value>Name</value>
        </characteristic>
		
        <characteristic uuid="2A24">
            <properties read="true" const="true" />
            <value>Device Name</value>
        </characteristic>
		
		
		
    </service>
	
	<!-- Manufacturer specific, used for own characteristics -->
	<service uuid="81b22eb3-83f0-400a-af03-c5dd7724caf9" advertise="true">
		<description>Test Values</description>
		<characteristic uuid="029e0b8a-54e9-407b-a393-6c4cb3c3b133" id="button1value">
			<properties read="true" notify="true" write="true"/>
			<value variable_length="true" length="255"/>
		</characteristic>
		
		<characteristic uuid="25c75354-98f5-4090-967f-bcd6ab000a9c" id="testvalue">
			<properties read="true" notify="true" write="true"/>
			<value variable_length="true" length="255"/>
		</characteristic>
	</service>
	
</configuration>

and BGS-File:

# Boot Event listener
event system_boot(major, minor, patch, build, ll_version, protocol_version, hw)
	
	#Enable IO interrupts from PORT 0 PINs P0_0 and P0_1 on rising edge
    call hardware_io_port_config_irq(0,$3,0)
	
	# set bondable mode
	call sm_set_bondable_mode(1)
	
	#set to advertising mode
	call gap_set_mode(gap_general_discoverable, gap_undirected_connectable)
end

# connection event listener
event connection_status(connection, flags, address, address_type, conn_interval, timeout, latency, bonding)
	# device now connected
	call attributes_write(testvalue,0,4,"Blub")
end

#GPIO interrupt listener
event hardware_io_port_status(delta, port, irq, state)
	call attributes_write(button1value,0,4,"Test")
end

 

By the way: I'm also wondering why my button pressed event will not be recognized although I've implemented the hardware_io_port_status method an set the irq.

 

 

Posts: 2,738
Registered: ‎09-01-2015

Re: BLE113 Firmware update only works once

I tested running your code on BLE113 and reading the custom characteristics did not work. I then changed the length from 255 to 254 and I was able to read the "Blub" value using BLE GUI and BLED112 dongle in the remote end.

 

I was also able to read the "Test" string from the 2nd characteristic, indicating that button interrupt works as expected.

 

I need to check why having a characteristic with length 255 does not work. Based on our documentation the valid range should be 0..255  bytes.

 

 

Highlighted
Posts: 28
Registered: ‎10-19-2015

Re: BLE113 Firmware update only works once

Thanks alot for the last tipp! It worked as described. Problem was, that I was using 255 instead of 254 bytes as maximum length for the property of my characteristics.