chromebook and att wifi

I had upgraded my mother’s Chromebook to a 4g model late last year. I had known that operating system updates didn’t occur over 3g. Unsurprisingly, they don’t occur over 4g either. She’s been taking her laptop to wifi to patch and enjoying the 4g speeds for normal home internet use. Everyone happy. Until now. Her source of convenient wifi has vanished. Now, she could go to Starbucks or the library o use wifi. But that’s not convenient. I decided to look at replacing the monthly 4g bill with a monthly wifi hotspot bill.

The difference

On a prepaid low bandwidth plan, the two are pretty comparable.

Category Verizon 4g ATT wifi hotspot (over 4g)
Where to find the price list Verizon page GoPhone page
Minimum plan per 30 days $20 $25
Amount of bandwidth included 1GB 2GB
Ability to buy more if go over $5 for 300MB $10 for 500MB
Next level plan if not enough bandwidth $30 for 2GB plan $50 for 5GB

In other words $5 more per month for double the bandwidth. And the Chromebook can see it as wifi so patches work.

Trying to buy the hotspot online

The AT&T Velocity hotspot is $149 if you want to use a prepaid plan. (Free with a contract.) I hit two problems trying to buyt it online:

  1. AT&T’s product page either doesn’t work in Safari or is relying on a third party site to render the ability to order the device. Or it’s just broken. I tried reloading the page four times to write this post and it showed up the fourth time. In any case, I switched to Chrome.
  2. When you choose the $149 version, AT&T asks if you are a new or existing customer. I clicked new customer. It then took me to a page to buy a “choice” of plan. The only “choice” was the $50/month plan.

I was able to find out online that while my local AT&T store didn’t have the device in stock, the one at the mall did.

Buying the hotspot in person

This went better. They didn’t try to trick me into buying the $50 plan. They warned me that I had to pay for the first month ($25) while still in the store. No problem. I had planned to buy the first month right away to test anyway.

The receipt was a bit odd. It said the $25 plan was for 1.5GB. Online it shows at 2GB when I check my use so this is just wrong. It also directs to att.com/wireless which isn’t the site to go to for prepaid.

Trying out the hotspot

When I got home, I gave it a shot. It was easy to use. The battery/case comes separated so I put that together. The hotspot is like a cell phone that doesn’t make calls.

The device tells you the charge, connection strength and whether you have any new messages. I had a few from AT&T about the product. It has a touch screen to get messages. Or you can use the website paygonline.com or att.com/mygophone to check them through a computer. You know you have a text because the device blinks with a green light.

The device also tells you how many connections are in use. I went into settings and lowered the max from 10 to 2 by going to http://attwifimanager once connected to the hotspot from the Chromebook. (One for my mother’s Chromebook and one for my iPad when I visit. Being able to use my iPad when I visit is a nice side effect of using a hotspot.) I got a message “The LCD display is in operation, use power button to turn LCD display off and try again” which was easy enough to move past.

I also changed the wifi name from ATT-WIFI-1234 to something more readable and changed the  password to a different set of numbers than the default. It suggests using numbers and letters but then wouldn’t let me choose letters. Once I changed this, my browser hung on saving because it was no longer connected to the new wifi network. Not a big deal, but they could have given a prompt. Once I reconnected, I also disabled broadcasting the SSID.

Note: I had to turn broadcasting the SSID back on to avoid having to enter the password on each connect. Chrome feels it is bad that I’m not broadcasting the network name. I’m annoyed ChromeOS doesn’t work well with hidden SSIDs. I understand that hiding the SSID doesn’t protect it from the bad guys. But it does prevent random people from trying different passwords. But at the same time, I’m worried this isn’t a well supported configuration and my mom will have other troubles later.

Anyway, then I went to settings > advanced to change the admin login so it isn’t attadmin.

I also learned the bandwidth reporting is realtime which is an improvement over Verizon. And that if you don’t use it for hours, you have to press the power button on the hotspot so the wifi network resumes broadcasting. Which is reasonable.

Connecting from the Chromebook

Connecting to the new wifi name is easy. Note that the network name is case sensitive
  1. Join other…
  2. my network with “X wifi” SSID
  3. Security: PSK (WPA or RSN)
  4. Enter password
  5. Don’t click share network

To remember the connection

  1. Click the wifi icon and click “Connected to X”
  2. Click network name
  3. Click “Prefer this network”
  4. Ensure “Automatically connect to this network is checked”
  5. Click “close”

The first Chromebook patch

I did a Chromebook patch over wifi. It took 7 minutes and was approximately 400MB. (GoPhone reports bandwidth use to the nearest 50MB). While that is 25% of the wifi allocation, there is no need to patch the Chromebook every month. Plus my mom has double the bandwidth she used to so it is still an increase.

How fast is the connection?

I ran a speedtest both to see how fast the connection was and to use a chunk of bandwidth to see how reporting worked. The answer was:

  • ping 33ms
  • download 19.94 Mbps
  • upload 11.76 Mbps

Problems

Every once in a while, I have to push the power button on the wifi device for the ChromeBook to connect. I haven’t seen a pattern on this, but it only happens on trying to connect.

why posting errata matters

We’ve been posting every errata we receive about our a href=”/oca”>OCA 8 book. There’s something about cert books that attracts errata. I think it is because readers have to be so attentive.

Error count

We have slightly more errata reported than K&B 7 (which has 89 at the moment; we have 117). That book covers more (both OCA and OCP) so it isn’t a fair comparison. However, it has more versions published (starting with Java 4 I think) which means there were more opportunities to catch and correct theirs. It’s kind of interesting how certain errors can pass by so many people.

Anyway, my point is that while I’d love for our book to be perfect, I think our errata rate is acceptable for a cert book. Plus it gives us something to try to beat for our a href=”/ocp”>OCP 8 book. I am glad that most of the errata in the “stupid typo” department and not the “understanding” department.

Why reporting each and every errata matters

Ok. So if most of them are typos, why bother making a list? There’s three big reasons I think about:

  1. If we write that Java 9 version of the book, I don’t want these errors in it. I want there to be different errors for crying out loud! It’s like experience; you don’t want to keep making the same mistakes.
  2. If another reader isn’t sure if something is wrong, he/she can look at the thorough errata list.
  3. Finally, when I read a book and see something technical wrong, (even if it is a typo in a code snippet), I start to wonder “if I can’t trust this which I caught without knowing the topic, how can I trust the rest.” An exhaustive errata list provides transparency. You know if something was wrong it would be listed. That’s why I “categorized” the errata so you can see what is a typo and what is significant.

For the readers, it’s also helpful to have that engagement. By knowing that every question about the book posted in the forum, will get a reply, readers have confidence they wouldn’t be confused.

Which brings us to a big thank you

Interestingly, three people reported over half of the errors. So a big thank you to Mushfiq Mammadov, Elena Felder and Cedric Georges. I’d also like to thank Roel De Nijs. He didn’t report many errors, but he *confirmed* a whole boatload of them. Which saved me a lot of time and I really appreciate.

Formatting Strings for the Java Foundations Junior Associate exam

Thinking about using our OCA 8 book to study for the Java Foundations Junior Associate exam? It covers most of the topics. See what other topics you need to learn and where to read about that. One of those topics is formatting a String using %s, %n and %d. Conveniently for you , I had written a draft of this material for our OCP book before finding out that topic is not on the OCP 8 exam. I asked our publisher if I could post the material online and they said yes. I’ve edited it down to cover the subset that is on the Java Foundations Junior Associate exam. While the style matches our book, keep in mind it has not gone through the normal editing process by our publisher.

Note that the exam only expects you to know %d (digit/integer), %s (string) and %n (new line). This post covers a bit about %f (decimal) for two reasons:

  1. To help you remember why %d is digit/integer and not a floating point number
  2. To see the power of printf!

Formatting Strings

Formatting a String is useful because they let us specify a lot of complex logic clearly and succinctly . Imagine you had to write code to print out exactly 3 decimal places and align the decimal places. That would be a lot of coding and logic. Or it could be done using formatting:

List<Double> values = Arrays.asList(123.456, -1.4, 2.0);

for (Double d : values)

System.out.printf("%7.3f%n", d);

Don’t worry if this seems like magic. In a nutshell, this uses a width of 7 with 3 decimal places followed by a new line. It outputs:

123.456
-1.400
2.000

You don’t have to be able to write code like this. It is just to show the power of formatting. Also, there are a lot more types and options in existence than you need to know for the exam. See the Formatter class in the Javadoc for the ones not on the exam. The following figure shows what is going on from a high level. Java is substituting the parameter into a part of the format string.c05f003Ok. From this point on, you do need to know the material for the exam.

The PrintStream class defines the methods format and printf. They do the exact same thing. Java wanted to name the method format. However, C++ has had this method called printf for decades. Java supports both names to make things easy for both C++ developers and new developers.

System.out and System.err are both PrintStream instances. Remember that System.out.println() can show up in questions on just about anything as can System.out.printf(). This means you won’t know specifically if you are being tested on printf or something else.

The signatures of these two methods are:

  • public PrintWriter format(String fmt, Object… args)
  • public PrintWriter printf(String fmt, Object… args)

Remember that the three dots mean varargs. You can pass as many arguments as you want here. Also, remember that format and printf are exactly the same so we will start to use them interchangeably.

The first parameter is a String with embedded format parameters. The remaining parameters are an ordered list of the parameters to be inserted:

int num = 3;

String s = "Three: ";

System.out.format("%s %d", s, num);

Java sees a format string of a String to be inserted, followed by a space and then followed by a number to be inserted. The output is:

Three: 3

There are a number of parts to a format string. You only need to know a simplified version which looks like:

%[arg_index$]conversion_char

Conversion Character

%d and %s are format conversion specifiers. These format specifiers indicate the type of the parameter. You are only required to know three of the format specifiers for the exam as listed in following table. You do have to memorize these. They are copied from C++ so some of the types might seem odd to you. We’ve tried to give a description that helps you remember it rather than the shortest one possible. If you are a C++ developer, you might know that %d actually stands for decimal rather than digit. This is harder to remember for a new developer because the whole point of %d is that there is not a decimal point.

Remember that %d is digit (integer) and not double.

Conversion Specifier Description
%d Specifies a number with digits and no decimal point. (also known as an integer number)
%n New line (line break)
%s Specifies a String

Argument Index

The remaining part of a format string is the argument index. This is the index number followed by a $.

Argument indexes start counting from 1 instead of 0.

These examples should be straightforward:

System.out.printf("%s, %s", "play", "time");    // play, time

System.out.printf("%2$s, %1$s", "play", "time"); // time, play

System.out.printf("%2$s, %2$s", "play", "time"); // time, time

The first line can omit the argument index since we want to use them in the order provided. The second line shows how to reverse the arguments. The final line shows how to use the same argument multiple times.

The Formatter Class

The Formatter class is an interpreter for the format strings used in format/printf methods. The class is similar to the PrintWriter class except that Formatter defines only the format methods and not the printf methods. Since the Formatter class didn’t exist in C++, Java didn’t need to be compatible with it. You invoke format in the way you do PrintWriter: passing in a format specifier followed by a comma-separated list of arguments.

For example, the following statements create a Formatter object and format a string of primitive types. What do you think this outputs?

StringBuilder sb = new StringBuilder();

Formatter fmt = new Formatter(sb);

int x = 123;

fmt.format("x=%d", x);

System.out.println(sb.toString());

In this example, the Formatter writes its output to a StringBuilder object. The int x is formatted and the resulting StringBuilder looks like this:

x=123

As you can see, working with Formatter is similar to working with PrintWriter.

Summary

printf() and format() use a format string. You need to know the simplified format of: %[arg_index$]conversion_char. The arg_index is optional. However, it must be specified in the correct order if present. The components you need to know are:

  • arg_index is an index that starts counting with one
  • conversion_character includes:
    • %b for boolean
    • %d for digit/decimal/integer (no decimal point)
    • %n for new line
    • %s for strings

Practice Questions

Question 1

What is the result of the following code?

System.out.format("%2$d is bigger than %2$d", 10, 5);

A: 10 is bigger than 5
B: 5 is bigger than 10
C: 10 is bigger than 10
D: 5 is bigger than 5
E: The code does not compile
F: A runtime exception is thrown

Question 2

Which of the following are true about the format string passed to printf? (Choose all that apply)

A: The argument index is a 0 based index.
B: The argument index is a 1 based index.
C: double goes with %d
D: int goes with %d

Question 3

What is the output of this statement?

System.out.printf("%2$d %1$s", "entry", 123.456);

A: 123 entry
B: 123.456 entry
C: entry 123
D: entry 123.456
E: The code does not compile
F: A runtime exception is thrown

Question 4

What is the output of this statement?

System.out.format("$n, $s", 123.456);

A: %n %s
B: $n $s
C: %n, %s
D: $n, $s
E: None of the above
F: A runtime exception is thrown

Question 5

What is the output of this statement?

System.out.println("%d", 123);

A: 0
B: 123
C: %d
D: The code does not compile
E: A runtime exception is thrown

The answers are posted here.