Developing and Debugging on an Android Device Wirelessly Over WiFi

Update: I create a batch script that you can use to complete this whole tutorial for you. Download the wireless Android ADB Script.

Have you ever been developing an Android app that requires mobility? Or maybe you don’t have a USB cable on you? Perhaps the USB cable you do have or the USB port of your Android device is too sensitive and you are sick of having to sick perfectly still when deploying your app.

Well, you can avoid these problems and others easily by using WiFi to connect to your Android device. It’s not very difficult and is just about as fast as using a USB cable.

The first thing to do is locate adb.exe. It is located in %LOCALAPPDATA%\Android\sdk\platform-tools. To make things easier in the future, I like to add this to the PATH system variable so that I may run adb commands wherever I like. If you’d like to do so too, open a command prompt by pressing Windows Key + R and type in “cmd” into the “Run” dialog and type in:

set Path=%Path%;%LOCALAPPDATA%\Android\sdk\platform-tools

Once you have added the adb.exe location to your path, or have navigated to %LOCALAPPDATA%\Android\sdk\platform-tools in the command prompt, follow these steps:

  1. Connect the Android device you wish to test with to your computer using the USB cable. Disconnect any Android devices that you will not be using for developing and debugging.
  2. Run the command: adb -d tcpip 5555
  3. Disconnect the Android device from USB
  4. Connect your Android device to the same wireless network as the PC
  5. In the status section under settings on your Android, find the IP address that the wireless connection is using. It will usually start with 10. or 192. We’ll pretend it is 10.0.0.37 for the next step.
  6. Run the command: adb connect 10.0.0.37
  7. Verify everything worked by running the command: adb devices

You should see a device listed as 10.0.0.37:5555 device

Now when you debug in Android Studio or whatever IDE you use, you should be able to choose your Android device even though it is not connected by USB. If your Android device’s WiFi IP address changes, repeat step 6 with the new IP address.

How to display bfgminer’s miner.php temperatures in degrees Fahrenheit

I know the math isn’t all that hard, but I wanted to be lazy so I decided to modify miner.php (the one the comes with bfgminer) to show temperatures in degrees Fahrenheit.

1. Modify function fmt($section, $name, $value, $when, $alldata)

You can find this function around line 600. All you need to do to show Fahrenheit on the “Stats” page is add these as the first 3 lines:

if(stristr($name, "Temperature") !== false){
    $value = (($value * 1.8) + 32);
}

So, the beginning of the function will look like this:

function fmt($section, $name, $value, $when, $alldata)
{
    if (stristr($name, "Temperature") !== false) {
        $value = (($value * 1.8) + 32);
    }
    global $dfmt, $rownum;

2. Display °F

We can’t convert to Fahrenheit and display the wrong symbol, right? Search for the following code around line 742:

$ret = $value . '°C';

And change that to:

$ret = $value . '°F';

There you go. Now take a look at miner.php in your browser. Don’t forget to start XAMPP, MAMP, WAMP, whatever!

How to mine Namecoins and run the daemon as a service in Windows

I use Slush’s Pool Bitparking as my main mining pool (and Slush’s Pool and Eclipse MC as backups). Slush’s pool Bitparking allows you to mine Namecoins (along with a few others others) without any extra overhead or cost. Basically, if you mine Bitcoin, and don’t mine Namecoin, you are losing out on a few extra bucks. So, here is how to get started (specifically on Bitparking, but pretty much applies to all pools):

1.  Download the Namecoin daemon

You can download the files to run the Namecoin daemon at http://dot-bit.org/Main_Page. Just look on the right sidebar and download the Windows version under “Download”. Here’s a direct link to the latest version as of this post.

2. Extract the Namecoin files

Once the zip is done downloading, copy the file to C:. Them rename it to simply “Namecoin” (optional).

3. Run the daemon to create the initial files

Browse to C:Namecoin (or whatever you named it) and double click on namecoind.exe. It will run for several seconds to a minute and then close and complain about missing the config file. This is expected.

4. Show hidden files (if you don’t already)

In your Windows explorer windows, click “Alt” to show the menu. Then go to Tools > Folder Options. This will open “Folder Options”. Then click the view tab and make sure “Show hidden files, folders, and drives” is selected.

5. Create the Namecoin config file

Browse to C:Users[YourUserName]AppDataRoamingNamecoin. It was created in step 3. Then, right click to create a new text file. Rename the new file to bitcoin.conf and then open it in notepad, Notepadd++, whatever you use and enter something like this:

rpcuser=d3k4y
rpcpassword=xrhW8WBb
rpcport=8336
daemon=1

Use whatever rpcuser and rpcpassword that you like. It doesn’t really matter.

6. Install NSSM to make namecoind run as a service

You can find nssm at http://nssm.cc/download/?page=download. It is a zip that contains a 32 bit and 64 bit version. Find the nssm.exe that matches your version of windows and copy it to C:WindowsSystem32 or any directory in your PATH environment variable.

Now, open an administrator command prompt. Start -> All Programs -> Accessories -> Right click “Command Prompt” and “Run as Administrator”. Once you have a command prompt, type:

nssm install "Namecoin Daemon"

A new window will appear titled “NSSM service installer”. Set “Application:” to your namecoind.exe (C:Namecoinnamecoind.exe if you followed my instructions). Leave “Options:” blank, and service name should already be “Namecoin Daemon”.

Click “Install service”

7. Setup “Namecoin Daemon” service to run as your user

Hit Windows Key + R. Enter “services.msc” in the box that pops up. Find the service “Namecoin Daemon” that you just created. Right Click -> Properties. The “Namecoin Daemon Properties” window comes up. Select the “Log On” tab.

Choose “This account:” then click browse. Type in your username and click “Check Names”. Hit “OK” Then, type in your password and “confirm password” with the password you use to login to  your computer. Hit OK to close the properties window.

8. Start the “Namecoin Daemon” service

Right Click the “Namecoin Daemon” service and click start. As long as it is set to run as you it should start fine. Hit F5 to make sure it didn’t pause. If it did, retry the last step.

9. Test it and get a wallet

Open a command prompt again but this time just run it as your user.

cd C:Namecoin
namecoind getinfo

This should return vesrion, balance, blocks, etc… If it does not, your “Namecoin Daemon” service isn’t running. As long as you’re good, let’s create a wallet:

namecoind listreceivedbyaddress 0 true

This will give you an address (First setting called “address”). Copy that and use it to setup Namecoin mining at whatever pool you use. That’s it! If you have any questions, leave a comment and I’ll try to clarify.

10. Setup your Namecoin and Bitcoin address at Bitparking. 

If you already mine at Bitparking, but don’t mine Namecoins, or if you don’t mine at Bitparking, but want to, go to http://mmpool.bitparking.com/register and fill in your Bitcoin address and the Namecoin address you just created. If you like the other coins Bitoarking offers, you can pretty much follow this guide, but use different ports for the daemons. They all must be setup to run as your user, not a local service.

Just a reminder:

I accept tips in Bitcoin:

1MMZzTu1TvHaQDKt8m2u7iiMna1RAGwBS1

Tip Me at 1MMZzTu1TvHaQDKt8m2u7iiMna1RAGwBS1

Running a Bitcoin Miner with Backup Pools as a Service in Windows

It’s been many years since I’ve worked on this blog. This is my first post after converting from b2evolution to WordPress. Hi!

I just got my first ASIC miner in the mail this weekend. After an update, brown out, and passing out on the keyboard and causing a crash, I decided that it would be safer and financially smarter to have my miner run as a service. Blah blah blah, here’s the steps:

1. Download and install nssm.

You can find nssm at http://nssm.cc/download/?page=download. It is a zip that contains a 32 bit and 64 bit version. Find the nssm.exe that matches your version of windows and copy it to C:WindowsSystem32 or any directory in your PATH environment variable.

2. Download and install bfgminer

bfgminer supports multile pools on the command line. This is important. You could probably substitute any command line miner here, but this is what I’m sticking to until I hear better.

bfgminer can be downloaded at https://github.com/luke-jr/bfgminer/archive/bfgminer.zip. Just unzip that to anywhere. Let’s say C:bfgminer.

3. Setup your miner as a service!

Open a command prompt with Windows Key + R then enter cmd into the input box. This will open a command prompt.  Then, in the command prompt enter something like:

nssm install "Bitcoin Mining Service"

You may call your service whatever you want. Just use quotes if it’s more than one word.

Installing Bitcoin Miner Service in Windows
Installing Bitcoin Miner Service in Windows

If it works, you should get the below window. Point it to your install of bfgminer.exe and use options like:

--api-listen --api-network -o http://api.bitcoin.cz:8332 -u d3k4y.worker1 -p xrhW8WBb -o http://us1.eclipsemc.com:8337 -u dkubica83_BFL30 -p xrhW8WBb -o http://us2.eclipsemc.com:8337 -u dkubica83_BFL30 -p xrhW8WBb

*Note: The first 2 switches are optional, but needed for the BONUS! step. You may specify -o, -u, and -p as little or many times as you want. These are just your pools. The api switches let you use the miner.php file that comes with bfgminer for some control and insight. Use XAMPP or something to host it.

*Note: If you are using an ASIC miner and don’t want to use your GPU at all, add

--disable-gpu

to the front of the options.

Installing a Bitcoin Miner as a Windows Service
Installing a Bitcoin Miner as a Windows Service

If all goes well, you will get the message:

Installing a Bitcoin Miner as a Windows Service
Bitcoin Miner as a Windows Service Success

4. Start the service!

Hit Windows Key + R then enter:

services.msc

You should see your newly created service. Right click it and select “Start”. You should now hear your GPU or ASIC hardware star making a lot more noise. That means you are golden. Double check with your mining pool to be sure.

5. Finished!

Now, everytime you reboot, you will automatically start mining in the background. As long as your computer starts, you will be mining. If you want to stop for some reason simply stop the service. Want to quit mining for a while? Disable the service.

 

I DO accept tips BTW

1MMZzTu1TvHaQDKt8m2u7iiMna1RAGwBS1

Tip Me at 1MMZzTu1TvHaQDKt8m2u7iiMna1RAGwBS1

 

BONUS!

Sure, running your miner as a service won’t let you stare at the command prompt, but this will give you lots of cool stuff to stare at as you dream of Bitcoin riches. Here’s one way to use the miner.php file to watch per processor speed, temperature, shares, per pool difficulty, speed, stratum status, and a bunch of network info.

bfgminer miner.php

 

The first thing you need is a way to compile/execute miner.php. That means a web server that speaks PHP. XAMPP will do the trick.  You can download XAMPP at http://sourceforge.net/projects/xampp/files/latest/download.

1.  Install XAMPP

Once the XAMPP installer is downloaded, disable your antivirus so some false positives don’t mess everything up. Web servers listen on port 80. To some AVs, this can look like a backdoor or trojan or whatever sex related term scares you the most.  All you really need is Apache and PHP. The rest of the stuff is optional for this project. If you know PHP or plan to learn it, then maybe install MySQL for later adventures. FileZilla, Mercury, and Tomcat is up to you. Click “Next”, “Agree”, whatever.

Just try to remember where you installed XAMPP to for the next step.

2. Put miner.php on your local web

Navigate to the directory that you unzipped bfgminer. “miner.php” is in the same directory as your bfgminer executable. Copy miner.php and then navigate to your XAMPP directory. In there is a folder called “htdocs”. This is your web root. Paste miner.php into htdocs.

3. Start Apache

Start > All Programs > XAMPP > XAMPP Control Panel. You should now see the XAMPP Control Panel. Before you start Apache, click config. Set the Apache ports to 80, and 443 for SSL unless you know a reason not to. If you have extra RAM and CPU to spare, or only use this computer for mining, click the red X on the left of Apache and make it run as a service. This way, Apache starts automatically when you boot. Just like the miner in the top steps. Now, click “Start” next to Apache.

4. View miner.php!

Open a web browser, Chrome seems to work best at the moment, to http://127.0.0.1/miner.php. If yo weren’t aware, that’s your computer. You should see a pretty ugly table of stats and some fun buttons. Now you can see all the info about your Bitcoin mining service.

Just another reminder:

I accept tips in BTC:

1MMZzTu1TvHaQDKt8m2u7iiMna1RAGwBS1

Tip Me at 1MMZzTu1TvHaQDKt8m2u7iiMna1RAGwBS1

Setting up an Ubuntu webcam server

Sharing a webcam stream in Ubuntu is not the easiest thing, but it’s not too bad if you have some help. This tutorial will explain how to use the package webcam-server. It seems to work pretty well for me. I had to write the startup script myself, but I’m going to share that with you. To use webcam-server to it’s full potential, you should have Apache installed. Continue reading Setting up an Ubuntu webcam server

HowTo: Avant Window Navigator (AWN) in Ubuntu 7.10 using only GUIs

This howto explains the steps involved in setting up AWN, a dock-like launchpad for Linux, that is similar to the one in OSX. The difference between this howto and the 50 others out there, is that this howto only uses GUIs (Graphical User Interface). It’s for those of you who are afraid, or, for some reason, do not like to use command line tools. I know there are plenty of you out there! Continue reading HowTo: Avant Window Navigator (AWN) in Ubuntu 7.10 using only GUIs