44 lines
1.2 KiB
C
44 lines
1.2 KiB
C
#include "charger_cmd_process.h"
|
|
#include "charger_api.h"
|
|
#include "cmsis_os2.h"
|
|
#include "service_charger.h"
|
|
|
|
static struct charger_class_ops *g_charger_api;
|
|
|
|
void charger_cmd_process_init(void) { g_charger_api = tjd_driver_charger_get_ops(); }
|
|
|
|
result_t ate_charger_init(uint8_t *para, uint32_t para_len)
|
|
{
|
|
result_t result = {0};
|
|
|
|
result.code = tjd_service_charger_open();
|
|
|
|
return result;
|
|
}
|
|
|
|
result_t ate_charger_test(uint8_t *para, uint32_t para_len)
|
|
{
|
|
result_t result = {0};
|
|
uint32_t battery = 0;
|
|
result.code = g_charger_api->sample_event(&battery);
|
|
if (result.code != 0) {
|
|
return result;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
result_t ate_charger_get_battery(uint8_t *para, uint32_t para_len)
|
|
{
|
|
result_t result = {0};
|
|
uint8_t battery = tjd_service_charger_get_battery();
|
|
result.len = snprintf((char *)result.msg, sizeof(result.msg), "%d%%", battery);
|
|
return result;
|
|
}
|
|
|
|
result_t ate_charger_get_state(uint8_t *para, uint32_t para_len)
|
|
{
|
|
result_t result = {0};
|
|
uint8_t state = tjd_service_charger_get_charger_status();
|
|
result.len = snprintf((char *)result.msg, sizeof(result.msg), "%s", state ? "Charging" : "Not Charging");
|
|
return result;
|
|
} |