Show Posts
Pages: 1 [2] 3
16  Using Arduino / Networking, Protocols, and Devices / Re: First steps with WiFly and Arduino on: June 19, 2012, 01:50:42 pm
Hi

Sorry to ask again but I want to be sure before I purchase and I've discovered there seem to be an enormous variety of usb/ttl adaptors.

I've found a 5V adaptor here:
http://robosavvy.com/store/product_info.php/manufacturers_id/33/products_id/986
which is cheaper than all the usb to ttl cables I've seen (I have a usb male to female extension already).  It looks the same to me but the (CP210) number is not one I'm seeing anywhere else.  Maybe its just the brand id number?

and I've found a tutorial here:
http://hcgilje.wordpress.com/resources/arduino-terminal-and-two-serial-ports/

which is nice and clear - even though the adaptor is different, same principle right?

thanks in advance
Garrett
17  Using Arduino / Networking, Protocols, and Devices / Re: First steps with WiFly and Arduino on: June 18, 2012, 06:40:49 am
Almost, but this is the 3V version. I'd go for the 5V version as the standard Arduino runs it's pins on 5V. Usually 60% of the max level should be enough to trigger as HIGH but 3V is exactly on the edge then which is something I would avoid.

I often use the original Arduino USB2Serial LIght (http://store.arduino.cc/ww/index.php?main_page=product_info&cPath=11&products_id=143) or the Foca (http://shop.boxtec.ch/product_info.php/products_id/40332)

ah right I'll see if I can find a 5v version.  I can't find an image of how the Arduino USB2Serial LIght is to be wired up to the Arduino so that's making me hesitant about that - I have found images of the USB FTDI TTL-232 cable - TTL-232R cable connected to Arduino.  Is the FTDI friend (http://www.adafruit.com/products/284) the same thing again?

Garrett
18  Community / Products and Services / Re: An Arduino seller in Europe to avoid on: June 18, 2012, 06:26:17 am
Hi

Interesting turn of events. Alpha Crucis (http://www.alpha-crucis.com/) has posted this on their home page in the last few days:

Quote
Our company and our group have been suffered numerous attacks over the past three weeks, the most important between Thursday, June 14 and Saturday, June 16.

In a nutshell:

- Our phone lines have been saturated by rogue automated calls via Skype
- Our mail server was attacked and sabotaged, with destruction of emails and accounts
- Our blog has been attacked and sabotaged
- Some old maintenance copies of our customer database and our products database have been stolen and destroyed
- Our database of products images has been siphoned
- We have to cope with a smear campaign on several forums including one moderated by one of our competitors

Sounds that we disturb somebody...

Fortunately the attackers failed to sabotage our main e-commerce server. There won't be any impact to our customers because we do not store any confidential data related to payment. We are working hard to restart all of our services.

Given the seriousness of the facts, we are going to fill a complain to the prosecutor and we have diligented the technical expertises needed to gather evidence to act against the attackers.

The first five points have nothing to do with me and yes it does sound like it's more than just me who is unhappy about their service, but I guess in point six they are refering to my post about broken products and poor service as a smear campaign.  I posted it to both the English and French sections of the Arduino forum and I noticed that the French forum is run by somebody connected to an Arduino selling store in France.  I don't know him and at no point has he commented in the thread so I don't see why that's particularly relevant.

I'd hardly call posting what happened and just advising others to not shop there as a smear campaign.  It's an unfavourable review of their service, they are after all providing a service and my experience of it has been poor.  I have still yet to recieve a refund or even confirmation that I will receive a refund despite having returned the product and asked Alpha Crucis several times.

Garrett
19  Using Arduino / Networking, Protocols, and Devices / Re: First steps with WiFly and Arduino on: June 18, 2012, 04:23:25 am
I guess you know you have to change the MY_SERVER_GET and MY_SERVER_GET_URL defines to match your server's setup? This is what's being inserted into your request and if the values in it are not correct you won't reach your server.

Your request is executed (if this is possible to say, the request line is sent over the existing connection) in this line:

Code:
WiFly <<  (const char*) strRequest;


Hi

Yes, I just put false details for the forum.  Ah ok that is that line that's sending the GET request.  Mmm, not sure what's happening then as the php script doesn't execute.  It works fine when I do it via a browser.

You mentioned about a serial adaptor for testing before.  Is it this adaptor?
http://www.adafruit.com/products/70

I think I need to get one of these as its impossible to test what's going on, its perhaps something small like a typo in the request URL.

Thanks.
Garrett
20  Using Arduino / Networking, Protocols, and Devices / Re: First steps with WiFly and Arduino on: June 16, 2012, 11:43:27 am
Hi

On the final bit now I think but I'm confused on what I hope is just one last detail.  I'm unsure what line is the actual GET request being made in my arduino code.  I copied mine from a demo that came with WiFlySerial library that does both GET and POST requests and I can see where the request line is built - just not where it's executed.

Anyway in the demo below the loop I've made should work every five second (it was working without all the WiFly code).  I've highlighted where I'm stuck inside the "if (WiFly.openConnection(MY_SERVER_GET))" section which is not working (the counter.txt file online isn't updating).  What should I be doing here?

Thanks in advance
Garrett

Code:
#include <Arduino.h>
#include <SoftwareSerial.h>
#include <Streaming.h>
#include <PString.h>
#include "WiFlySerial.h"


//various buffer sizes
#define REQUEST_BUFFER_SIZE 180
#define TEMP_BUFFER_SIZE 60

//server hosting GET example php script
#define MY_SERVER_GET "http://www.mysite.com/"
#define MY_SERVER_GET_URL "pathway/to/index.php"


//WiFly pins
#define ARDUINO_RX_PIN  2
#define ARDUINO_TX_PIN  3

WiFlySerial WiFly(ARDUINO_RX_PIN ,ARDUINO_TX_PIN);
char bufRequest[REQUEST_BUFFER_SIZE];
char bufTemp[TEMP_BUFFER_SIZE];




//loop counter
int iLoopCounter = 0;

//start time
unsigned long startTime = 0;


void setup()
{
  //set up serial
  //Serial.begin(9600);
  
  //start up WiFly
  WiFly.begin();
}


void loop()
{
  //calculate the time since last time the cycle was completed
  unsigned long loopTime = millis() - startTime;

  //if the timer is greater than or equal to 5 seconds (5000 milliseconds)
  if (loopTime >= 5000)
  {
    //trigger
    //Serial.println("Loop");
    
    char bufRequest[REQUEST_BUFFER_SIZE];
    PString strRequest(bufRequest, REQUEST_BUFFER_SIZE);
      
    // Build GET expression
    strRequest << F("GET ") << MY_SERVER_GET_URL << F("?count=") << iLoopCounter
    << F(" HTTP/1.1") << "\n"
    << F("Host: ") << MY_SERVER_GET << "\n"
    << F("Connection: close") << "\n"
    << "\n\n";
    // send data via request
    // close connection
  
    //open connection, then send GET Request, and display response.
    if (WiFly.openConnection(MY_SERVER_GET))
    {
      
      
      //***
      //I'm confused about this bit, what's actually doing the GET request here?
      //I don't think I need the wjile at the moment - that's testing the request has happened right?

      WiFly <<  (const char*) strRequest;
    
      // Show server response

      //how long to wait before timing out on the GET request
      unsigned long TimeOut = millis() + 3000;

      while (millis()  < TimeOut && WiFly.isConnectionOpen())
      {
        if (WiFly.available() > 0)
        {
            WiFly.read();
        }
      }

      //I'm confused about this bit, what's actually doing the GET request here?
      //***
      
      

      //force-close connection
      WiFly.closeConnection();
    }
    else
    {
      //failed to open
    }
  
    //restart timer
    startTime = millis();
  }

  //increment the loop counter
  iLoopCounter++;

  //to prevent spamming serial monitor too much
  delay(250);
}


This is the php counter if you need to see it, this works fine.

Code:
<?php

//error_reporting(E_ALL ^ E_NOTICE);

//if their is a GET request
if ($_SERVER['REQUEST_METHOD'] == 'GET'
{
//for debugging
//print_r($_GET);

//if count number in url
if ($_REQUEST['count'])
{
//get count number in url
$count $_REQUEST['count'];
}
else
{
//error no count number in url
$error "No count passed in url.";
}

//name of the counter database file
$logfile "counter.txt";

//open the counter file
$handle fopen($logfile"r+") or die("Can't write to log file! Please Change the file permissions (CHMOD to 666 on UNIX machines!)");

//write the passed count to the file
fwrite($handle$count);

//close file
fclose($handle);
}

?>
21  Using Arduino / Networking, Protocols, and Devices / Re: First steps with WiFly and Arduino on: June 14, 2012, 12:58:45 pm
Hi

Yes I know I'm not retrieving the data arduino side I want to send it and I'll check it php/txt side.  So essentially I want to send a GET to:

mypage.php?count=1

And the php will write it to a file.  It's the openconnection, while loop and closeconnection in that code which I think will help me.
22  Using Arduino / Networking, Protocols, and Devices / Re: First steps with WiFly and Arduino on: June 14, 2012, 11:59:24 am
ok some progress, I abandoned doing it in the sketch and searched around for a way to talk to the WiFly from osx, this pdf: ww1.microchip.com/downloads/en/.../rn-wifly-eval-um-ver1.0r.pdf

was a god send and recommended CoolTerm.  Followed the steps in the pdf to configure it for a WEP secured network and it looks like it has connected.  No flashing red light and now I have a slow pulsing green light so I think that means it has an ip and is connected.  I can also see the device in my network now.

Since testing seems to be quite difficult I want to make a slow looping sketching which passes a number (a counter) to a php file online which in turn will write it to a text file.  Php side is easy and I think I can conceptualise the loop in arduino.  I've spotted this in an example:

Code:
  // Open connection, then sent GET Request, and display response.
  if (wifi.openConnection( MY_SERVER_POST ) ) {
   
    wifi <<  (const char*) strRequest ;
   
    // Show server response

    unsigned long TimeOut = millis() + 3000;

    while ( millis()  < TimeOut && wifi.isConnectionOpen() ) {
      if (  wifi.available() > 0 ) {
        Serial <<  (char) wifi.read();
      }
    }
   
    // Force-close connection

    wifi.closeConnection();
 
  } else {
    // Failed to open
    Serial << GetBuffer_P(IDX_WT_MSG_FAIL_OPEN,bufTemp,TEMP_BUFFER_SIZE) << MY_SERVER_POST << endl;
  }

Which I think gives me the actual GET calls.  If you have advice on this last part I'd appreciate it.  Once I get this working I'm going to post it all to this thread because this was far more difficult than it should be.

Garrett

23  Using Arduino / Networking, Protocols, and Devices / Re: First steps with WiFly and Arduino on: June 14, 2012, 08:25:31 am
If you disabled the encryption you cannot just remove a line and expect the configuration to be also removed. The library does configure the RN-XV by sending serial commands. Although the library looks like that these configuration has to be made at every startup, this is not true. The RN-XV stores it's configuration in EEPROM. So if the last configuration was WPA2 and you remove the configuration line, it stays WPA2 and is not changing to any default value.
To have no encryption the value has to be changed to WIFLY_AUTH_OPEN.

I configured my RN-XV by connecting it directly (better by the use of a Foca) to my notebook and sending the serial commands myself. So I have immediate feedback from the device and if I was successful, I simply disconnect the Bee from the notebook and connect it to the Arduino. After powerup it reconnects to the WiFi network and shows success by it's status LED.

Hi

Ok I've just tied it with my network open and using the line WiFly.setAuthMode( WIFLY_AUTH_OPEN ); - still no change, doesn't connect.  Not sure what a Foca is?  I'm happy to try and configure it directly, I've seen this mentioned in the WiFly userguide, using $$$ and changing modes etc. but what do I do this through on osx?  Can it be done in osx terminal?
24  Using Arduino / Networking, Protocols, and Devices / Re: First steps with WiFly and Arduino on: June 14, 2012, 07:27:05 am
I tried last night with out any encryption so my network was open and I removed the line WiFly.setAuthMode(WIFLY_AUTH_WEP);.  Today I tried WPA2 (just in case as every example I'm finding on the web is for WPA2) and used the line WiFly.setAuthMode( WIFLY_AUTH_WPA2_PSK);.  Nether of these tests have changed anything.
25  Using Arduino / Networking, Protocols, and Devices / Re: First steps with WiFly and Arduino on: June 14, 2012, 05:51:56 am
Yes I think I have removed all the serial code.  Below is my sketch.  I've also tried changing my network to WPA-PSK Encryption (WPA2) and used WiFly.setAuthMode( WIFLY_AUTH_WPA2_PSK); in the sketch but nothing changes.


Code:
/*
 * WiFly_Device Test Platform
 * A simple tester for communicating with the WiFly GSx RN-131b/g series.
 * LGPL 2.0
 * Tom Waldock, 2011
 */

#include <Arduino.h>
#include <Streaming.h>
#include <SoftwareSerial.h>
#include "WiFlySerial.h"
#include "MemoryFree.h"
#include "Credentials.h"


// Pins are 3 for INCOMING TO Arduino, 5 for OUTGOING TO Wifly
// Arduino       WiFly
//  2 - receive  TX   (Send from Wifly, Receive to Arduino)
//  3 - send     RX   (Send from Arduino, Receive to WiFly)
WiFlySerial WiFly(2,3);

#define REQUEST_BUFFER_SIZE 120
#define HEADER_BUFFER_SIZE 150
#define BODY_BUFFER_SIZE 100

char bufRequest[REQUEST_BUFFER_SIZE];
char bufHeader[HEADER_BUFFER_SIZE];
char bufBody[BODY_BUFFER_SIZE];


void setup() {
 
  WiFly.begin();
 
  WiFly.setDebugChannel( (Print*) &Serial);
 
  //WEP 128 bit security
  WiFly.setAuthMode(WIFLY_AUTH_WEP);
 
  //WPA2 security
  //WiFly.setAuthMode( WIFLY_AUTH_WPA2_PSK);
 
  WiFly.setJoinMode(  WIFLY_JOIN_AUTO );
  WiFly.setDHCPMode( WIFLY_DHCP_ON );

  // if not connected restart link
  WiFly.getDeviceStatus();
  if (! WiFly.isifUp() ) {

    // join
    if (WiFly.setSSID(ssid) ) {   
      //Serial << "SSID Set :" << ssid << endl;
    }
   
    if (WiFly.setPassphrase(passphrase)) {

    }

    if ( WiFly.join() ) {
      WiFly.setNTP( ntp_server ); // use your favorite NTP server
    } else {

    }
  } // if not connected

  WiFly.SendCommand("set comm remote 0",">", bufBody, BODY_BUFFER_SIZE);
  memset (bufBody,'\0',BODY_BUFFER_SIZE);

  WiFly.closeConnection();

  // clear out prior requests.
  WiFly.flush();
  while (WiFly.available() )
    WiFly.read();
 
}

char chOut;
void loop() {
  // Terminal routine

  // Always display a response uninterrupted by typing
  // but note that this makes the terminal unresponsive
  // while a response is being received.
 
  while(WiFly.available() > 0) {
 
  }

} //loop
26  Using Arduino / Networking, Protocols, and Devices / Re: First steps with WiFly and Arduino on: June 14, 2012, 04:28:07 am
There are several possibilities to debug if the serial is used for device communication. The cheapest and fastest to realise is using one ore more LEDs to show some states. An easy one from the programmers view is using SoftwareSerial to establish a serial interface on two (one is sufficient for debugging) digital pins. You then need a USB2Serial adapter (available from Arduino or other suppliers) to connect that serial to your PC. The third option is an LCD display to show the messages. There different versions available, from 4-bit to 8-bit parallel and almost any serial connection (UART is not feasible in your situation, but I2C or SPI will do).

I think your stock of devices and/or budget will decide. :-)

Yes I've seen somebody testing with LEDs, different LEDs, flashing rates etc.  I'd much rather debug with messages back to Serial Monitor but I don't understand how a usb2serial is needed.  My arduino is USB and I have no serial ports on my mac, I thought the USB on the arduino doubled up as serial and power?  Also the three LEDs on the WiFly, aren't they LEDs showing the WiFly's state?

I've now tried turning off all security (wep) on my network and still no change, the red led on the WiFly never stops flashing rapidly.
27  Using Arduino / Networking, Protocols, and Devices / Re: First steps with WiFly and Arduino on: June 13, 2012, 02:23:02 pm
Thanks for your patience on this, still no joy.

This switch has to be on the USB side when you're transferring sketches to the Arduino but on the Bee side when this sketch runs as otherwise your Arduino has no connection to the RN-XV.

right I understand.

You also have to remove all Serial code from your sketch as the Serial is used for communication with the RN-XV, you cannot use the serial connection for the Bee and for debugging at the same time.

So every line that has a call to serial needs to be commented out?  That's nearly every second line in the example I have, if all of that is gone how do I know if it has successfully joined a network or not?  At the moment my WiFly_Test sketch looks like this.

Code:
/*
 * WiFly_Device Test Platform
 * A simple tester for communicating with the WiFly GSx RN-131b/g series.
 * LGPL 2.0
 * Tom Waldock, 2011
 */

#include <Arduino.h>
#include <Streaming.h>
#include <SoftwareSerial.h>
#include "WiFlySerial.h"
#include "MemoryFree.h"
#include "Credentials.h"


// Pins are 3 for INCOMING TO Arduino, 5 for OUTGOING TO Wifly
// Arduino       WiFly
//  2 - receive  TX   (Send from Wifly, Receive to Arduino)
//  3 - send     RX   (Send from Arduino, Receive to WiFly)
WiFlySerial WiFly(2,3);

#define REQUEST_BUFFER_SIZE 120
#define HEADER_BUFFER_SIZE 150
#define BODY_BUFFER_SIZE 100

char bufRequest[REQUEST_BUFFER_SIZE];
char bufHeader[HEADER_BUFFER_SIZE];
char bufBody[BODY_BUFFER_SIZE];


void setup() {
 
  //Serial.begin(9600);
  //Serial.println(F("Starting WiFly Tester." ) );
  //Serial << F("Free memory:") << freeMemory() << endl; 

  WiFly.begin();
  //Serial << F("Starting WiFly...") <<  WiFly.getLibraryVersion(bufRequest, REQUEST_BUFFER_SIZE)
  // << F(" Free memory:") << freeMemory() << endl;
 
  // get MAC
  //Serial << F("MAC: ") << WiFly.getMAC(bufRequest, REQUEST_BUFFER_SIZE) << endl;
  // is connected ?
 
  WiFly.setDebugChannel( (Print*) &Serial);
 
  //WPA2 security
  //WiFly.setAuthMode( WIFLY_AUTH_WPA2_PSK);
 
  //WEP 128 bit security
  WiFly.setAuthMode(WIFLY_AUTH_WEP);
 
  WiFly.setJoinMode(  WIFLY_JOIN_AUTO );
  WiFly.setDHCPMode( WIFLY_DHCP_ON );

   
  // if not connected restart link
  WiFly.getDeviceStatus();
  if (! WiFly.isifUp() ) {
    //Serial << "Leave:" <<  ssid << WiFly.leave() << endl;
    // join
    if (WiFly.setSSID(ssid) ) {   
      //Serial << "SSID Set :" << ssid << endl;
    }
    if (WiFly.setPassphrase(passphrase)) {
      //Serial << "Passphrase Set :" << endl;
    }
    //Serial << "Joining... :"<< ssid << endl;

    if ( WiFly.join() ) {
      //Serial << F("Joined ") << ssid << F(" successfully.") << endl;
      WiFly.setNTP( ntp_server ); // use your favorite NTP server
    } else {
      //Serial << F("Join to ") << ssid << F(" failed.") << endl;
    }
  } // if not connected

  Serial << F("IP: ") << WiFly.getIP(bufRequest, REQUEST_BUFFER_SIZE) << endl <<
    F("Netmask: ") << WiFly.getNetMask(bufRequest, REQUEST_BUFFER_SIZE) << endl <<
    F("Gateway: ") << WiFly.getGateway(bufRequest, REQUEST_BUFFER_SIZE) << endl <<
    F("DNS: ") << WiFly.getDNS(bufRequest, REQUEST_BUFFER_SIZE) << endl
    << F("WiFly Sensors: ") << bufBody <<  WiFly.SendCommand("show q 0x177 ",">", bufBody, BODY_BUFFER_SIZE) << endl
    << F("WiFly Temp: ") <<  WiFly.SendCommand("show q t ",">", bufBody, BODY_BUFFER_SIZE)
    << F("WiFly battery: ") << WiFly.getBattery(bufBody, BODY_BUFFER_SIZE) << endl;

  WiFly.SendCommand("set comm remote 0",">", bufBody, BODY_BUFFER_SIZE);
  memset (bufBody,'\0',BODY_BUFFER_SIZE);

  WiFly.closeConnection();
  //Serial << F("After Setup mem:") << freeMemory() << endl ;
 
  //Serial << F("WiFly now listening for commands.  Type 'exit' to listen for wifi traffic.  $$$ (no CR) for command-mode.") << endl;


  // clear out prior requests.
  WiFly.flush();
  while (WiFly.available() )
    WiFly.read();
 
}

char chOut;
void loop() {
  // Terminal routine

  // Always display a response uninterrupted by typing
  // but note that this makes the terminal unresponsive
  // while a response is being received.
 
  while(WiFly.available() > 0) {
    //Serial.write(WiFly.read());
  }
 
  //if(Serial.available()) { // Outgoing data
  //  WiFly.write( (chOut = Serial.read()) );
  //  Serial.write (chOut);
  //}

} //loop
28  Using Arduino / Networking, Protocols, and Devices / Re: First steps with WiFly and Arduino on: June 13, 2012, 09:03:22 am
Unfortunately the library doesn't support that (setting the WEP key), so you have to do that manually, switching the Bee to USB and sending commands from your serial terminal. The command for setting the WEP key is

Code:
set wlan key <key-value>

This and other available commands are in the WiFly User Manual and Command Reference (WiFly-RN-UM). You probably should read in that document and should it be only for reference.

Hi

Can't believe I didn't spot the WPA2 line.  Anyway no change, it's this last bit I'm sure I doing wrong, I understand how to send the command from the serial monitor but am not sure what you mean by switching the bee to usb.  Is the switch the part I've highlighted in the attached image?  If so I permanently have the switch on the USB side as sketches don't send when they are on the xbee side.

Is there a better library to use for setting the WEP key in the sketch?

Thanks in advance.

Garrett
29  Using Arduino / Networking, Protocols, and Devices / Re: First steps with WiFly and Arduino on: June 11, 2012, 02:23:50 pm
Hi

Thanks for your reply.  Yes I didn't know there were several libraries for this when I posted and it's since added to my confusion even more.  I'll try to be as descriptive as possible.  I've attached photos of the arduino, wifly and xbee shield I'm using for reference. 

So far I've been through the WiFly library (this one: https://github.com/jmr13031/WiFly-Shield) - but I believe that's pre-version 1 of Arduino?, the WiFlySerial library (this one: http://sourceforge.net/projects/arduinowifly/files/) and WiFlyHQ (this one: https://github.com/harlequin-tech/WiFlyHQ).  The last two compile and upload their examples fine and each starts, puts output in the serial monitor and then seems to go no further.

This is the WiFly_Test sketch I've mentioned which is an example that comes with WiFlySerial.  I don't care which library or demo I get working, anything would be a start I could start working back from.

thanks
Garrett


WiFly_Test:

Code:
/*
 * WiFly_Device Test Platform
 * A simple tester for communicating with the WiFly GSx RN-131b/g series.
 * LGPL 2.0
 * Tom Waldock, 2011
 */

#include <Arduino.h>
#include <Streaming.h>
#include <SoftwareSerial.h>
#include "WiFlySerial.h"
#include "MemoryFree.h"
#include "Credentials.h"


// Pins are 3 for INCOMING TO Arduino, 5 for OUTGOING TO Wifly
// Arduino       WiFly
//  2 - receive  TX   (Send from Wifly, Receive to Arduino)
//  3 - send     RX   (Send from Arduino, Receive to WiFly)
WiFlySerial WiFly(2,3);

#define REQUEST_BUFFER_SIZE 120
#define HEADER_BUFFER_SIZE 150
#define BODY_BUFFER_SIZE 100

char bufRequest[REQUEST_BUFFER_SIZE];
char bufHeader[HEADER_BUFFER_SIZE];
char bufBody[BODY_BUFFER_SIZE];


void setup() {
 
  Serial.begin(9600);
  Serial.println(F("Starting WiFly Tester." ) );
  Serial << F("Free memory:") << freeMemory() << endl; 

  WiFly.begin();
  Serial << F("Starting WiFly...") <<  WiFly.getLibraryVersion(bufRequest, REQUEST_BUFFER_SIZE)
   << F(" Free memory:") << freeMemory() << endl;
 
  // get MAC
  Serial << F("MAC: ") << WiFly.getMAC(bufRequest, REQUEST_BUFFER_SIZE) << endl;
  // is connected ?
 
  // WiFly.setDebugChannel( (Print*) &Serial);
 
  WiFly.setAuthMode( WIFLY_AUTH_WPA2_PSK);
  WiFly.setJoinMode(  WIFLY_JOIN_AUTO );
  WiFly.setDHCPMode( WIFLY_DHCP_ON );

   
  // if not connected restart link
  WiFly.getDeviceStatus();
  if (! WiFly.isifUp() ) {
    Serial << "Leave:" <<  ssid << WiFly.leave() << endl;
    // join
    if (WiFly.setSSID(ssid) ) {   
      Serial << "SSID Set :" << ssid << endl;
    }
    if (WiFly.setPassphrase(passphrase)) {
      Serial << "Passphrase Set :" << endl;
    }
    Serial << "Joining... :"<< ssid << endl;

    if ( WiFly.join() ) {
      Serial << F("Joined ") << ssid << F(" successfully.") << endl;
      WiFly.setNTP( ntp_server ); // use your favorite NTP server
    } else {
      Serial << F("Join to ") << ssid << F(" failed.") << endl;
    }
  } // if not connected

  Serial << F("IP: ") << WiFly.getIP(bufRequest, REQUEST_BUFFER_SIZE) << endl <<
    F("Netmask: ") << WiFly.getNetMask(bufRequest, REQUEST_BUFFER_SIZE) << endl <<
    F("Gateway: ") << WiFly.getGateway(bufRequest, REQUEST_BUFFER_SIZE) << endl <<
    F("DNS: ") << WiFly.getDNS(bufRequest, REQUEST_BUFFER_SIZE) << endl
    << F("WiFly Sensors: ") << bufBody <<  WiFly.SendCommand("show q 0x177 ",">", bufBody, BODY_BUFFER_SIZE) << endl
    << F("WiFly Temp: ") <<  WiFly.SendCommand("show q t ",">", bufBody, BODY_BUFFER_SIZE)
    << F("WiFly battery: ") << WiFly.getBattery(bufBody, BODY_BUFFER_SIZE) << endl;

  WiFly.SendCommand("set comm remote 0",">", bufBody, BODY_BUFFER_SIZE);
  memset (bufBody,'\0',BODY_BUFFER_SIZE);

  WiFly.closeConnection();
  Serial << F("After Setup mem:") << freeMemory() << endl ;
 
  Serial << F("WiFly now listening for commands.  Type 'exit' to listen for wifi traffic.  $$$ (no CR) for command-mode.") << endl;


  // clear out prior requests.
  WiFly.flush();
  while (WiFly.available() )
    WiFly.read();
 
}

char chOut;
void loop() {
  // Terminal routine

  // Always display a response uninterrupted by typing
  // but note that this makes the terminal unresponsive
  // while a response is being received.
 
  while(WiFly.available() > 0) {
    Serial.write(WiFly.read());
  }
 
  if(Serial.available()) { // Outgoing data
    WiFly.write( (chOut = Serial.read()) );
    Serial.write (chOut);
  }

} //loop


In the Creditials.h below is SSID the network name and passphrase the WEP number?  I've read that this needs to be 128 bit on my network and have set it as that.

Credentials.h:

Code:
#ifndef __CREDENTIALS_H__
#define __CREDENTIALS_H__

// Wifi parameters
char passphrase[] = "PassPhrase"; //"YourSecretPassPhrase123"
char ssid[] = "SSID"; //"YourSSID"
char ntp_server[] = "nist1-la.ustiming.org"; // or your favorite ntp server.

#endif


MemoryFree.cpp:

Code:
extern unsigned int __bss_end;
extern unsigned int __heap_start;
extern void *__brkval;


#include "MemoryFree.h"


int freeMemory() {
  int free_memory;

  if((int)__brkval == 0)
     free_memory = ((int)&free_memory) - ((int)&__bss_end);
  else
    free_memory = ((int)&free_memory) - ((int)__brkval);

  return free_memory;
}


MemoryFree.h:

Code:
// memoryFree header

#ifndef MEMORY_FREE_H
#define MEMORY_FREE_H

#ifdef __cplusplus
extern "C" {
#endif

int freeMemory();

#ifdef  __cplusplus
}
#endif

#endif
30  International / Français / Un vendeur de Arduino en France a evite a tout prix! on: June 10, 2012, 06:19:19 am
Pour tout en Europe qui est nouveau a Arduino (comme moi), voila un vendeur a evite!  C'est difficile deja a commence a utilse Arduino avec le prix de material sans tombe sur un vendeur pas honnete.

J'ai achete un carte electronique pour Arduino de Alpha Crucis (https://www.alpha-crucis.com/).  Cettais livrais chez moi en Pay Galles sans reçu et caisse dans le boite (voir le image attache).  J'ai demande un echange de le vendeur, etais obligie a paye le prix de retour et j'ai jamais vu un remplacement.  J'ai plainte plusiers fois a le vendeur sans success.  Achete vos electronique delicate ailleurs!
Pages: 1 [2] 3