• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "nmea_message_callback_taihe.h"
16 
17 #include "common_utils.h"
18 #include "ipc_skeleton.h"
19 #include "location_log.h"
20 #include "constant_definition.h"
21 
22 namespace OHOS {
23 namespace Location {
NmeaMessageCallbackTaihe()24 NmeaMessageCallbackTaihe::NmeaMessageCallbackTaihe()
25 {
26 }
27 
~NmeaMessageCallbackTaihe()28 NmeaMessageCallbackTaihe::~NmeaMessageCallbackTaihe()
29 {
30 }
31 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)32 int NmeaMessageCallbackTaihe::OnRemoteRequest(
33     uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
34 {
35     LBSLOGD(NMEA_MESSAGE_CALLBACK, "NmeaMessageCallbackTaihe::OnRemoteRequest!");
36     if (data.ReadInterfaceToken() != GetDescriptor()) {
37         LBSLOGE(NMEA_MESSAGE_CALLBACK, "invalid token.");
38         return -1;
39     }
40     switch (code) {
41         case RECEIVE_NMEA_MESSAGE_EVENT: {
42             int64_t timestamp = data.ReadInt64();
43             std::string msg = Str16ToStr8(data.ReadString16());
44             OnMessageChange(timestamp, msg);
45             break;
46         }
47         default: {
48             IPCObjectStub::OnRemoteRequest(code, data, reply, option);
49             break;
50         }
51     }
52     return 0;
53 }
54 
OnMessageChange(int64_t timestamp,const std::string msg)55 void NmeaMessageCallbackTaihe::OnMessageChange(int64_t timestamp, const std::string msg)
56 {
57     LBSLOGD(NMEA_MESSAGE_CALLBACK, "NmeaMessageCallbackTaihe::OnMessageChange");
58     if (callback_) {
59         (*callback_)(msg);
60     }
61 }
62 }  // namespace Location
63 }  // namespace OHOS
64