Skip to content

Instantly share code, notes, and snippets.

lynx http://127.0.0.1:13000/status
lynx http://127.0.0.1:13000/restart?password=bacon
lynx http://127.0.0.1:13013/cgi-bin/sendsms?username=kannel&password=kannel&text=I%20fucking%20love%20bacon
public static String sendDataToServer(Context context, String jsonString, String appendedURL, boolean waitForResponse) {
String response;
if(checkNetworkConnection(context)){
response = sendDataUsingHttpConnection(jsonString, appendedURL);
}
else{
response = sendDataUsingSMS(context, jsonString, appendedURL, waitForResponse);
}
return response;
}
SmsManager smsManager = SmsManager.getDefault();
String message = appendedURL+SMS_DELIMITER+jsonString;
ArrayList<String> multipartMessage = smsManager.divideMessage(message);
int noOfParts = multipartMessage.size();
MistroSMSSentReceiver mistroSMSSentReceiver = new MistroSMSSentReceiver(message, noOfParts);
context.registerReceiver(mistroSMSSentReceiver, new IntentFilter(ACTION_SMS_SENT));
MistroSMSDeliveredReceiver mistroSMSDeliveredReceiver = new MistroSMSDeliveredReceiver(message, noOfParts);
context.registerReceiver(mistroSMSDeliveredReceiver, new IntentFilter(ACTION_SMS_DELIVERED));
if(waitForResponse){//method will be waiting for a response sms from the server
MistroSMSReceiver mistroSMSReceiver = new MistroSMSReceiver();
IntentFilter smsReceivedIntentFilter = new IntentFilter(ACTION_SMS_RECEIVED);
smsReceivedIntentFilter.addAction("android.provider.Telephony.SMS_RECEIVED");
context.registerReceiver(mistroSMSReceiver, smsReceivedIntentFilter);
}
//register a new sent and delivered intent for each of the parts
ArrayList<PendingIntent> sentPendingIntents = new ArrayList<PendingIntent>();
ArrayList<PendingIntent> deliveredPendingIntents = new ArrayList<PendingIntent>();
for(int i = 0; i<noOfParts; i++){
PendingIntent newSentPE = PendingIntent.getBroadcast(context, 0, new Intent(ACTION_SMS_SENT), 0);
sentPendingIntents.add(newSentPE);
PendingIntent newDeliveredPE = PendingIntent.getBroadcast(context, 0, new Intent(ACTION_SMS_DELIVERED), 0);
deliveredPendingIntents.add(newDeliveredPE);
}
smsManager.sendMultipartTextMessage(SMS_SERVER_ADDRESS, null, multipartMessage, sentPendingIntents, deliveredPendingIntents);
long startTime = System.currentTimeMillis();
if(waitForResponse){
while(true){
long currTime = System.currentTimeMillis();
long timeDiff = currTime - startTime;
if(getSharedPreference(context, SP_KEY_SMS_RESPONSE,"").length()>0){
return getSharedPreference(context, SP_KEY_SMS_RESPONSE,"");
}
1. Determine how to make the connection
Most serial devices can be accessed via a serial RS-232 cable. However, most computers these days don't have this port.
The [RFC2217](http://blog.philippklaus.de/2011/08/make-rs232-serial-devices-accessible-via-ethernet/) protocol with the help of an RJ45 to RS-232 cable should do the trick.
There are several tools you can use to initiate contact once connected:
- YPort: Part of the opensource ethersex firmware
- ser2net: Nice serial to network proxy that is still kept up to date
- socat: socat STDIO:/dev/ttyS0,nonblock,raw,echo=0 TCP-LISTEN:1234
#! /bin/bash
export DEBIAN_FRONTEND=noninteractive
debconf-set-selections <<< 'mariadb-server mysql-server/root_password password {{ mariadb_root_password }}'
debconf-set-selections <<< 'mariadb-server mysql-server/root_password_again password {{ mariadb_root_password }}'