Windows Phone 7 Connection with a wifi-enabled micro controller - sockets

How can i connect a windows phone 7 device with a WiFi-enabled micro controller. Should i use socket programming?? If yes then how?? I actually want to send a text file or a text message to the micro controller using WI-FI??

Your question is a bit vague. Are you trying to write a app that enables you to send a text file/message?
or are you trying to accomplish this by connecting to the microcontroller with the default connection your phone provides.
If you want to write your own app, you can do this by using a windows socket function. Have you looked into the standard code examples windows provides? They provide good examples about the basis of windows phone wifi connectivity
in example:
Example 1
Example 2
Edit:
You should take a look at this example.
Example
In this microsoft example, they make the game tic tac too between two windows phones. For your cause, you can read the data form file. Temporarly store it in an array. And send it over wifi. if you customize the example to fit your needs, so in steps:
Declare a socket (with the right ip adresses, ports etc)
Read file
Store in array
Send array by the wifi (using your previously declared socket)
And then on the microcontroller, you need some way to filter your data out of the incomming wifi buffer. I looked into one of my older projects where i did something like this. But i couldn't find it anymore. So i must have deleted it at some point "sorry :( " i you can work this out using the example

Related

Reading messages from can bus and display on raspberry pi webpage

This is a theorical question. I have no code and I am not looking for that, just knowledge.
I have a raspberry pi with a webserver and a waveshare can-hat. It receives various messages from a dozen devices.
among those messages a few contains data (some informations are divided over multiple messages).
My idea is to receive the messages, restore complete informations and write one file each.
then an ajax call reads each file and displays each value in the webpage. Probably once every second.
Is it possible to do that? is there a better way?
the receiving script will be made in C.
thank you for helping and sharing your knowledge!
I think it would be a better practice if you create some kind of process (or some kind of kernel module or daemon for example) which read out the data from CAN and you use this process with Python and use some sort of Webserver-API to display the data via web.
You can find some ideas for IPC between a C and a Python application here.
So one simple solution would be to create a socket system with a C guest and a Python master. Your Python application is a flask application which waits for a connection of the C application (or vice versa) and the C application transmit all incomming data to your Python application.
This would be a more neat solution than writing and reading a file.

How to send a GET/POST request with Forth

I want to write a Forth program for my Raspberry Pi. This program shall read some sensor data from an existing file and send it to a website where the data gets stored.
Searching the web there was plenty of documentation about how easy and fast Forth is and how to calculate Fibonacci numbers. But how can I request a URL? How can I send data to a website and process the result?
If there's no socket support: is it possible to start an external program like curl/wget to do the request?
It is not obvious from the question what the Forth implementation is used.
For example, Gforth (that is available on Raspberry Pi)
has some support of the sockets and also it allows to start an external program using system word. See my answer on the similar question: How do I read raw code from a website in Gforth?
Example of creating curl child process in Gforth:
S" curl https://example.com/" system
In any case,
it seems that the most promising approach for the given problem is to develop a binding to libcurl (if it doesn't exist yet for the used Forth implementation).

Not able to connect to TCP server through APN

After googling thoroughly I finally decided to post my problem which is really giving me nightmares.
In my app I am trying to connect to a TCP server using the Network Carrier internet and using following connection string:
url="socket://"+ip+":"+port+";deviceside=true;connectionTimeout=30000;apn=;tunnelauthusername=;tunnelauthpassword=;";
I am able to connect to internet through the phone's browser but not able to connect to TCP server through app.
In my device APN authentication is disabled by default and APN,Userid/Password fields are blank thats why i have taken these parameters as blank valued in the connection string.
When i try to connect through wifi network using the string below:
url="socket://"+ip+":"+port+";deviceside=true;interface=wifi;connectionTimeout=30000";
I am able to connect to server but not in the case via APN.
Please help me out.
I am just stuck here and finding no way out.
Thanks
There are a variety of methods of connecting to a Server. What you are doing is specifying the method to use in the connection suffix which you set. The options that you can use in the connection suffix are documented in the BB KB article here:
Different-ways-to-make-an-HTTP-or-socket-connection
If you are supporting really old phones (pre OS 5.0), then this is the only option you have. But the trick with this is that you have to figure out what connection method is going to work on your device at the time you make the request. There is a load of code floating round the internet to do this, most of it dubious.
If you are OS 5.0 or above, then you can use a more advanced API, the ConnectionFactory, to make this easier, and in OS 6.0 even more advanced features. These are all documented on the BB Java microsite, see here:
BB OS Networking
The option you are using is the GCF framework. I recommend you investigate the "Network API" if you are supporting OS 5.0 and later only. You might also investigate the "Network API alternative for legacy OS".
This does not answer the frequent question, "how come the Browser can connect and I can't in my app?". This is because the Browser uses a special BlackBerry connectivity method referred to as BIS-B. The good thing about BIS-B is that it will work for any BB phone that has a BlackBerry tariff, and requires no configuration. The bad thing is that you do not get access to it as of right. To get access to it, the easiest thing to do is to ask for Push support, even if you are not planning on using it immediately but might in the future. This is documented on the page above.
But back to your question. The APN values in your TCP configuration being not set, does NOT mean you don't have to set them. The values specified in the Options are used as the default values should someone code ";deviceside=true" as a connection string - the idea being that users can set these for themselves and application developers don't code anything. These values are specific to your carrier. So search to find out what values you need to use. You will either put these values in the TCP Options (and so don't code them in your connection suffix), or put in your connection suffix. If you can't find out what you should put in there, you need to ask your carrier.
On most BlackBerry tariffs, using direct TCP through the APN may cost the user something for the data, and will also require configuration. Alternatively, you can use WAP 2, which may also cost for data, but doesn't require any configuration. The advantage of both these is that they will work on phones that are not using a BlackBerry tariff.
My recommendation is to look at connecting using ConnectionFactory (Network API), but this will only work for OS 5.0 and above.

How to connect to NAO robot using sockets?

I'm playing with Aldebaran's NAO humanoid robot Simulator and choregraph.
I have a software in java that I would like to use to control the robot by activating its behaviors, and I believe sockets would do the trick.
My question is: is there a way to open a socket connection from within choregraph+naoSim, so I can get sensor readings and send commands to the robot?
Or any other way to connect to choregraph+naoSim to achieve the same effect?
thanks in advance!
K
I'm planning to use python websocket package to accomplish this. As far as I see the server can be written on anything. The client part - NAO - should initiate connection to the server send something, possibly wait for a reply and then carry on. So the sending functionality can be implemented using Python and coded in one of the NAO action boxes. You could even create a separate box that will take a request as a parameter and output a reply from the server. A small neat box that talk to the server.

what type of network programming is necessary in iPhone online multiplayer game?

I am asking this question as a small part of my question series regarding game programming .
Refer this question as the main one .
Now suppose I want to develop a game on iphone - a simple online multiplayer board game.
Suppose its a casino table.
In the main question ChrisF has tell me of sort of Client - Server architecture for iphone online multiplayer game.
I want to know what sort network programming I have to do for this type of application .
What will be the responsibilities and activities carried out by client and server .
You can provide me link, tutorials or to the point answers , anything will be great help for me and will be really appreciable .
thanks
You'll want to write a socket application running on a server. When you have access to a wifi access point or edge/3g you can send data to it from your iphone application. This server can then handle the incoming data and send an appropriate reply to the people connected.
For server socket programming, take a look at this guide - http://beej.us/guide/bgnet/.
For iphone specific socket programming, take a look at the samples supplied with the Iphone SDK. This link also has some basic information.
A simple online multiplayer board game
Given that the iPhone isn't always connected to the internet, you might need a server to store state. Alternatively you could always stipulate that if one person loses their connection the game finishes.
Client to client would be the obvious choice for the latter. Both clients have a port they listen to, and send the other commands based on the board state. Like almost all online games the obvious choice would be to use UDP as it's fast and compact.
For the server architecture you will of course need some kind of server listening for commands and a game number. It would store your state in a datastore on the server, a mySQL database for example. UDP or even SOAP or JSON over HTTP would be the two obvious choices for this.
This second approach using JSON/SOAP route would be a lot easier for you to get started with, assuming the iPhone has a decent JSON or SOAP library which is not likely. I have no idea about UDP in Objective C, however in C it requires a certain level of knowledge which won't get you something to play with quickly.
As you already said, you will need a server, but you can have two kinds of design:
The server can serve only as a gateway between the players to connect one to each other: it's two uses are, first, to list the running games, and second, to list the IP addresses of the players so that each client will read the IP addresses and connect to them. This will require less bandwidth and processing power for the web server and more for the client which will host the game. In this configuration, one of the clients will act as a server and will send data to the others. If your game has only one of the players playing at a time, and not a huge lot a players, this is what you should use as what you pay is the server's power.
The server can also store all games' states: it might require far more processing power and/or bandwidth depending on your game.
Anyway, most of the time you will want only one machine (which can change during the game as in the first case) to do the processing and the others will only receive the computed data.
To program a networked game, you will need knowledge of sockets (deep knowledge in the first case because you will have to deal with NAT issues, routers blocking the way between clients). The guide to that is Beej's Guide to Network Programming, the number one ressource on this topic, although it doesn't focus on games.
If not too much processing is needed on the WWW server, you could deal with it with server scripting languages like PHP along with MySQL, but you're most likely to use your own server programmed in C++ (or in C). If you use C++, you might want to use an already existing library such as RakNet.
The client will obviously be programmed in Objective-C as it's on the iPhone. I believe there is a good networking framework looking at the number of online games, so you might as well not want to use an external server networking library.
It might be a bit too much for what you want to do, but you could also use the well known Torque Engine.