Due - Thursday 2/9 - 4:35pm
The goal of this project is to implement the foundation of the code you will build upon for the rest of the semester. You will produce a long-running program that will run on an a laptop or phone and will produce at least two trends: IP address and application reboots. You will extend this in Project 2 to include several other metrics.
Requirements
- Your application will trend, at minimum, the following information:
- IP address - Periodically, or when your application is triggered (see below), you will retrieve the IP address of your device and upload it.
- Application reboots - When your application starts or restarts, you will upload the event.
- Your application must be long running and regularly report data. This requirement will be satisfied slightly differently based on the platform you are using.
- iPhone - In order to satisfy this requirement using an iPhone, you will need to implement a program that executes in the background. This requires, first, that you have iOS 4 or greater. If you do not, consider using your laptop instead of your iPhone. Second, unfortunately in order to have your app run in the background on an iPhone you must register to use one of a small number of services that allow background execution. It is recommended that you register with the location service. This will alert your application whenever the user moves to a new location. This event will trigger the retrieval of the IP address and report to the server. Note, learning to use the location service will be helpful for Project 2 when you will add trending of location. Also note that the location service will promptly kill your battery unless you are careful. You may register for very course-grained updates, meaning your app will only be notified when the change in location is significant. Finally, you should note that your application must be manually started. After reboot of your phone, or after the application is killed, you will need to restart manually.
- Android - It should be fairly straightforward to satisfy these requirements on an Android device. You should refer to the AlarmManager, which will allow you to schedule your main execution loop to run at fixed intervals. The maximum interval should be once per hour, but you are encouraged to use the smallest interval that satisfies your personal battery life constraints. When triggered, your main execution loop will determine whether your device has an IP address and, if so, upload the address to the server. Finally, you should note that your application must be manually started. After reboot of your phone, or after the application is killed, you will need to restart manually.
- Laptops - It should be fairly straightforward to write a basic program that will periodically report the IP address to the server. You may use any language you like, but it is strongly recommended that you use native APIs (e.g., use C). The reason for this is that for Project 2 you will need to access information (such as battery percentage) that is not accessible using Java, python, etc. If you do not use native APIs for Project 1, you will have to rewrite all code for Project 2. You may use something like JNI, if you wish. This would allow you to write a small bit of C to access native APIs and then hook it with the rest of the code in Java. Your program must be scheduled to run periodically when the laptop is on. The maximum interval should be once per hour, but you are encouraged to use the smallest interval you are comfortable with. You are not required to wake your laptop from sleep. This means that you will have once-per-hour reports when the laptop lid is open and no reports when the lid is closed. Your program is required to be installed as a windows service or mac/linux daemon so that it autolaunches at startup.
- You must share your trends with me (srollins).
Submission Instructions
- A demonstration will be required. Early demos are encouraged; I am happy to see your demo during office hours. Each student will have roughly 5 minutes for demonstration, so be ready! You will have one opportunity to demo, so practice and make sure your demo works. If it does not, points will be deducted.
- Demo Requirements:
- Demonstrate that IP is correctly posted to Trendulate. This will require that you use curl or a similar tool to do a GET for the trend points as the string value will not be shown in the web UI.
- Demonstrate that reboots correctly post an event to Trendulate.
- Demonstrate that your application handles and recovers from network failure. You will need to turn off your network interfaces (e.g., put your phone into airplane mode), wait for at least one sample cycle, then turn your network interfaces back on to demonstrate that the IP trend point will be posted in the next sample cycle.
- Demonstrate that your application moves to the background and continues to run. This is a challenging demonstration. What I prefer to see is that your application has run consistently for some time (say 1 hour) prior to the demo. You should also be prepared to show the portion of your code that handles this in whatever way is appropriate for your OS.
- By the deadline, all code you wish to be considered must be checked in at https://www.cs.usfca.edu/svn/<username>/cs685
This assignment will not require a large amount of code, but it will require, for most of you, learning a new development environment, toolset, and language, as well as the Trendulate API. You are expected to produce a solid design so that it may be extended later.
Also keep in mind that, though your use of Pivotal will not be part of the grade for this project, you should use Pivotal consistently to keep track of your work. This will ensure that you receive a high grade for your use of Pivotal later in the semester.