- .... .- -. -.- ... / .--. .- ..- .-..
- Netduino Forums
- → Viewing Profile: Posts: qsnapper
The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
Community Stats
- Group Members
- Active Posts 8
- Profile Views 5949
- Member Title New Member
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Not Telling
0
Neutral
User Tools
Friends
qsnapper hasn't added any friends yet.
Latest Visitors
Posts I've Made
In Topic: Morse code to Text to Speach
20 November 2013 - 03:21 PM
In Topic: Simple HTTP Client?
09 November 2013 - 01:18 PM
The API I am trying to work with only allows HTTPS GET requests.
Can someone help me out how I could change the above to get it to work with an HTTPS URL.
Thanks
In Topic: Simple HTTP Client?
09 November 2013 - 12:37 PM
lot of digging around found some sample code that works for me, hopefully works for you too.
Be sure to add the 'System.Http' reference. For some reason this doesn't work for HTTPS URL's though
using System;using System.IO;using System.Text;using System.Net;using System.Net.Sockets;using System.Threading;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.Netduino;namespace NetduinoApplication2{ public class Program { public static void Main() { // write your code here // produce request var requestUri = "http://192.168.1.1/?a=1"; Debug.Print(requestUri); using (var request = (HttpWebRequest)WebRequest.Create(requestUri)) { request.Method = "GET"; // headers request.Headers.Add("X-ApiKey", "ThisIsMyKey"); // send request and receive response using (var response = (HttpWebResponse)request.GetResponse()) { // consume response HandleResponse(response); } } } public static void HandleResponse(HttpWebResponse response) { // response status line Debug.Print("HTTP/" + response.ProtocolVersion + " " + response.StatusCode + " " + response.StatusDescription); // response headers string[] headers = response.Headers.AllKeys; foreach (string name in headers) { Debug.Print(name + ": " + response.Headers[name]); } // response body var buffer = new byte[(int)response.ContentLength]; Stream stream = response.GetResponseStream(); int toRead = buffer.Length; while (toRead > 0) { // already read: buffer.Length - toRead int read = stream.Read(buffer, buffer.Length - toRead, toRead); toRead = toRead - read; } char[] chars = Encoding.UTF8.GetChars(buffer); Debug.Print(new string(chars)); } }}
In Topic: Simple HTTP Client?
08 November 2013 - 05:39 PM
have exactly the same question!
In Topic: CIRC-06 | Music With Piezos Netduino Plus 2 MS Port
07 January 2013 - 09:17 PM
If anyone having the same issue, the below is the updated working code for Microsoft.SPOT.Hardware.PWM
using System; //use base classes using System.Threading; //use threading classes using Microsoft.SPOT; //use smart personal objects technology classesusing Microsoft.SPOT.Hardware; //use hardware related SPOT classesusing SecretLabs.NETMF.Hardware; //use Secret Labs hardware frameworkusing SecretLabs.NETMF.Hardware.Netduino; //use the Netduino specific classesnamespace Piezo{ public class Program { //static PWM speaker = new PWM(Pins.GPIO_PIN_D9); // Add the following line instead of this one static PWM speaker = new Microsoft.SPOT.Hardware.PWM(PWMChannels.PWM_PIN_D9, 100000, 0.5, false); static char[] notes = "ccggaagffeeddc ".ToCharArray(); static int[] beats = { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 4 }; static int tempo = 300; public static void Main() { speaker.Start(); // Add this while (true) { for (int i = 0; i < notes.Length; i++) { playNote(notes[i], beats[i] * tempo); playNote(' ', tempo / 2); } } } /// <summary> /// Plays a particular tone for a particular duration /// </summary> /// <param name="tone">The tone to play</param> /// <param name="duration">How long to play the tone</param> static void playTone(int tone, int duration) { //speaker.SetPulse((uint)(tone * 2), (uint)tone); //Uncomment this nad use the next two lines instead speaker.Period = (uint)tone * 2; speaker.Duration = (uint)tone; Thread.Sleep(duration); //waits the appropriate amount of time } /// <summary> /// Looks up the tone for a note based on it's letter and plays /// it for a specific amount of time /// </summary> /// <param name="note">The letter of the note to play</param> /// <param name="duration">How long to play the tone</param> static void playNote(char note, int duration) { char[] names = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C', ' ' }; //The array of possible notes int[] tones = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956, 0 };//The frequency of each note in the previous array for (int i = 0; i < 9; i++) //Goes through each note { if (names[i] == note) { playTone(tones[i], duration); //Plays the right note } } } }}
- Netduino Forums
- → Viewing Profile: Posts: qsnapper
- Privacy Policy