Windows Mobile (C#) - Communicating between phone and PC

和自甴很熟 提交于 2019-12-03 07:54:43

问题


I'm working on a project where a program running on the mobile phone needs to communicate with a program running on the PC it's connected to. Ideally, I'd like to use USB, WiFi, whatever to communicate.

The two programs should be able to communicate things like battery life, text messages, etc... But I can work on that later, I just need to get them to talk.

What's the best way to do this?


回答1:


"Best" is really subjective and highly dependent on a lot of factors like devices, topology, firewall presence, need for security, etc, etc.

Where do you need the comms to originate and will you have an ActiveSync connection? If the PC initiates the comms and you have ActiveSync, then RAPI is the transport you'd use as it's got all of the infrastructure done and ready.

For anything else you're going to need some form of proprietary protocol and transport mechanism. Typically I write a simple socket protocol with a defined message structure (typically a message ID, CRC, message length and data payload). I then have some base message class that handles the comms and a set of derived messages for each specific command I want. For 2-way stuff that requires a response, I typically create a base Response class and then derive specific response formats from it.




回答2:


Assuming you have a wifi connection, one way for your Windows Mobile program to communicate with your PC would be to use WCF on the .NET compact framework 3.5.

You'd create a new WCF application to run you your PC, and expose an interface exposing functions you want to call from your Windows Mobile Device.

WCF on Windows Mobile requires Compact Framework 3.5 to be installed on your device. You also need the "Windows Mobile power toys" to be able to generate compatible proxies to call from Windows mobile.

Power Toys for .NET Compact Framework 3.5

Calling the WCF service from your WM Device also requires you to manually set up the binding and endpoint to pass into your web service proxy (with desktop WCF this is done automatically by loading them from a config file).

WCF on Windows Mobile currently only supports the basic http binding (which can be encrypted if you want), but this may be enough for your needs.




回答3:


You might try looking into the OpeNETCF.Desktop.Communications library. You can start at http://www.opennetcf.com/FreeSoftware/tabid/84/Default.aspx and follow the links to find the necessary downloads. (I think you may need to get it from their subversion repository).




回答4:


WIMO is working on WiFi to desktop support and may be done. Might be worth a look at the code either way.

home

source




回答5:


found this in 2015, so I don't think the answer is going to be relevant for the original asker, but for the record: Proximity https://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh465205.aspx



来源:https://stackoverflow.com/questions/344335/windows-mobile-c-communicating-between-phone-and-pc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!