SDK 6.3/C++/Core

From WowWiki
Jump to navigation Jump to search
Official WOWCube SDK documentation. SDK 6.3, C++ (WebAssembly) API. Signatures are extracted from the canonical SDK headers shipped with the WOWCube Development Kit; the headers remain authoritative.

SDK 6.3 · PAWN API: Core · Graphics · Topology · Sound · Motion Sensor · Leaderboard · Splash Screen · Physics · Network · Save · Scramble · Logging
C++: Native API · Application · GFX Engine  ·  Rust: Rust API (experimental)  ·  Changelog


SDK 6.3 · C++ Native API / Core

Application-level services: time, RNG, inter-module packets, BLE data, persistent state, user info, versioning and logging.

Shared types, enums and constants are listed on the Native API overview.

Minimal example

Typical service calls:

uint32_t now = getTime();          // ms since app start
i32_t r = random(0, 100);          // engine RNG
saveState(&state, sizeof(state));  // persist between runs

Functions

sendPacket

Syntax:

i32_t sendPacket(u32_t type, uint8_t* pkt, u32_t size)

Description:

Send a packet to another module. Use NET_BROADCAST (0xFF) as the destination to reach all modules. Low-level counterpart of the PAWN broadcastPacket().

recvPacket

Syntax:

i32_t recvPacket(u32_t size, uint32_t* type, uint8_t* pkt)

Description:

Read a pending inter-module packet into a buffer. Normally consumed by the AppManager event loop, which dispatches it to Application::on_Message().

getTime

Syntax:

i32_t getTime()

Description:

Get time in milliseconds since the module start.

Return values:

Time in milliseconds since the module start.

getUserName

Syntax:

i32_t getUserName(uint8_t* buffer, u32_t bufSize)

Description:

Get the name of a user who is logined on the cube.
Get the user name configured in the WOWCube mobile application to save
results for.

toggleDebugInfo

Syntax:

i32_t toggleDebugInfo()

Description:

Toggle overlay with debug information. TBD - move to GFX

saveState

Syntax:

i32_t saveState(void* data, u32_t size)

Description:

Request to save an application data
Save user settings and/or progress on the flash to restore next time. Each
save data has an incremental ID.

Return values:

True if save was successful.

History:

v5.0 - fixed a bug in which only part of a data saved on the flash

loadState

Syntax:

i32_t loadState(u32_t* id, void* data, u32_t size)

Description:

Request to load an application save data from the flash.
Trigger state load event. It is asynchronous so access to flash memory will
not affect an application performance.

random

Syntax:

i32_t random(u32_t min, u32_t max)

Description:

Generate random number in half-open range.
Random number generator is initialized before each application start. Seed
for initialization is generated by TRNG (True Random Number Generator).

Return values:

Pseudo random value from requested range.

History:

v5.0 - fixed a bug in which random does not generate numbers in a given
range.

getAppVersion

Syntax:

i32_t getAppVersion(Cubios::AppVersion_t *version)

Description:

Get application version.
WOWCube applications follow semantic versioning scheme (see
https://semver.org). This interface allows to get version parts stored in
the cube application descriptor.
Outputs
  • version - structure describing application version

History:

v6.0 - added

LOG

Syntax:

i32_t LOG(uint8_t level, const char* text)

Description:

Write a log line with the given level. Prefer the LOG_a/e/w/i/d/v printf-style macros (see LogLevel_t).

getTap

Syntax:

i32_t getTap()

Description:

Get the pending tap event, if any. Normally consumed by the AppManager event loop (Application::on_Tap() / on_Pat()).

sendBleData

Syntax:

i32_t sendBleData(u32_t type, uint8_t* pkt, u32_t size)

Description:

Send external data over BLE to the connected companion (WOWCube Connect) application.

recvBleData

Syntax:

i32_t recvBleData(uint8_t* pkt, u32_t size)

Description:

Receive pending external BLE data; dispatched by AppManager to Application::on_ExternalMessage().

EVENT_getList

Syntax:

i32_t EVENT_getList()

Description:

Get the pending event mask for this module (see eventMask_t).