Showing posts with label sms. Show all posts
Showing posts with label sms. Show all posts

Friday, 2 September 2016

HB Blog 118: Cell Broadcast - The Mobile Technology For Mass Message Broadcast.

Cell Broadcast (CB) is a mobile technology that allows messages (currently of up to 15 pages of up to 93 characters) to be broadcast to all mobile handsets and similar devices within a designated geographical area. The broadcast range can be varied, from a single cell to the entire network.
This technology is used in deploying location-based subscriber services, such as regional auctions, local weather, traffic conditions and 'nearest' services (like requesting the nearest service station or restaurant).
It is designed for simultaneous delivery of messages to multiple users in a specified area. Whereas the Short Message Service (SMS) is a one-to-one and one-to-a-few service, It is one-to-many geographically focused service.
It enables messages to be communicated to multiple mobile phone customers who are located within a given part of its network coverage area at the time the message is broadcast. Cell Broadcast is more akin to other mass distribution media such as teletext or Radio Data System (RDS).
It  is a technology that allows a text or binary message to be defined and distributed to all mobile terminals connected to a set of cells. Whereas SMS messages are sent point-to-point, Cell Broadcast (SMS-CB) messages are sent point-to-area. This means that one SMS-CB message can reach a huge number of terminals at once. In other words, SMS-CB messages are directed to radio cells, rather than to a specific terminal. SMS-CB is an unconfirmed push service, meaning that the originator of the message does not know who has received the message, allowing for services based on anonymity.

A Cell Broadcast Entity (CBE) is a multi-user front-end that allows the definition and control of SMS-CB messages. A CBE can be located at the site of a content provider. At the site of the operator a so-called Cell Broadcast Centre (CBC) is located. The CBC is the heart of the Cell Broadcast System and acts as a server for all CBE clients. It takes care of the administration of all SMS-CB messages it receives from the CBEs and does the communication towards the GSM network. The GSM network itself takes care of delivering the SMS-CB messages to the mobile terminals.
Cell Broadcast can be used for a number of different services and has been de-ployed by several network operators.

Early Warning System (EWS) for citizen alert
Cell Broadcast on mobile telephones can be used for Early Warning Systems (EWS) by Governments. A few countries in the world have already adopted this technique, in addition to older and already existing forms of communication like siren, or radio and TV. The advantage of this system is that it allows sending messages without having to know the phone numbers of the users in the region. Instead of sending a message to a specific known mobile phone you can send a text to all mobile phones in a specific zone. Mass communication, very fast, in case it really matters.

Advertising
Retail outlets in certain areas would be interested in sending customers and potential customers information about special offers and attractions such as sales, special offers, extended opening times and so on. Shopping centers, exhibition halls, airports and sports stadiums are the kinds of location that could be targeted for Cell Broadcast based services.

Information Services
Cell Broadcast is ideal for delivering local or regional information which is suited to all the people in that area, rather than just one or a few people. Examples include hazard warnings, cinema programs, local weather, flight or bus delays, tourist information, parking and traffic information. Cell Broadcast can also be used for managing and communicating with a remote but local team such as emergency services or airport staff. The emergency services could send an encrypted message out to all officers or other staff in a certain area to respond to an incident. This is particularly useful for standby workers who only need to be called in and present in a certain place when certain events occur.

SMS versus Cell Broadcast: -

Short Message Service (SMS)
Characteristic
Cell Broadcast (CELL BROADCAST)
Messages sent point-to-point
Transmission type
Messages sent point-to-area
Required. Requires specific phone numbers to be known
Mobile Number dependency
Independent. Does not require phone numbers to be known
No. Only pre-registered numbers will be notified; message will be received regardless of actual location
Location based targeting
Yes. All phones within a targeted geographical area (cells) will be notified.
Static messages will be sent to pre-registered numbers.
Message type
Location specific. Tailored messages can be sent to different areas.
Direct. Users can receive messages and respond directly to the sender via SMS.
Bi-directionality
Indirect. The message should contain a URL or number to reply.
Subject to network congestion. Delivery is queued. Congestion can occur
Congestion and delay
CELL BROADCAST is always available.
140-160 characters. Longer 'concatenated' messages are supported.
Message length
93 characters. Longer 'multiple page’ messages are supported.
Poor authenticity. The source of the message cannot be verified.
Security
Good security. Only the mobile operator can broadcast messages.
No barring.
Service barring
Yes. Users can turn off CELL BROADCAST reception or a specific channel.
By default. When phone is turned on messages can be received.
Reception
Requires action. CELL BROADCAST needs to be turned on in order to receive messages.
Yes. Senders can request delivery confirmation.
Delivery confirmation
No. Confirmation of delivery to the handset is not available, however actual broadcast in the network is.
No repetition rate.
Repetition rate
Yes. Can be repeated between 2 seconds and 32 minutes.
No. Identical to all receivers.
Language selection
Yes. Messages can be broadcasted in subscriber’s preferred language
Yes.
Message storage
Handset dependant.

Monday, 10 November 2014

HB Blog 37: Remote Control Android Phone Via Sms Commands.

Remote administration refers to any method of controlling a device from a remote location.Specifically, for android phones remote controlling can be done using many applications with different RAT(Remote Access Trojan) patterns.
In this blog, I will show a very similar kind of RAT to control device using simple sms commands.

Process goes as follows:-
1)Install android apk file on target device.
2)Send following commands and appropriate actions are resulted.

1 - Wifi is turned ON.
2 - Wifi is turned OFF.
3 - Bluetooth is turned ON.
4 - Bluetooth is turned OFF.
5 - Mobile data is turned ON.
6 - Mobile data is turned OFF.
7 - Silent Mode is turned ON.
8 - Silent Mode is turned OFF.
9 - Notification is sent.
0 - Sd card is formatted.

Have a look on few code snippets,

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//Toggle wifi
    public void toggleWifi(Context context,boolean status){
            WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
            wifiManager.setWifiEnabled(status);
    }

    //Toggle bluetooth
    public void toggleBluetooth(Context context,boolean status){
         BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        if(bluetoothAdapter != null){
            if(!bluetoothAdapter.isEnabled() && status==true){
                bluetoothAdapter.enable();
            }
            else{
                bluetoothAdapter.disable();
            }
        }
        else {}
    }
   
    //Toggle Mobile data
    public void toggleMobileData(Context context,boolean status){
            final ConnectivityManager conman = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
            final Class conmanClass = Class.forName(conman.getClass().getName());
            final Field iConnectivityManagerField = conmanClass.getDeclaredField("mService");
            iConnectivityManagerField.setAccessible(true);
            final Object iConnectivityManager = iConnectivityManagerField.get(conman);
            final Class iConnectivityManagerClass = Class.forName(iConnectivityManager.getClass().getName());
            final Method setMobileDataEnabledMethod = iConnectivityManagerClass.getDeclaredMethod("setMobileDataEnabled", Boolean.TYPE);
            setMobileDataEnabledMethod.setAccessible(true);
            setMobileDataEnabledMethod.invoke(iConnectivityManager, status);
        }

    // Toggle Silent Mode
    public void toggleSilentMode(Context context,boolean status){
        AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
        if(status){
            audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
        } else {
            audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
        }
    }

Refer the below link for complete sample code:-
Download Sample Code
Download Apk File

Wednesday, 23 July 2014

HB Blog 5: How to send sms programmatically using phonegap and android?

The mobile application development landscape is filled with many ways to build a mobile app.
Among the most popular are:

    Native iOS,
    Native Android,
    PhoneGap,
    PhoneGap Android Cordova Library,
    Appcelerator Titanium.

1)PhoneGap Android Cordova Library:-

 Refer the below link for starting with phonegap:-

    http://docs.phonegap.com/en/2.0.0/guide_getting-started_android_index.md.html

Refer the below link for complete sample code:-
Download Sample Code
Download Apk File



 Few important snippets for sms:-

   MainActivity.java
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
public class MainActivity extends DroidGap
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        // Set by <content src="index.html" /> in config.xml
        super.loadUrl(Config.getStartUrl());
        //super.loadUrl("file:///android_asset/www/index.html")
    }
}
  
  smsplugin.js
1
2
3
4
5
6
7
var SmsPlugin = function () {};
SmsPlugin.prototype.send = function (phone, message, method, successCallback, failureCallback) {   
    return PhoneGap.exec(successCallback, failureCallback, 'SmsPlugin', "SendSMS", [phone, message, method]);
};
PhoneGap.addConstructor(function() {
    PhoneGap.addPlugin("sms", new SmsPlugin());
});
  
  index.html
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<script type="text/javascript">
         $(document).ready(function() {
             //leave empty for sending sms using default intent
             $("#btnDefaultSMS").click(function(){
                 var number = $("#numberTxt").val();
                 var message = $("#messageTxt").val();
                SmsPlugin.prototype.send(number, message, '',
                    function () {
                       alert('Message sent successfully'); 
                    },
                    function (e) {
                        alert('Message Failed:' + e);
                    }
                );              
             });
         });
      </script>
2)Native Android:-

 Refer the below link for starting with android:-

   https://developer.android.com/training/index.html

Refer the below link for complete sample code:-
Download Sample Code
Download Apk File



 Few important snippets for sms:-

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
public void sendSMS(String phoneNumber,String message) {
        SmsManager smsManager = SmsManager.getDefault();
         String SENT = "SMS_SENT";
         String DELIVERED = "SMS_DELIVERED";
            SmsManager sms = SmsManager.getDefault();
            ArrayList<String> parts = sms.divideMessage(message);
            int messageCount = parts.size();        
     Log.i("Message Count", "Message Count: " + messageCount);    
         ArrayList<PendingIntent> deliveryIntents = new ArrayList<PendingIntent>();
            ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>(); 
            PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SENT), 0);
            PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new Intent(DELIVERED), 0);
            for (int j = 0; j < messageCount; j++) {
                sentIntents.add(sentPI);
                deliveryIntents.add(deliveredPI);
            }
            // ---when the SMS has been sent---
            registerReceiver(new BroadcastReceiver() {
                @Override
                public void onReceive(Context arg0, Intent arg1) {
                    switch (getResultCode()) {
                    case Activity.RESULT_OK:
                        Toast.makeText(getBaseContext(), "SMS sent",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                        Toast.makeText(getBaseContext(), "Generic failure",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_NO_SERVICE:
                        Toast.makeText(getBaseContext(), "No service",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_NULL_PDU:
                        Toast.makeText(getBaseContext(), "Null PDU",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_RADIO_OFF:
                        Toast.makeText(getBaseContext(), "Radio off",
                                Toast.LENGTH_SHORT).show();
                        break;
                    }
                }
            }, new IntentFilter(SENT));

            // ---when the SMS has been delivered---
            registerReceiver(new BroadcastReceiver() {
               @Override
                public void onReceive(Context arg0, Intent arg1) {
                    switch (getResultCode()) {
                    case Activity.RESULT_OK:
                        Toast.makeText(getBaseContext(), "SMS delivered",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case Activity.RESULT_CANCELED:
                        Toast.makeText(getBaseContext(), "SMS not delivered",
                                Toast.LENGTH_SHORT).show();
                        break;
                    }
                }
            }, new IntentFilter(DELIVERED));         
            smsManager.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
           /* sms.sendMultipartTextMessage(phoneNumber, null, parts, sentIntents, deliveryIntents); */
    }