Git Product home page Git Product logo

Comments (2)

Trion avatar Trion commented on August 15, 2024

chargingstateOk

from gprs_c_sdk.

Trion avatar Trion commented on August 15, 2024

Test Code

/*

  • @file app_main.c
  • @brief An example of SDK's mini system
  • @author: Trion
  • @Date: 2024-8-7 11:22
  • @last Modified by: Trion
  • @last Modified time:2024-8-7 august 11:22 AM
    */

#include "stdint.h"
#include "stdbool.h"
#include "api_os.h"
#include "api_event.h"
#include "api_debug.h"
#include "api_hal_pm.h"
#include "api_key.h"

#define AppMain_TASK_STACK_SIZE    (1024 * 2)
#define AppMain_TASK_PRIORITY      1 
HANDLE mainTaskHandle  = NULL;
HANDLE otherTaskHandle = NULL;
uint16_t chargerState ;
uint16_t chargeLevel ;
uint16_t batteryState ;
uint16_t batteryVoltage; 

void LoopTask(VOID *pData)
{
    uint64_t count = 0;
    while(1)
    {
        ++count;
        if(count == 3000)
        {
            count = 0;
            Trace(1,"Test Test");
            OS_Sleep(1000);
            Trace(1,"Test Test2");
        }
    }
}
void EventDispatch(API_Event_t* pEvent)
{
    switch(pEvent->id)
    {
        case API_EVENT_ID_POWER_ON:
            break;
        case API_EVENT_ID_NO_SIMCARD:
            break;
        case API_EVENT_ID_NETWORK_REGISTERED_HOME:
        case API_EVENT_ID_NETWORK_REGISTERED_ROAMING:
            break;
         case API_EVENT_ID_POWER_INFO:
               chargerState = (pEvent->param1 >> 16) & 0xFFFF;
               chargeLevel = pEvent->param1 & 0xFFFF;
               batteryState = (pEvent->param2 >> 16) & 0xFFFF;
               batteryVoltage = pEvent->param2 & 0xFFFF;
                Trace(1,"Charger State: %d",chargerState);
                Trace(1,"Charger Level: %d",chargeLevel);
                Trace(1,"battery State: %d",batteryState);
                Trace(1,"battery Voltage: %d",batteryVoltage);
                switch(chargerState){
                    case PM_CHARGER_STATE_DISCONNECTED:
                        Trace(1,"Charger is disconnected");
                        break;
                    case PM_CHARGER_STATE_CONNECTED:
                        Trace(1,"Charger is connected");
                        break;
                    case PM_CHARGER_STATE_CHRGING:
                        Trace(1,"Charging is progress");
                        break;
                    case PM_CHARGER_STATE_FINISHED:
                        Trace(1,"Battery is fully charged");
                        break;  
                }
        default:
            break;
    }
}
void AppMainTask(VOID *pData)
{
    API_Event_t* event=NULL;
    otherTaskHandle = OS_CreateTask(LoopTask ,
        NULL, NULL, AppMain_TASK_STACK_SIZE, AppMain_TASK_PRIORITY, 0, 0, "ohter Task");
    while(1)
    {
        if(OS_WaitEvent(mainTaskHandle, &event, OS_TIME_OUT_WAIT_FOREVER))
        {
            EventDispatch(event);
            OS_Free(event->pParam1);
            OS_Free(event->pParam2);
            OS_Free(event);
        }
    }
}
void app_Main(void)
{
    mainTaskHandle = OS_CreateTask(AppMainTask ,
        NULL, NULL, AppMain_TASK_STACK_SIZE, AppMain_TASK_PRIORITY, 0, 0, "init Task");
    OS_SetUserMainHandle(&mainTaskHandle);
}

from gprs_c_sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.