• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef NOS_NUGGET_CLIENT_DEBUGGABLE_H
18 #define NOS_NUGGET_CLIENT_DEBUGGABLE_H
19 
20 #include <cstdint>
21 #include <string>
22 #include <vector>
23 
24 #include <nos/device.h>
25 #include <nos/NuggetClient.h>
26 
27 namespace nos {
28 
29 /**
30  * This adds some debug functions around NuggetClient::CallApp()
31  */
32 class NuggetClientDebuggable : public NuggetClient {
33 public:
34 
35   using request_cb_t = std::function<void(const std::vector<uint8_t>&)>;
36   using response_cb_t = std::function<void(uint32_t, const std::vector<uint8_t>&)>;
37 
38   /* Need to pass the base constructor params up */
39   NuggetClientDebuggable(const char* name = 0, uint32_t config = 0,
40                          request_cb_t req_cb_ = 0, response_cb_t resp_cb_ = 0);
41 
42   /* We'll override this */
43   uint32_t CallApp(uint32_t appId, uint16_t arg,
44                    const std::vector<uint8_t>& request,
45                    std::vector<uint8_t>* response) override;
46 
47 
48 private:
49   request_cb_t request_cb_;
50   response_cb_t response_cb_;
51 };
52 
53 } // namespace nos
54 
55 #endif // NOS_NUGGET_CLIENT_DEBUGGABLE_H
56