I am working on using a Raspberry Pi in an embedded project that will utilize wifi to communicate with external devices. The device should be able to act either as a standalone wifi hotspot that devices can connect to or in the case of the presence of an existing wifi network it should connect to that network so that the user does not have to give up his internet connection in order to connect to the device. I plan on making the device start up in hotspot mode, the user can then use the web interface to enter the details of a network that he wants the device to connect to, whenever the specified parameters fails to establish a connection then it defaults back to hotspot mode.
Now the technical stuff I am struggling with is that I want to implement the control software in C# running with Mono on Arch Linux on the Rapsberry Pi. I am struggling the find the Apis or libraries needed to manage the Linux wifi connection. On Windows it seems as if managedwifi.codeplex.com can be used but it does not seem to be compatible with Linux.
My last resort would obviously be to execute shell commands and then parse their outputs, but considering how crude and possibly unreliable that would be this is obviously my last resort.
Any ideas regarding what I should do?
PS. Another thing I might consider before using shell scripts, if it makes a difference is to use Raspbian or some other distro instead.
Actually calling shell commands from a managed code is not a very bad idea. They are reliable, very well tested and mostly lightweight and sometimes just a wrapper around kernel or other modules function. This is also seems to be the same method Node.js modules use when they want to access something lowlevel or related to networking. For example see this source code: node-wireless/node_modules/wireless/index.js
If you don't like it this way there is always "Interop". The same way that you can DllImport() libraries in Windows, you can do in Linux. See here: http://www.mono-project.com/Interop_with_Native_Libraries
IMHO the second solution doesn't worth the effort. Calling shell commands is elegant and neat enough.
my pi is starting into wlan0 as AP with hostapd, when a AP also a lighttpd is starting and give a web interface do change the settings. the web interface verify and write the input in a sqlite3. a second script is doing the canges according to my changes. (like add, edit or remove wifis in wpa_supplicant, reset wlan0 to be a part of an existing wlan like set to dhcp, tell wpa_supplicants...)
except the lighttpd and sqlite3 all components are already on the Raspery. you dont need any mono or c-libraries
for writing the scripts i use python but also perl is working (even php for the frontend)
Related
I'm currently attempting to use multiple Kinect v2.0s as part of my dissertation. I've looked around on the subject and I'm aware of the issue with usb bandwidth so the two Kinects I'm currently using are on different usb controllers.
The issue I'm having is that as part of the GetDefault() function (2.0 SDK) it, as the name suggests, simply gets the default Kinect. Is there a way of either determining which Kinect to 'get' or determining which Kinect is the 'default'? (I know the SDK only allows for one but I'm exploring the idea of having a separate application handling each Kinect).
Thanks in advance for any input.
Using the Microsoft SDK you don't have a chance to use multiple Kinect2 on one PC:
Sensor Acquisition and Startup
Kinect for Windows supports one sensor, which is called the default sensor. The KinectSensor Class has static members to help configure the Kinect sensor and access sensor data.
Kinect API Overview
We tried similar things, but in the end we settled with a client/server-Solution where additional Kinects are connected to client PCs. But, even here you need to be careful if those Kinects are used in the same room - the sensors might pick up light from the other emitters! (see here e.g.: Interference between multiple Kinects).
Another thing you need to keep in mind when working on an client/server-solution - the Kinect does not handle Remote Desktop Connections very well:
Remote Desktop
If you are accessing the Kinect using Remote Desktop, You must change the remote desktop audio settings to "play on remote machine". If you do not do this, the runtime will not be able to see the audio device, and may disallow connection to the Kinect. (2.0 SDK and Developer Known Issues)
Another way you could choose, is use OpenKinect, which is supposed to support multiple cameras (here, here, here, ...) but all this seems not so easy to achieve too. Also, during our tests we noticed that the depth values are different when using the official Microsoft SDK or the open source library, since there is a lot of black-box-magic happening in the official SDK.
Have you considered running a virtual machine in parallel on your machine? Just have the virtual machine ignore the USB port that one of the kinects is on so the virtual machine is forced to use the other one.
This may require way more processing power than just plugging them in, but it should work, especially if you are trying to use them for two different programs.
Kinect for windows are only supported for virtual machines, (not including kinect for xbox one and kinect for 360 with adapters)
I am writing an application in C#, to connect to a Bluetooth breakout chip.
From my understanding, Windows assign a COM port to the device; so I can connect to it. Although, I do not understand how to retrieve the name of the device associated to a specific port.
At the moment I retrieve all the COM, and then since I know which port is working for the BT device, I open the connection manually with a button.
The objective here is to turn on the device, and if the device is paired; it will connect automatically.
Unless I got it wrong; when you pair a Bluetooth device, it get assigned to a COM port; so it should be possible to retrieve the device name/BT name, interrogating the COM port? In this way I can scan all the ports; check which port is assigned to that device name and open automatically the connection.
Is this correct or there is a different way to achieve what I want to achieve?
So far, I found no quick way to do so, nor an API from Windows or .NET that allow you to do such an easy thing, like get info about a COM port. Either nobobody works with Bluetooth on serial, or it must be so horrible that not even Microsoft wanted to put efforts in allowing this info to be obtained.
Beside the very convoluted ways to get the info, raging from registry inquire to introspection on different levels; I found this add on called 32feet for .NET; which allow to actually do what I was trying to achieve.
The code is pretty simple; and the object created has the info about the friendly name used in the Bluetooth peripherals screen, and is able to return also the port that is bound to that device, once it connects.
Quite a surprise that I have to use an external solution, while I was expecting that it would be exposed somehow through the standard API in Windows. Although it works, problem solved!
IF I find a different way to do the same, and that does not require more overhead than what you really need, I will post it here.
I am totally new to using C# for networking purposes, can anyone show me in an easy way how to create in a few lines a console application that reads the IP information (Packets)..."Sniffer", i dont need a class or anything.. just in the main program 2 or three lines that would give me this information.
Thank you guys
This is not possible to do in a two or three line C# program. You need to replace the winsock driver in the operating system itself so that the operating system will show you packets intended for others, and you can't put managed code into the kernel like that. This is why software like Wireshark usually also requires you to install WinPcap. That said, after winpcap is installed on a system C# can control it and use it to capture packets.
I'm thinking of writing an app to selectively transfer photos/music to and from my iPhone, mostly for fun and personal convenience. However, I'm stuck at the very beginning -- where do I look to find information on how to do this?
Pretty much every link I see talks about developing applications that run on the iPhone, but nothing about desktop app for interfacing with an iPhone.
I'm on Windows (no access to a Mac, but I'll take suggestions for that for when I eventually acquire one), and I'm most familiar with C#, but other languages are definitely an option.
Can anybody offer me a few pointers on getting started? Thanks.
Edit: to clarify further, I don't need information on how to write applications that run ON the iphone. There are plenty of resources out for that. :) What I'm looking for it some pointers on how to "talk" to an iPhone or an iPod through the USB cord, if that's even possible.
Edit #2: I found libmobiledevice library that effectively does what I'm talking about on Linux. I don't think I'm too keen on attempting to port it over to Windows, though. :)
I found what I was looking for: SharePodLib. Thanks, everyone.
I recommend and have used the following options:
Option 1:
Run a small and light webserver in the iPhone and of course, use HTTP to transfer. I recommend mongoose websever, i've tried it with very simple and very heavy load. Also here, you can find an actual drag and drop project to deploy this webserver in the iPhone.
Option 2:
Use something like Bonjour, this is something very useful if you want the "smart" discovery of your device in the network, maybe for opportunistic peer discovery. You can check here and here, to understand how to get bonjour to run in the iPhone and use it to exploit discovery and sharing.
Hope it helps!!
Unfortunately, there's no no way to sync an iPhone app with a Mac app over USB, at least in the current SDK. As already stated, you'll have to either sync over HTTP or use the local network. You might want to check out ZSync, a Cocoa library for bonjour syncing (I haven't used it, and it's in early development stages, but it looks interesting).
Unfortunately there is no officially sanctioned method to do what you describe. In Apple's view the only application that should have visibility of that information is iTunes. There are applications out there that appear to be able to do this, but I suspect they have reverse engineered the USB protocol and are thus open to being locked out if the protocol changes.
I have the following problem:
I implemented a managed mobile application for Windows Mobile devices using the C# Bluetooth library of InTheHand.
Now I figured out that the new devices of HTC will all have the Widcomm Bluetooth stack instead of the Microsoft Bluetooth stack...
Does anybody know some working C# library for the Widcomm Bluetooth stack? And also how limited the widcomm api is, concerning e.g. being able to turn bluetooth on/off or having an Obex listener?
Thanks for any hints!
Firstly the disclaimer, I'm the maintainer of the 32feet.NET library. :-)
Version 2.4 of 32feet.NET from InTheHand includes Widcomm/Broadcom support. Have you tried that? I get the feeling you might have...
To run ObexListener firstly we'd need a way to disable Widcomm's built-in OBEX server (if that can be done I can make the changes necessary to have ObexListener run). There might be support for enabling/disabling the radio on CE/WM -- I think that API is missing on Win32 however.
The other options with ObexListener are to run it on a personal Service Class Id, as long as the client app knows that it will work. Or perhaps you could use the Widcomm API directly, which might allow you to intercept the PUT objects you need...