In order to bring consistency in-tree, migrate all samples to the use
the new prefix <zephyr/...>. Note that the conversion has been scripted:
```python
from pathlib import Path
import re
EXTENSIONS = ("c", "h", "cpp", "rst")
for p in Path(".").glob("samples/**/*"):
if not p.is_file() or p.suffix and p.suffix[1:] not in EXTENSIONS:
continue
content = ""
with open(p) as f:
for line in f:
m = re.match(r"^(.*)#include <(.*)>(.*)$", line)
if (m and
not m.group(2).startswith("zephyr/") and
(Path(".") / "include" / "zephyr" / m.group(2)).exists()):
content += (
m.group(1) +
"#include <zephyr/" + m.group(2) +">" +
m.group(3) + "\n"
)
else:
content += line
with open(p, "w") as f:
f.write(content)
```
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
/* Copyright (c) 2021 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <cinttypes>
|
|
#include <zephyr/sys/printk.h>
|
|
|
|
#include "chre_api/chre/event.h"
|
|
#include "chre/core/event_loop_manager.h"
|
|
#include "chre/platform/static_nanoapp_init.h"
|
|
#include "chre/util/system/napp_permissions.h"
|
|
|
|
namespace
|
|
{
|
|
constexpr const uint64_t kAppId = 1;
|
|
constexpr const uint32_t kAppVersion = 1;
|
|
|
|
chre::Nanoapp *nanoapp = nullptr;
|
|
|
|
bool nanoappStart(void)
|
|
{
|
|
printk("EchoApp::nanoappStart()\n");
|
|
nanoapp = chre::EventLoopManagerSingleton ::get()->getEventLoop().getCurrentNanoapp();
|
|
nanoapp->registerForBroadcastEvent(CHRE_EVENT_MESSAGE_FROM_HOST);
|
|
return true;
|
|
}
|
|
|
|
void nanoappHandleEvent(uint32_t sender_instance_id, uint16_t event_type, const void *event_data)
|
|
{
|
|
printk("EchoApp::nanoappHandleEvent(sender_instance_id=%u, event_type=%u, event_data@%p)\n",
|
|
sender_instance_id, event_type, event_data);
|
|
}
|
|
|
|
void nanoappEnd()
|
|
{
|
|
nanoapp->unregisterForBroadcastEvent(0);
|
|
nanoapp = nullptr;
|
|
printk("EchoApp::nanoappEnd()\n");
|
|
}
|
|
|
|
} /* anonymous namespace */
|
|
|
|
CHRE_STATIC_NANOAPP_INIT(EchoApp, kAppId, kAppVersion, chre::NanoappPermissions::CHRE_PERMS_NONE);
|