Windows Phone 8.1 - Receive files with OBEX

1

i have successfully implemented a library for sending files over Bluetooth via Obex Object Push Profile on Windows Phone 8.1 app (C#). Anyway, I need to implement also the opposite direction (receive files via OPP) but I'm not able to find a way to override the already existing OPP system service. The problem is that when a file is sent from a device to my windows phone application, the system service 'catch' it first (and the message "DeviceX is sharing a file with you, receive content?" is shown). If i try to use RfcommConnectionTrigger and register a background task triggered by an incoming ObexObjectPush request, an exception raises: "The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)". I imagine that the other process is the system service. Anyone knows out to solve this? I report the code for the background task registration below:

        string taskName = RfcommServiceId.ObexObjectPush.AsString();
        if (BackgroundTaskRegistration.AllTasks.Values.SingleOrDefault(x => x.Name == taskName) == null)
        {
            RfcommConnectionTrigger trigger = new RfcommConnectionTrigger
            {

            };
            trigger.InboundConnection.LocalServiceId = RfcommServiceId.ObexObjectPush;//OPPprovider.ServiceId;

            BackgroundTaskBuilder builder = new BackgroundTaskBuilder
            {
                Name = taskName,
                TaskEntryPoint = "WP_OPPServerBackgroundTask.OppTask",
            };
            builder.SetTrigger(trigger);
            builder.Register();
        }

Thanks in advance for any hint on this topic Lorenzo

c#
windows-phone-8
bluetooth
windows-phone-8.1
obex
asked on Stack Overflow Oct 10, 2016 by LorenZ • edited Oct 10, 2016 by LorenZ

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0