This post shows how to connect to Internet using a D-Link broadband modem dongle (Model DWM-221) on the Ubuntu LTS 14.04 64 Bit OS. Most of the posts i searched online on this topic does not seem to work (most of them on DWM-156 and older versions of Ubuntu), therefore i decides to write something about how to do it after successfully get it to work on my Ubuntu OS.
Firstly, one may need to install the ia32-libs, the following command lines can be followed to install ia32-libs on Ubuntu 14.04:
Next plug in your D-link broadband modem to your computer and run the following command lines to mount it
sudo -su
mkdir /media/cdrom
mount /dev/sr1 /media/cdrom
You may try "mount /dev/sr0 /media/cdrom" if "mount /dev/sr0 /media/cdrom" does not work.
Once the D-Link folder has been mounted, you will notice there is a zip file in the folder named "DTLW3_D600B_linux_2.0.0WW_140305.tar.gz". If you try to extract it to a folder on your computer, you may encounter "Cannot create hard links ..." error messages. To get around list, right-click the file and select "Open with Archive Manager", extracts all the files excepts the hard links "device.conf" (which has size 0). Now in the extracted folder, you should have something like the following files and folders:
install.sh
uninstall.sh
linux
/usr
/bin
/etc
/3g_modem_connection
/ppp
/cm.version
/device.conf
To make it easier, i have share the contents in the extracted folder here:
In the extracted folder, run the following command:
sudo bash install.sh
Once this is done, go to the networking icons on the upper right corner of the Ubuntu desktop and select "Create new mobile broadband", follow the simple steps (basically a wizard asking several simple questions such as your internet provider and data plan in the form of drop down lists) and you should be able to connect to the internet via your D-Link broadband modem (Can try "sudo 3g_connect.sh ttyUSB0" if still got problem).
In this blog, the step 1 to step 5 shows you how to set up the home automation using X10 technologies (where to purchase and how to setup). The remaining step shows you how to control devices via X10 using C#.
The first step is to purchase X10 appliance module with optional lamp modules (purchase a lamp module only if you want to dim a lamp).
The x10 appliance modules allow one to control many different home appliances such as lamp, electric fan, fridge, etc, via a computer interface such as CM15Pro. The approach is not intrusive, in other words, there is no need to modify your home circuits or whatever. Simply plug the appliance module into any of the wall socket, then plug any devices (to be controlled) onto the socket on the appliance module.
The lamp module is similar to the appliance module except it allows dimmable lamp attached to be dimmed via a computer interface such as CM15Pro. By the way, if the lamp you try to control is not dimmable (such as those cheap lamp sold at Japan Home shop), then don't bother to by a lamp module as non-dimmable lamp can be easily controlled by a appliance module (any way lamp module does not work well with non-dimmable lamp)
A computer interface control the appliance module or lamp module via either power line or radio frequency, the appliance module or lamp module in turns can then switch on or off the devices plugged into its socket.
If you are staying in Singapore or some other common wealth countries which follow UK plug standard, you can purchase the appliances modules / lamp modules from UK Automation at http://www.uk-automation.co.uk/
The CM15Pro computer interface comes with the power line USB connector which can be plugged into your computer. it also has the ActiveHomePro software which once installed, allows one to control the appliance modules from the ActiveHomePro.
Step 3: Set up CM15Pro and ActiveHomePro
Step 3.1: Power up the CM15Pro via its power cable.
Step 3.2: Disable your anti-virus software and install the ActiveHomePro, During the installation, when prompted, plug in the USB cable from the CM15Pro to your computer. Wait for the installation to complete.
Step 4: Set up appliance module.
For each appliance module, configure its address using the two dials in front of the module as shown in the figure below:
It is important that you set each module to a unit address such as "A1", "B3" (where "A" is the House and "1" is the Unit).
Once configured, plug the device power plug into the module's socket, and then attach the module's plug to any socket at your house.
Step 5: Testing
Suppose you have set up two modules in step 4 with addresses "A1", "B3". On your computer, launch the ActiveHomePro, and then tries the user interface which allows you to switch "A1" ON and OFF. it should work as expected.
The ActiveHome SDK comes with a set of C# sample codes which shows you how to turn ON/OFF a device connected to an appliance module. You may notice some error messages while building, if so simple delete the pfx key file which is not needed. Another error that you may encounter is the follow message:
ActiveHomeScriptLib.ActiveHomeClass' cannot be embedded. Use the applicable interface instead
If you encounter the above error message, simply change the "Embed Interop Types" of the referenced Interop.ActiveHomeScriptLib.dll to "False" in your VC# project.
You should now compile and successfully run by controlling the "A1" and "B3" device ON or OFF.
Step 8: Write your own C# codes to control.
I have attached here a small sample project which shows user how to control the devices via C# as well as how to obtain the "ON/OFF" status of the devices using C#.
The following code (mikroC) is the working code on MCU PIC30F6014A on the dsPICPRO4 development board:
sbit Lcd_D4 at LATD4_bit; sbit Lcd_D5 at LATD5_bit; sbit Lcd_D6 at LATD6_bit; sbit Lcd_D7 at LATD7_bit; sbit Lcd_RS at LATB4_bit; sbit Lcd_EN at LATB6_bit; sbit LCD_D4_DIRECTION at TRISD4_bit; sbit LCD_D5_DIRECTION at TRISD5_bit; sbit LCD_D6_DIRECTION at TRISD6_bit; sbit LCD_D7_Direction at TRISD7_bit; sbit LCD_RS_Direction at TRISB4_bit; sbit LCD_EN_Direction at TRISB6_bit; int MyLcdOutLen=0; int MyLcdOutIdx=0; void My_Lcd_Out(int row, int col, char* message) { MyLcdOutLen=strlen(message); for(MyLcdOutIdx=0; MyLcdOutIdx != MyLcdOutLen; ++MyLcdOutIdx) { Lcd_Chr(row, col+MyLcdOutIdx, message[MyLcdOutIdx]); } } char text[6]="Hello"; void main() { Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); My_Lcd_Out(1, 3, text); //Lcd_Out(1, 3, "HelloWorld"); //this line is not working }
Interestingly the Lcd_Out and the Lcd Custom library is not working on the demo version of the mikroC IDE.
One of the challenging task in smslib is to detect the gsm device has been attached to which usb port as the port name is required during the smslib server initialization.
The manual way to find out the port is "Device Manager" panel of your Windows OS, and double click the item under "Modems" category, the com port name can be found in the "Modem" tab of the popup properties page.
The automatic way must allows the user to determine which port as there might be more than one gsm devices attached. therefore the function should return a set of possible candidate port names. this can be done by downloading the Wmi package from http://www.codeproject.com/KB/cs/EverythingInWmi02.aspx which can be used to discover hardware settings in your machine. The following are the C# code that uses Wmi and SerialPort interface from C# to automatically discover the com port for smslib in C#:
using System.IO.Ports; using baileysoft.Wmi; string[] port_names = SerialPort.GetPortNames(); List<string> possible_ports = new List<string>(); Connection.ApplicationPath = Application.StartupPath; Connection wmiConnection = new Connection(); Win32_POTSModem x = new Win32_POTSModem(wmiConnection); foreach (string property in x.GetPropertyValues()) { int split_index = property.IndexOf(": "); string property_name = property.Substring(0, split_index); string property_value = property.Substring(split_index+2); if (property_name == "AttachedTo") { foreach (string port_name in port_names) { if (port_name == property_value) { possible_ports.Add(property_value); break; } } }
In the above code, the possible ports returns the list of possible ports that might have the gsm devices attached.