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 <nos/NuggetClient.h> 21 #include <nos/device.h> 22 23 #include <cstdint> 24 #include <functional> 25 #include <string> 26 #include <vector> 27 28 namespace nos { 29 30 /** 31 * This adds some debug functions around NuggetClient::CallApp() 32 */ 33 class NuggetClientDebuggable : public NuggetClient { 34 public: 35 36 using request_cb_t = std::function<void(const std::vector<uint8_t>&)>; 37 using response_cb_t = std::function<void(uint32_t, const std::vector<uint8_t>&)>; 38 39 /* Need to pass the base constructor params up */ 40 NuggetClientDebuggable(const char* name = 0, uint32_t config = 0, 41 request_cb_t req_cb_ = 0, response_cb_t resp_cb_ = 0); 42 43 /* We'll override this */ 44 uint32_t CallApp(uint32_t appId, uint16_t arg, 45 const std::vector<uint8_t>& request, 46 std::vector<uint8_t>* response) override; 47 48 49 private: 50 request_cb_t request_cb_; 51 response_cb_t response_cb_; 52 }; 53 54 } // namespace nos 55 56 #endif // NOS_NUGGET_CLIENT_DEBUGGABLE_H 57