Add Signal Strength & Screen Brightness 61/222961/1
authorDewal Agarwal <d1.agarwal@samsung.com>
Tue, 21 Jan 2020 14:12:47 +0000 (19:42 +0530)
committerDewal Agarwal <d1.agarwal@samsung.com>
Tue, 21 Jan 2020 14:12:47 +0000 (19:42 +0530)
Change-Id: I99be2da604fb8afca391a7e33c62cb52eb8ecd14
Signed-off-by: Dewal Agarwal <d1.agarwal@samsung.com>
include/bd_history_item.h
include/bd_history_item_dummy.h [new file with mode: 0644]
src/battery_dump/bd_history_item.c
src/battery_dump/bd_history_item_dummy.c [new file with mode: 0644]

index f0dfca3..011cd95 100644 (file)
@@ -79,7 +79,6 @@ typedef struct _encoding_map_s {
 */
 
 #define HISTORY_SIZE_MAX 1000000 // Maximum Allowed History
-#define S_POOL_SIZE_MAX 10000
 #define TIZEN_DUMP_VERSION "9"
 #define DUMP_DATA_TAG "h"
 #define DUMP_DATA_TAG_1 "hsp"
@@ -97,12 +96,13 @@ int bd_initialize_battery_dump(void);
 int bd_deinitialize_battery_dump(void);
 int bd_print_history_item_main(int fd, int num_h_items, long base_time, bool chkin);
 int bd_store_history_item(history_item_s* nrec);
+int bd_print_history_item_reset(history_item_s* old_state);
 
 // Constants for State Changes of Type 1
-//static const int ST1_BRIGHTNESS_SHIFT = 0;
-//static const int ST1_BRIGHTNESS_MASK = (0x7 << 0);
-//static const int ST1_PHONE_SIGNAL_STRENGTH_SHIFT = 3; // 3 bit left Shift from initial point
-//static const int ST1_PHONE_SIGNAL_STRENGTH_MASK = (0x7 << 3);
+static const int ST1_BRIGHTNESS_SHIFT = 0;
+static const int ST1_BRIGHTNESS_MASK = (0x7 << 0);
+static const int ST1_PHONE_SIGNAL_STRENGTH_SHIFT = 3; // 3 bit left Shift from initial point
+static const int ST1_PHONE_SIGNAL_STRENGTH_MASK = (0x7 << 3);
 //static const int ST1_PHONE_STATE_SHIFT = 6;
 //static const int ST1_PHONE_STATE_MASK = (0x7 << 6);
 //static const int ST1_DATA_CONNECTION_SHIFT = 9;
diff --git a/include/bd_history_item_dummy.h b/include/bd_history_item_dummy.h
new file mode 100644 (file)
index 0000000..0704181
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __BD_HISTORY_ITEM_DUMMY_H__
+#define __BD_HISTORY_ITEM_DUMMY_H__
+
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int bd_dummy_test_fn();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__BD_HISTORY_ITEM_DUMMY_H__*/
index 729256b..18232e4 100644 (file)
@@ -22,7 +22,6 @@
 #include <glib/gprintf.h>
 #include <stdio.h>
 #include <unistd.h>
-//#include <vconf.h>
 #include "bd_history_item.h"
 #include "bm_util.h"
 #include "bm_dbg.h"
@@ -30,8 +29,8 @@
 #include "bm_server_db.h"
 #include "bm_private.h"
 #include "bd_private.h"
-//#include "bm_power_engine.h"
-
+/* For Test Purpose Only */
+#include "bd_history_item_dummy.h"
 
 dump_data_s history_data[HISTORY_SIZE_MAX];
 int h_count = 0; int h_flag = false;
@@ -628,7 +627,7 @@ static int bd_get_history_detail_from_dump(int index, history_item_s* dump_node)
        return BATTERY_MONITOR_ERROR_NONE;
 }
 
-static int bd_print_history_item_reset(history_item_s* old_state)
+int bd_print_history_item_reset(history_item_s* old_state)
 {
        ENTER;
        BM_CHECK_INPUT_PARAM(old_state);
@@ -872,9 +871,25 @@ int bd_print_history_item_main(int fd, int num_h_items, long base_time, bool chk
                        }
                        int change = (old_state.state_1 ^ new_state.state_1);
                        if (change != 0) {
-                               bool wake_fl = false;
-                               int shifts = 1;
-                               for (int i = 0; i < 32; i++) {
+                               bool wake_fl = false; int k = 0;
+                               if ((change & ST1_BRIGHTNESS_MASK) != 0) {
+                                       k = (new_state.state_1 & ST1_BRIGHTNESS_MASK);
+                                       dump_p = g_string_append(dump_p, ",Sb=");
+                                       k = k >> ST1_BRIGHTNESS_SHIFT;
+                                       _DBG("Sb = %d", k);
+                                       g_string_append_printf(dump_p, "%d", k);
+                                       k = 0;
+                               }
+                               if ((change & ST1_PHONE_SIGNAL_STRENGTH_MASK) != 0) {
+                                       k = (new_state.state_1 & ST1_PHONE_SIGNAL_STRENGTH_MASK);
+                                       dump_p = g_string_append(dump_p, ",Pss=");
+                                       k = k >> ST1_PHONE_SIGNAL_STRENGTH_SHIFT;
+                                       _DBG("Pss = %d", k);
+                                       g_string_append_printf(dump_p, "%d", k);
+                                       k = 0;
+                               }
+                               int shifts = (1 << 14);
+                               for (int i = 14; i < 32; i++) {
                                        if ((change & shifts) != 0) {
                                                dump_p = g_string_append_c(dump_p, ',');
                                                //Considering only -ve shift cases
@@ -896,7 +911,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long base_time, bool chk
                                                                if (chkin)
                                                                        g_string_append_printf(dump_p,
                                                                "%d", new_state.wakelock_tag->sp_idx);
-                                                               else{
+                                                               else {
                                                                        //: NC
                                                                }
                                                                //_DBG("value %s", dump_p->str);
@@ -1040,7 +1055,8 @@ static int bd_set_history_from_listener(history_item_s* nrec)
        time_t current_time;
        time(&current_time); //This time needs to be changed to MT
 
-       history_data[h_count].time_s = current_time;
+//     history_data[h_count].time_s = current_time;// comment for testing with test fn
+       history_data[h_count].time_s = nrec->time_s;
 
        dvar1 = ((nrec->cmd_s) & 0xff) | ((nrec->battery_level << 8) & 0xff00) |
                ((nrec->battery_status << 16) & 0xf0000) |
@@ -1065,6 +1081,9 @@ static int bd_set_history_from_listener(history_item_s* nrec)
        if (nrec->wakereason_tag != NULL)
                history_data[h_count].wakereason_tag = nrec->wakereason_tag;
        if (nrec->event_code != ET_NONE) {
+               _DBG("HI");
+               if (nrec->event_tag == NULL)
+                       _ERR("IT is NULL");
                history_data[h_count].event_code = nrec->event_code;
                history_data[h_count].event_tag = nrec->event_tag;
        }
@@ -1171,8 +1190,9 @@ static int bd_test_fn()
 
        EXIT;
        return BATTERY_MONITOR_ERROR_NONE;
-}
+}*/
 
+/*
 static int bd_make_string_maps()
 {
        ENTER;
@@ -1185,8 +1205,7 @@ static int bd_make_string_maps()
 
        EXIT;
        return BATTERY_MONITOR_ERROR_NONE;
-}
-*/
+}*/
 
 static int *dumpsys_handler;
 
@@ -1206,6 +1225,7 @@ int bd_callback(const int fd, const int argc, char **argv)
                }
        }
 
+       checkin = true;
        ret = bd_print_history_item_main(fd, -1, 0, checkin);
        if (ret != BATTERY_MONITOR_ERROR_NONE) {
                _ERR("bd_print_history_item_main failed (%x)", ret);
@@ -1230,7 +1250,9 @@ int bd_initialize_battery_dump()
        h_count = 0; h_flag = true;
        _INFO("Battery Dump Init Successful");
        //Remove
-       //bd_make_string_maps();
+       // Uncomment to test
+       bd_dummy_test_fn();
+
        EXIT;
        return BATTERY_MONITOR_ERROR_NONE;
 }
@@ -1252,4 +1274,3 @@ int bd_deinitialize_battery_dump()
        EXIT;
        return BATTERY_MONITOR_ERROR_NONE;
 }
-//Remove all DBG statements in final patch
diff --git a/src/battery_dump/bd_history_item_dummy.c b/src/battery_dump/bd_history_item_dummy.c
new file mode 100644 (file)
index 0000000..2e3b71d
--- /dev/null
@@ -0,0 +1,455 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "bd_history_item.h"
+#include "bm_dbg.h"
+#include "bm_common.h"
+#include <stdlib.h>
+#include <time.h>
+#include <glib/gprintf.h>
+#include <stdio.h>
+#include "bd_history_item_dummy.h"
+
+int pool_idx = 0;
+int pool_idx_map_s1[32];
+int pool_idx_map_s2[32];
+int gl_time = 1;
+
+/*
+static int create_sp_idx(int mask, int state)
+{
+       ENTER;
+
+       if (state == 1) {
+               if (pool_idx_map_s1[mask] == -1) {
+                       pool_idx_map_s1[mask] = pool_idx++;
+               }
+       } else if (state == 2) {
+               if (pool_idx_map_s2[mask] == -1) {
+                       pool_idx_map_s2[mask] = pool_idx++;
+               }
+       }
+
+       EXIT;
+       return BATTERY_MONITOR_ERROR_NONE;
+}
+
+static int remove_sp_idx(int mask, int state)
+{
+       ENTER;
+
+       if (state == 1) {
+               if (pool_idx_map_s1[mask] != -1) {
+                       pool_idx_map_s1[mask] = -1;
+               }
+       } else if (state == 2) {
+               if (pool_idx_map_s2[mask] != -1;) {
+                       pool_idx_map_s2[mask] = -1;
+               }
+       }
+
+       EXIT;
+       return BATTERY_MONITOR_ERROR_NONE;
+}
+*/
+
+static int create_history_tag(history_item_s* ts, int mask, int state, int on)
+{
+       ENTER;
+
+       ts->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
+       if (ts->event_tag != NULL) {
+               _DBG("Memory created successfully");
+               GString *temp = ts->event_tag->string_info;
+               temp = g_string_sized_new(30);
+               BM_CHECK_MEM_ALLOC(temp, {});
+               ts->event_tag->uid = 0; //All events are associated with tizen
+               if (state == 1) {
+                       if (pool_idx_map_s1[mask] == -1) {
+                               pool_idx_map_s1[mask] = pool_idx++;
+                               ts->event_tag->sp_idx = pool_idx_map_s1[mask];
+                       } else {
+                               ts->event_tag->sp_idx = pool_idx_map_s1[mask];
+                               pool_idx_map_s1[mask] = -1;
+                       }
+               } else if (state == 2) {
+                       if (pool_idx_map_s2[mask] == -1) {
+                               pool_idx_map_s2[mask] = pool_idx++;
+                               ts->event_tag->sp_idx = pool_idx_map_s2[mask];
+                       } else {
+                               ts->event_tag->sp_idx = pool_idx_map_s2[mask];
+                               pool_idx_map_s1[mask] = -1;
+                       }
+               } else
+                       ts->event_tag->sp_idx = pool_idx++;
+
+               if (on)
+                       temp = g_string_append(temp, "tizen:ON");
+               else
+                       temp = g_string_append(temp, "tizen:OFF");
+               ts->event_tag->string_info = temp;
+               _DBG("%s", ts->event_tag->string_info->str);
+       }
+
+       EXIT;
+       return BATTERY_MONITOR_ERROR_NONE;
+}
+
+int bd_dummy_test_fn()
+{
+       ENTER;
+
+       for (int i = 0; i < 32; i++) {
+               pool_idx_map_s1[i] = -1;
+               pool_idx_map_s2[i] = -1;
+       }
+
+       history_item_s ts;
+       //Node 0
+       bd_print_history_item_reset(&ts);
+       ts.cmd_s = CM_CRR_TIME; ts.event_code = ET_NONE;
+       ts.event_tag = NULL; ts.wakelock_tag = NULL;
+       ts.wakereason_tag = NULL; ts.time_s = 10*(gl_time++);
+       bd_store_history_item(&ts);
+
+       // Common
+       ts.battery_status = 'd'; ts.battery_temperature = 226;
+       ts.battery_voltage = 4274; ts.battery_charge = 0;
+       ts.wakelock_tag = NULL; ts.wakelock_tag = NULL;
+
+       // Node 1
+       /*
+               state 2 wifi on
+               event connectivity change
+       */
+       ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+       ts.time_current = 0;
+       ts.state_1 = 0;
+       ts.state_2 = ST2_WIFI_ON_FLAG;
+       ts.battery_level = 99; ts.battery_health = 'g';
+       ts.battery_plugtype = 'n';
+       ts.event_code = ET_CONNECTIVITY_CHANGED;
+       ts.event_code |= ET_FLAG_START;
+       ts.event_tag = NULL;
+       if (ts.event_code != ET_NONE)
+               create_history_tag(&ts, 28, 2, 1);
+       bd_store_history_item(&ts);
+
+       // Node 2
+       /*
+               state 2 wifi off
+               event connectivity change
+       */
+       ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+       ts.time_current = 0;
+       ts.state_2 &= ~(ST2_WIFI_ON_FLAG);
+       ts.battery_level = 97;
+       ts.event_code = ET_NONE;
+       ts.event_code |= ET_FLAG_FINISH;
+       ts.event_code |= ET_CONNECTIVITY_CHANGED;
+       ts.event_tag = NULL;
+       if (ts.event_code != ET_NONE)
+               create_history_tag(&ts, 28, 2, 0);
+       bd_store_history_item(&ts);
+
+       // Node 3
+       /*
+               state 1 wifi scan on
+               event connectivity change
+       */
+       ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+       ts.time_current = 0;
+       ts.state_1 |= ST1_WIFI_SCAN_FLAG;
+       ts.battery_level = 95; ts.battery_health = 'g';
+       ts.battery_plugtype = 'n';
+       ts.event_code = ET_NONE;
+       ts.event_code |= ET_FLAG_START;
+       ts.event_code |= ET_CONNECTIVITY_CHANGED;
+       ts.event_tag = NULL;
+       if (ts.event_code != ET_NONE)
+               create_history_tag(&ts, 27, 1, 1);
+       bd_store_history_item(&ts);
+
+       // Node 4
+       /*
+               state 1 wifi scan off
+               event connectivity change
+       */
+       ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+       ts.time_current = 0;
+       ts.state_1 &= ~(ST1_WIFI_SCAN_FLAG);
+       ts.battery_level = 94;
+       ts.event_code = ET_NONE;
+       ts.event_code |= ET_FLAG_FINISH;
+       ts.event_code |= ET_CONNECTIVITY_CHANGED;
+       ts.event_tag = NULL;
+       if (ts.event_code != ET_NONE)
+               create_history_tag(&ts, 27, 1, 0);
+       bd_store_history_item(&ts);
+
+       // Node 5
+       /*
+               state 2 bt on
+               event connectivity change
+       */
+       ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+       ts.time_current = 0;
+       ts.state_2 |= ST2_BLUETOOTH_ON_FLAG;
+       ts.battery_level = 92;
+       ts.battery_plugtype = 'n';
+       ts.event_code = ET_NONE;
+       ts.event_code |= ET_FLAG_START;
+       ts.event_code |= ET_CONNECTIVITY_CHANGED;
+       ts.event_tag = NULL;
+       if (ts.event_code != ET_NONE)
+               create_history_tag(&ts, 22, 2, 1);
+       bd_store_history_item(&ts);
+
+       // Node 6
+       /*
+               state 2 bt off
+               event connectivity change
+       */
+       ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+       ts.time_current = 0;
+       ts.state_2 &= ~(ST2_BLUETOOTH_ON_FLAG);
+       ts.battery_level = 90;
+       ts.event_code = ET_NONE;
+       ts.event_code |= ET_FLAG_FINISH;
+       ts.event_code |= ET_CONNECTIVITY_CHANGED;
+       ts.event_tag = NULL;
+       if (ts.event_code != ET_NONE)
+               create_history_tag(&ts, 22, 2, 0);
+       bd_store_history_item(&ts);
+
+       // Node 7
+       /*
+               state 2 bt scan on
+               event connectivity change
+       */
+       ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+       ts.time_current = 0;
+       ts.state_2 |= ST2_BLUETOOTH_SCAN_FLAG;
+       ts.battery_level = 88;
+       ts.event_code = ET_NONE;
+       ts.event_code |= ET_FLAG_START;
+       ts.event_code |= ET_CONNECTIVITY_CHANGED;
+       ts.event_tag = NULL;
+       if (ts.event_code != ET_NONE)
+               create_history_tag(&ts, 20, 2, 1);
+       bd_store_history_item(&ts);
+
+       // Node 8
+       /*
+               state 2 bt scan off
+               event connectivity change
+       */
+       ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+       ts.time_current = 0;
+       ts.state_2 &= ~(ST2_BLUETOOTH_SCAN_FLAG);
+       ts.battery_level = 87;
+       ts.event_code = ET_NONE;
+       ts.event_code |= ET_FLAG_FINISH;
+       ts.event_code |= ET_CONNECTIVITY_CHANGED;
+       ts.event_tag = NULL;
+       if (ts.event_code != ET_NONE)
+               create_history_tag(&ts, 20, 2, 0);
+       bd_store_history_item(&ts);
+
+
+       // Node 9
+       /*
+               state 1 screen on
+               event screen wakeup
+       */
+       ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+       ts.time_current = 0;
+       ts.state_1 |= ST1_SCREEN_ON_FLAG;
+       ts.battery_level = 85; ts.battery_health = 'g';
+       ts.battery_plugtype = 'n';
+       ts.event_code = ET_NONE;
+       ts.event_code |= ET_FLAG_START;
+       ts.event_code |= ET_SCREEN_WAKE_UP;
+       ts.event_tag = NULL;
+       if (ts.event_code != ET_NONE)
+               create_history_tag(&ts, 20, 1, 1);
+       bd_store_history_item(&ts);
+
+       // Node 10
+       /*
+               state 1 screen off
+               event screen wakeup (off)
+       */
+       ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+       ts.time_current = 0;
+       ts.state_1 &= ~(ST1_SCREEN_ON_FLAG);
+       ts.battery_level = 83; ts.battery_health = 'g';
+       ts.battery_plugtype = 'n';
+       ts.event_code = ET_NONE;
+       ts.event_code |= ET_FLAG_FINISH;
+       ts.event_code |= ET_SCREEN_WAKE_UP;
+       ts.event_tag = NULL;
+       if (ts.event_code != ET_NONE)
+               create_history_tag(&ts, 20, 1, 0);
+       bd_store_history_item(&ts);
+
+       // Node 11
+       /*
+               sensor on flag
+               event wakeup
+       */
+       ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+       ts.time_current = 0;
+       ts.state_1 |= ST1_SENSOR_ON_FLAG;
+       ts.battery_level = 83; ts.battery_health = 'g';
+       ts.battery_plugtype = 'n';
+       ts.event_code = ET_NONE;
+       ts.event_code |= ET_FLAG_START;
+       ts.event_code |= ET_WAKEUP_AP;
+       ts.event_tag = NULL;
+       if (ts.event_code != ET_NONE)
+               create_history_tag(&ts, 23, 1, 1);
+       bd_store_history_item(&ts);
+
+       //Node 12
+       /*
+               sensor off flag
+               event wakeup
+       */
+       ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+       ts.time_current = 0;
+       ts.state_1 &= ~(ST1_SENSOR_ON_FLAG);
+       ts.battery_level = 79; ts.battery_health = 'g';
+       ts.battery_plugtype = 'n';
+       ts.event_code = ET_NONE;
+       ts.event_code |= ET_FLAG_FINISH;
+       ts.event_code |= ET_WAKEUP_AP;
+       ts.event_tag = NULL;
+       if (ts.event_code != ET_NONE)
+               create_history_tag(&ts, 23, 1, 0);
+       bd_store_history_item(&ts);
+
+       for (int i = 1; i <= 4; i++) {
+               ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+               ts.time_current = 0;
+               ts.state_1 |= i;
+               ts.event_code = ET_NONE;
+               ts.event_tag = NULL;
+               bd_store_history_item(&ts);
+               ts.state_1 &= ~i;
+       }
+
+       for (int i = 1; i <= 4; i++) {
+               ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+               ts.time_current = 0;
+               ts.state_1 |= (i << ST1_PHONE_SIGNAL_STRENGTH_SHIFT);
+               ts.event_code = ET_NONE;
+               ts.event_tag = NULL;
+               bd_store_history_item(&ts);
+               ts.state_1 &= ~(i << ST1_PHONE_SIGNAL_STRENGTH_SHIFT);
+       }
+
+       ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+       ts.time_current = 0;
+       ts.state_1 |= ST1_BATTERY_PLUGGED_FLAG;
+       ts.battery_level = 78; ts.battery_health = 'g';
+       ts.battery_plugtype = 'a';
+       ts.event_code = ET_NONE;
+       ts.event_code |= ET_FLAG_START;
+       ts.event_code |= ET_WAKEUP_AP;
+       ts.event_tag = NULL;
+       if (ts.event_code != ET_NONE)
+               create_history_tag(&ts, 19, 1, 1);
+       bd_store_history_item(&ts);
+
+       ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+       ts.time_current = 0;
+       ts.state_1 &= ~(ST1_BATTERY_PLUGGED_FLAG);
+       ts.battery_level = 79; ts.battery_health = 'g';
+       ts.battery_plugtype = 'n';
+       ts.event_code = ET_NONE;
+       ts.event_code |= ET_FLAG_FINISH;
+       ts.event_code |= ET_WAKEUP_AP;
+       ts.event_tag = NULL;
+       if (ts.event_code != ET_NONE)
+               create_history_tag(&ts, 19, 1, 0);
+       bd_store_history_item(&ts);
+
+       for (int i = 1; i < 100; i++) {
+               ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+               ts.time_current = 0;
+               ts.state_2 = ST2_WIFI_ON_FLAG;
+               if (i % 5 == 0)
+                       ts.battery_level--;
+               ts.battery_health = 'g';
+               ts.battery_plugtype = 'n';
+               ts.event_code = ET_CONNECTIVITY_CHANGED;
+               ts.event_code |= ET_FLAG_START;
+               ts.event_tag = NULL;
+               if (ts.event_code != ET_NONE)
+                       create_history_tag(&ts, 28, 2, 1);
+               bd_store_history_item(&ts);
+               ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+               ts.time_current = 0;
+               ts.state_1 |= ST1_SCREEN_ON_FLAG;
+               ts.battery_health = 'g';
+               ts.battery_plugtype = 'n';
+               ts.event_code = ET_NONE;
+               ts.event_code |= ET_FLAG_START;
+               ts.event_code |= ET_SCREEN_WAKE_UP;
+               ts.event_tag = NULL;
+               if (ts.event_code != ET_NONE)
+                       create_history_tag(&ts, 20, 1, 1);
+               bd_store_history_item(&ts);
+
+               for (int j = 1; j <= 4; j++) {
+               ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+               ts.time_current = 0;
+               ts.state_1 |= j;
+               ts.event_code = ET_NONE;
+               ts.event_tag = NULL;
+               bd_store_history_item(&ts);
+               ts.state_1 &= ~j;
+               }
+
+               ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+               ts.time_current = 0;
+               ts.state_1 &= ~(ST1_SCREEN_ON_FLAG);
+               ts.battery_health = 'g';
+               ts.battery_plugtype = 'n';
+               ts.event_code = ET_NONE;
+               ts.event_code |= ET_FLAG_FINISH;
+               ts.event_code |= ET_SCREEN_WAKE_UP;
+               ts.event_tag = NULL;
+               if (ts.event_code != ET_NONE)
+                       create_history_tag(&ts, 20, 1, 0);
+               bd_store_history_item(&ts);
+               ts.cmd_s = CM_UPD; ts.time_s = 10*(gl_time++);
+               ts.time_current = 0;
+               ts.state_2 &= ~(ST2_WIFI_ON_FLAG);
+               ts.event_code = ET_NONE;
+               ts.event_code |= ET_FLAG_FINISH;
+               ts.event_code |= ET_CONNECTIVITY_CHANGED;
+               ts.event_tag = NULL;
+               if (ts.event_code != ET_NONE)
+                       create_history_tag(&ts, 28, 2, 0);
+               bd_store_history_item(&ts);
+       }
+
+       EXIT;
+       return BATTERY_MONITOR_ERROR_NONE;
+}