[Feature][T108][task-view-1608][thermal]add gsw_get_modem_temperture and demo
Only Configure: No
Affected branch: GSW_V1453
Affected module: thermal
Is it affected on IC: only ASR
Self-test: yes
Doc Update: no
Change-Id: I99f8e68b342dfe2bc5289cd6eb30e709ab6eb36c
diff --git a/mbtk/libgsw_lib/gsw_at_interface.c b/mbtk/libgsw_lib/gsw_at_interface.c
index 2f48b47..cbf2c21 100755
--- a/mbtk/libgsw_lib/gsw_at_interface.c
+++ b/mbtk/libgsw_lib/gsw_at_interface.c
@@ -339,3 +339,30 @@
{
return GSW_HAL_SUCCESS;
}
+
+int gsw_get_modem_temperture(ZONE_NUM num,int *temp)
+{
+ if (num == soc_max)
+ {
+ char *cmd = "/sys/class/thermal/thermal_zone0/temp";
+ FILE *fp;
+ char buf[128];
+ fp = fopen(cmd, "r");
+ if (fp == NULL)
+ {
+ perror("Unable to open file");
+ return GSW_HAL_NORMAL_FAIL;
+ }
+
+ if (fgets(buf, sizeof(buf), fp) != NULL)
+ {
+ *temp = atoi(buf) * 0.001;
+ //printf("Temperature: %d °C\n", *temp);
+ }
+
+ fclose(fp);
+ return GSW_HAL_SUCCESS;
+ }
+ else
+ return GSW_HAL_FUNC_UNSUPPORT;
+}