From 1380508aa801e50df0523ebeefbb800c456b1b3a Mon Sep 17 00:00:00 2001 From: Aleksander Nowakowski Date: Thu, 17 Sep 2015 10:39:32 +0200 Subject: [PATCH] Documentation for DFU settings constants. --- .../android/dfu/DfuSettingsConstants.java | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/DfuSettingsConstants.java b/dfu/src/main/java/no/nordicsemi/android/dfu/DfuSettingsConstants.java index 46311e1..620f99d 100644 --- a/dfu/src/main/java/no/nordicsemi/android/dfu/DfuSettingsConstants.java +++ b/dfu/src/main/java/no/nordicsemi/android/dfu/DfuSettingsConstants.java @@ -22,11 +22,62 @@ package no.nordicsemi.android.dfu; +import android.bluetooth.BluetoothGattCharacteristic; + public interface DfuSettingsConstants { + /** + * This property must contain a boolean value. + *

If true (default) the Packet Receipt Notification procedure will be enabled. See DFU documentation on http://infocenter.nordicsemi.com for more details. + * The number of packets before receiving a Packet Receipt Notification is set with property {@link #SETTINGS_NUMBER_OF_PACKETS}. + */ public static final String SETTINGS_PACKET_RECEIPT_NOTIFICATION_ENABLED = "settings_packet_receipt_notification_enabled"; + + /** + * This property must contain a positive integer value, usually from range 1-200. + *

The default value is {@value #SETTINGS_NUMBER_OF_PACKETS_DEFAULT}. Setting it to 0 will disable the Packet Receipt Notification procedure. + * When sending a firmware using the DFU procedure the service will send this number of packets before waiting for a notification. + * Packet Receipt Notifications are used to synchronize the sender with receiver. On Android, calling {@link android.bluetooth.BluetoothGatt#writeCharacteristic(BluetoothGattCharacteristic)} + * will simply add the packet to outgoing queue before returning the callback. Adding the next packet in the callback is much faster than the real transmission (also the speed depends on + * the device chip manufacturer) and the queue may reach its limit. When does, the transmission stops and Android Bluetooth hangs. Using PRN procedure eliminates this problem as + * the notification is send when all packets were delivered the queue is empty. + */ public static final String SETTINGS_NUMBER_OF_PACKETS = "settings_number_of_packets"; + + /** + * The default value of {@link #SETTINGS_NUMBER_OF_PACKETS} property. Different phones sent a different number of packets each connection interval. The values are (for tested phones): + *

+ * The least common multiplier is 12 which is reasonably small. You may try other values, like 24 etc. Values higher than ~300 may cause the Bluetooth outgoing queue overflow error. + */ + public static final int SETTINGS_NUMBER_OF_PACKETS_DEFAULT = 12; + + /** + * This property must contain an integer value. + *

Size of the MBR (Master Boot Record) for the target chip. This applies only if you are using HEX files. The HEX_to_BIN parser included in the library will skip the addresses + * from 0 to this value. By default for nRF51 and the SoftDevice S110 this value is equal 4096 (0x1000 HEX) and for nRF52 has to be changed to 12288 (0x3000). If you want to send + * a firmware in HEX onto another MCU via nRF chip, set this value to 0. + *

If you are using the PC nrf util tool to create a ZIP Distribution Packet with the firmware and Init Packet this option does not apply as the nrf tool will convert HEX to BIN itself. + */ public static final String SETTINGS_MBR_SIZE = "settings_mbr_size"; + + /** + * The default value of the MBR size. + * @see #SETTINGS_DEFAULT_MBR_SIZE + */ public static final int SETTINGS_DEFAULT_MBR_SIZE = 0x1000; - public static final int SETTINGS_NUMBER_OF_PACKETS_DEFAULT = 10; + + /** + * This property must contain a boolean value. + *

The {@link DfuBaseService}, after connected to a DFU target will check whether it is in application or in DFU bootloader mode. For DFU implementations from SDK 7.0 or newer + * this is done by reading the value of DFU Version characteristic. It the returned value is equal to 0x0100 (major = 0, minor = 1) it means that we are in the application mode and + * jump to the bootloader mode is required. + *

However, for DFU implementations from older SDKs, where there was no DFU Version characteristic, the service must guess. If this option is set to false (default) it will count + * number of device's services. If the count is equal to 3 (Generic Access, Generic Attribute, DFU Service) it will assume that it's in DFU mode. If greater than 3 - in app mode. + * This guessing may not be always correct. One situation may be when the nRF chip is used to flash update on external MCU using DFU. The DFU procedure may be implemented in the + * application, which may (and usually does) have more services. In such case set the value of this property to true. + */ public static final String SETTINGS_ASSUME_DFU_NODE = "settings_assume_dfu_mode"; }