This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,""); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SmsManager smsManager = SmsManager.getDefault(); | |
String message = appendedURL+SMS_DELIMITER+jsonString; | |
ArrayList<String> multipartMessage = smsManager.divideMessage(message); | |
int noOfParts = multipartMessage.size(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lynx http://127.0.0.1:13013/cgi-bin/sendsms?username=kannel&password=kannel&text=I%20fucking%20love%20bacon |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lynx http://127.0.0.1:13000/restart?password=bacon |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lynx http://127.0.0.1:13000/status |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#group that configures how kannel sends messages to web apps | |
group = sms-service | |
keyword-regex = .* | |
catch-all = yes | |
max-messages = 0 | |
#sms-resend-retry = 0 | |
get-url = "http://localhost/~jason/ngombe_planner/WebServer/php/kannel/sms_router.php?phone=%p&text=%a" |