WiFiClient port numbers?

Reposted in "Networking" as it seems a more appropriate location for this question.

Setting up my UNO to send emails. The example code expects the smtp server to be on port 25:

if(client.connect(server,25)) {

but my isp blocks port 25. specifying a port I can actually telnet into and send an email manually (using telnet) does not seem to work. For instance

if(client.connect(server,26)) {

What port numbers are legit, or how can I modify the library to accept a more common port.

The port your client tries to connect to must be the same port that the server you are connecting to is listening on.

If your ISP blocks the port that the server is listening on then it is not possible for you to connect to it.

Yes, of course, But given that I have several ports that my server can respond to (587, 2525, and others) that are not blocked, how can I tell the client to use one of those other ports. I have verified, for instance, I can send email using telnet on port 26.

You specify the server port number in the connect call. Presumably you have tried this and think it doesn't work - what makes you think that?

If your wifi shield is still using an obsolete firmware version, you will not be able to connect to any server on any port using IDE v1.0.5 or newer. Add the firmware version below after the wifi shield check. If it displays 1.0.0, you need to upgrade the firmware on the shield. If it displays 1.1.0, it is current.

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present"); 
    // don't continue:
    while(true);
  } 

  // check firmware version
  Serial.print(F("Firmware version: "));
  Serial.println(WiFi.firmwareVersion());.

I will check the version number when I get home tonight. If it's out of date, I'll will update and retry. As to PeterH, Yes, I did try port 26 in the sketch and got a Connection Failed message in the serial monitor, but no problem using telnet. Used the same strings from the sketch in telnet, and received the test message.

Can you post the sketch you're running and identify the WiFi hardware and software library?

Sure enough, it was 1.0.0

Upgrading per http://arduino.cc/en/Hacking/WiFiShieldFirmwareUpgrading

I downloaded the elf file from

https://github.com/arduino/Arduino/tree/master/hardware/arduino/firmwares/wifishield/wifi_dnld/Release

I separated the wifi shield from my uno, downloaded Flip, and I set the jumper on the wifi shield. Plugged in a mini-usb cable, and got an error that AT32UC3A could not be installed.

That would explain why

batchisp.exe -device AT32UC3A1256 -hardware usb -operation erase f memory flash blankcheck loadbuffer /Arduino/hardware/arduino/firmware/wifishield/binary/wifi_dnld.elf program verify start reset 0

did not work either. Says AtLibUsbDfu.dll is missing.

I went into Computer Management, right clicked on the Atlem device with the yellow exclamation, said "update driver" and pointed it to the Atmel directory. Told it to search subdirectories. This time it found and installed!

Now when I run the command prompt

batchisp.exe -device AT32UC3A1256 -hardware usb -operation erase f memory flash blankcheck loadbuffer /Arduino/hardware/arduino/firmware/wifishield/binary/wifi_dnld.elf program verify start reset 0

It continues much further, until I get:

Device selection....................... PASS
Hardware selection..................... PASS
Opening port........................... PASS
Reading Bootloader version............. PASS 1.0.2
Erasing................................ PASS
Selecting FLASH........................ PASS
Blank checking......................... PASS 0x00000 0x3ffff
Parsing ELF file....................... Can't open input file "/Arduino/hardware
/arduino/firmware/wifishield/binary/wifi_dnld.elf"
FAIL Reading error.
(A)bort, (R)etry, (I)gnore ? r
PASS /Arduino/hardware/arduino/firmware/wifishield/binary/wifi_dnld.elf
Parsing ELF file....................... Can't open input file "/Arduino/hardware
/arduino/firmware/wifishield/binary/wifi_dnld.elf"
FAIL Reading error.
(A)bort, (R)etry, (I)gnore ? r
PASS /Arduino/hardware/arduino/firmware/wifishield/binary/wifi_dnld.elf
WARNING: The user program and the bootloader overlap!
Programming memory..................... PASS 0x00000 0x00000
Verifying memory....................... PASS 0x00000 0x00000
Starting Application................... PASS RESET 0

Summary: Total 14 Passed 12 Failed 2

C:\Program Files (x86)\Atmel\Flip 3.4.7\bin>

I reran to sketch to check firmware version, and now get "Wifi shield not present"

I've never updated the firmware on this shield, but this first error message looks significant:

Does that file exist?

That may just be fallout from a failed upload and might fix itself, but if not then it might imply that the fuses aren't set correctly. As I understand it, fuses are used to apportion the available program memory between bootloader and application spaces.

The file does exist, but apparently windows has protection issues with the program files directory, so I copied the two files to C:\wifitemp and those errors went away.

There are no directions as to what to do with fuses, I followed the instruction posted on the arduino site for uploading the two files.

I have a solid blue data light. "Wifi shield not present"

@PeterH: The bootloader overlap warning happens to everybody. I got it too on a successful upgrade.

That suggests either the upload didn't complete successfully, or the image you uploaded is not working on that board. Do you have the ability to reinstate the previous firmware, just to prove that your upload process is actually succeeding?

SurferTim:
@PeterH: The bootloader overlap warning happens to everybody. I got it too on a successful upgrade.

Ah. Probably nothing to worry about then, although it does sound a bit alarming. Do you understand what causes it?

I guess it is because it is uploading a new bootloader to the wifi shield, but that is only a guess.

I can download a previous version of the Arduino IDE I suppose and grab the files from that. The command line says both files uploaded successfully, but they don't work.

I hear v1.0.2 will work ok, but remember if you downgrade the firmware, you must use that earlier IDE version or you will not be able to connect to any servers using v1.0.5.

I had 1.0.2, but I think I removed it recently. I don't see it on the site anymore. Is there a URL to still get it? Hopefully I'll be able to reload the 1.0.2 firmware.