- Ubuntu 18.04
- MQTT Broker
- Redis DB Server
- Redis Web GUI Console
- NodeJS
- Python
- Sub MQTT & Write Data into Redis DB
- Temi Robot
- Java
- MQTT Client
- Java
-
MQTT
- Broker
$ sudo apt update -y && sudo apt install -y mosquitto
- Enable Service
$ sudo systemctl enable mosquitto
- Enable Service
- Client
$ sudo apt update -y && sudo apt install -y mosquitto-clients
- Broker
-
Redis
$ sudo apt update -y && sudo apt install redis-server -y
- Enable Service
$ sudo systemctl enable redis-server.service
- Config
$ sudo vim /etc/redis/redis.conf
bind 0.0.0.0 # port (default 6379) # requirepass <password> stop-writes-on-bgsave-error no
- Enable Service
-
NodeJS
- Node & NPM
$ sudo apt update -y && sudo apt install nodejs -y
- Node & NPM
-
Python
- Python v2.7
$ sudo apt install python -y
- Python v3.6+
- MQTT Client
$ pip3 install paho-mqtt
- redis
$ pip3 install redis
- MQTT Client
- Python v2.7
-
Install Android Studio
-
Install ADB (Android Debug Bridge)
- Windows
- Download SDK Platform-Tools
- MacOS
- Via
Homebrew
- Make sure brew is installed
$ brew cask install android-platform-tools
- Mannual
- (Optional) If installed before, run this command
$ rm -rf ~/.android-sdk-macosx/
to delete previous document - Download SDK Platform-Tools https://developer.android.com/studio/releases/platform-tools
- Add environment variables
or change$ echo 'export PATH=$PATH:~/.android-sdk-macosx/platform-tools/' >> ~/.bash_profile $ echo 'export PATH="$PATH:<PWD>/platform-tools"' >> ~/.zshrc # ex. $ echo 'export PATH="$PATH:$HOME/development/platform-tools"' >> ~/.zshrc
.bash_profile
to the active shell config such aszsh
config.zshrc
4. Source the rc file$ source ~/.zshrc
- (Optional) If installed before, run this command
- Via
- Windows
-
Open Temi ADB Connection Port
Settings -> temi Developer Tools -> ADB Port Opening
-
Connect
# Default Port : 5555 $ adb connect ip:port $ adb devices # check connection $ adb logcat | grep D\ <TAG> $ adb shell $ adb disconnect
- Getting Brand List
- Method : GET
- Parameters : BrandList_ID
- Usage : https://cgutemi.nctu.me/BrandLists/<ID>
- Getting Special Events & News
- Method : GET
- Parameters : Null
- Usage : https://cgutemi.nctu.me/events
-
Table [0] : Robot Utils & Status
- Key : S/N
- Value : Data JSON Format
S/N Status Time MAC_Addr SSID IP Addr RSSI Battery_Info Charging_Status Boolean - Key : S/N
-
Table [1] : Robot Status Log
- Key : S/N
- Field : Date, Time
- Value : Data JSON Format
- Field : Date, Time
- Key : S/N
-
Table [2] : 櫃位引導(Brand Guide)
Brand_ID Brand_Name Brand_URL Brand_Logo Brand_Description Brand_Location Ask_Counter URL -
Table [3] : 活動列表(Activity List)
Time Activity_Name Provider_ID ProviderName DM_Sources TTL List -
Table [4] : Coupon List
Time Coupon_Number Amount TTL -
Table [5] : User Data
UserID UserName UserPhone UserMail
- IDE : Android Studio (v4.0)
- Language : Java
- System Target : Android Version 6 Marshmallow (API 23)
- Screen Spec : 10.1" inches, 1920x1200(px), 224dpi >> Officail Web Spec
// Make app running specified function in a period
// https://www.itread01.com/p/1358274.html
final int time = 1000 ; // set period time (ms)
final Handler handler = new Handler();
Runnable runnable = new Runnable(){
@Override
public void run() {
// Add function(s) or something eles here
handler.postDelayed(this, time);// time ms後執行this,即runable
}
};
handler.postDelayed(runnable, time);// 開啟定時器,time ms後執行runnable操作
- Serial Number
- Current Time
- MAC Address
- IP Address
- SSID
- RSSI (Connection Strength)
- Memory
- System Memory
- totalMem
- availMem
- usedMem = totalMem - availMem
- Runtime Memory
- maxMemory
- totalMemory
- freeMemory
- usedMemory = totalMemory - freeMemory
- System Memory
- Battery
- BatteryLevel
- isCharging
public static void publishUtilTOMqtt(String content){ // Void function without return value (ex. string, int ...
String broker = "tcp://ip:1883";
String clientId = "Temi";
MemoryPersistence persistence = new MemoryPersistence();
String topic = "test/sub_topic"; // or "test/+" to subscribe the sub topic
// Setting mqtt connection quaility
// https://swf.com.tw/?p=1015
int qos = 0;
Log.d(TAG, "message: " + content);
try {
MqttClient sampleClient = new MqttClient(broker, clientId, persistence);
MqttConnectOptions connOpts = new MqttConnectOptions();
connOpts.setCleanSession(true);
//Log.d(TAG, "Connecting to broker: " + broker);
sampleClient.connect(connOpts);
Log.d(TAG, "Connected");
//Log.d(TAG, "Publishing message: " + content);
MqttMessage message = new MqttMessage(content.getBytes());
message.setQos(qos);
sampleClient.publish(topic, message);
Log.d(TAG, "Message published");
sampleClient.disconnect();
//Log.d(TAG, "Disconnected");
//System.exit(0);
} catch (MqttException me) {
Log.e(TAG, String.valueOf(me));
Log.d(TAG, "reason: " + me.getReasonCode());
Log.d(TAG, "msg: " + me.getMessage());
Log.d(TAG, "loc: " + me.getLocalizedMessage());
Log.d(TAG, "cause: " + me.getCause());
Log.d(TAG, "excep " + me);
me.printStackTrace();
}
}
- Connect to MQTT Server & Subcribe to
Topic
- Connect to Redis & I/O Data
- Clone from github
- Setup on http://ip:8085
- Can be access from http://cgutemi.nctu.me
- NodeJS
- Install Node & NPM(Node Package Manager)
- Connect to MQTT Server
- Subscribe to
Topic
- Start a socket to communicate between
server (backend)
&webpage (frontend)
- Apply from NCTU free domain : https://nctu.me/
- No longer support !! (from 2020/10)
[1] https://oranwind.org/-edge-zai-ubuntu-an-zhuang-mosquitto-mqtt-broker-part-2/
[2] https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-20-04
[3] https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-20-04