-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add offset on file upload/download #145
Comments
The Lines 169 to 175 in 52d62ba
Lines 213 to 217 in 52d62ba
The How does your addition works and what are you using it for? |
We are uploading/Downloading a ~30MB file to/from our remote device at a slow rate (due to hardware limitations), so we need to continue the transfer of the file from the last offset. I see from the documentation that the upload/download commands are for a single packet and not for the rest of the file from a specific offset as we need: Lines 158 to 175 in 52d62ba
Lines 197 to 217 in 52d62ba
We added it to the |
OK, I get it. However, I believe the current
Have a look here: Android-nRF-Connect-Device-Manager/mcumgr-core/src/main/java/io/runtime/mcumgr/transfer/Uploader.kt Line 104 in 52d62ba
The first chunk (offset 0) is sent as a single packet. It is only after a response is received when the uploader starts several parallel uploads of following chunks, but the next offset is known at that point. You just need to make sure to reply with an offset equal to the length of "already received part" when you receive offset 0 of a file that you partially already have. |
Our use is to continue the upload on different days and connections, so we can't start sending the first packet from offset 0 every time. The same thing to downloading. If it is something that you are willing to add to the library I can attach our code for the |
I understand, but that doesn't change anything. The packet with offset 0 is sent to get the actual offset to start sending from. For example, on day 0 the uploader sends 100 packets with offsets 0-9999. On the following day the uploader again starts by sending packet with offset 0, but the device replies with a notification with offset 99999, so the next packet sent from the uploader will have offset 10000 and upload will resume. |
From our experience with the We first get the offset from the status method. Our fix for the open class FileUploader(
private val fsManager: FsManager,
private val name: String,
data: ByteArray,
offset: Int = 0,
windowCapacity: Int = 1,
memoryAlignment: Int = 1
) : Uploader(
data,
windowCapacity,
memoryAlignment,
fsManager.mtu,
fsManager.scheme,
offset
) { Then set the uploader's current offset to the passed offset: abstract class Uploader(
private val data: ByteArray,
private val windowCapacity: Int,
private val memoryAlignment: Int,
internal var mtu: Int,
private val protocol: McuMgrScheme,
private var currentOffset: Int
) { And send the initial chunk with the current offset: next.send(newChunk(currentOffset)) We implemented similar things in the |
It depends on what offset it returns after receiving the packet with offset 0 again. It should check that it already has the file with this name and return the size instead of removing it and returning the size of the received packet. |
What about downloading @philips77 i see that there is a new helper class for Uploading called FileUploader.kt |
Hmm.. I don't think there is. This is a good point. |
Hi,
Are you considering adding an offset to the FileUploader and file download?
We implemented this kind of feature with your library, in our project.
If you want to add this feature we can integrate it with you.
Best regards,
Tal
The text was updated successfully, but these errors were encountered: