The code spits the IP address of the device (Rpi/dragonboard running linux) to the dynamoDB on AWS. This is quite helpful when running the device in the headless mode or when HDMI cable/monitor is not available.
The ipaws.py uses wlan0 (wifi) and a special number for USB-ethernet device. You can change this in the code if you have a different ethernet adaptor (wifi should work as is though)
#Steps involved
#Create a table on AWS Dynamo db
- Create AWS account if you don't have one. Go to https://console.aws.amazon.com/dynamodb/ and click on create table
- Fill following items (with your values) a. Table name: devicesinfo b. Primary partition key: deviceid (Number) c. Primary sort key ipaddr (String)
#Get AWS credentials
- Go to AWS IAM: https://console.aws.amazon.com/iam/
- Create new user
- Go to security credentials tab -> create access key
- Note down/save the credentials
#Configure AWS on hardware
-
sudo apt-get install python-pip
-
pip install boto3
-
pip install awscli
-
sudo aws configure
and use the credentials (from above steps)
#Get and running the code
- Clone the code
git clone https://github.com/TusharChugh/IP_addr-linux-AWS.git
- Change the path of the ipaws.py file in ip_aws script (currently it is /home/linaro/Desktop/IP_addr-linux-AWS/)
- Paste the ipaws script in /etc/network/if-up.d/
cp ipaws /etc/network/if-up.d/
- Give the required permissions to run the script when the network restarts
chmod +x ipaws
#Test the code
- In /etc/network/if-up.d/.
sh ipaws
- You should see an entry in the device info table on dynamoDB
- If it worked, then try restarting the board and see if that works as well
- Congratulations, you are done!