Skip to content

MOGWAI NANO v0.2.0

Choose a tag to compare

@Sydney680928 Sydney680928 released this 21 Aug 15:43
· 31 commits to main since this release

Added

  • Hexadecimal number literals (0xFF)
  • nano.info — remote equivalent of the device-side mogwai.info, returning the same MOGRecord (system version, IP, device name, platform, session, free memory, target, MOGWAI NANO version, and OEM build details) without needing a nano.run round-trip
  • nano.user.connect — guided connection shortcut combining discovery, interactive selection, and connection in one call: scans for devices, lists the ones that responded for the user to pick from, and connects to the selected one. Pushes true on a successful connection, false if nothing responded, no device was selected, or the connection failed — the same boolean convention as nano.connect
  • I2C support — i2c.open (name, bus, address), i2c.close, i2c.write, i2c.read, i2c.register.write, i2c.register.read, i2c.scan. Devices are identified by a user-chosen name rather than repeating the bus/address pair on every call, following the same pattern as named timers. i2c.open rejects a name that's already in use with a dedicated error rather than silently overwriting it. Validated against real hardware (a DS3231 RTC module) — write, read, register auto-increment, and bus scanning all confirmed working correctly, BCD-encoded values included
  • ->bcd/bcd-> — convert a number to/from BCD (binary-coded decimal) encoding, commonly used by I2C devices like RTC modules (e.g. 35 ->bcd pushes 0x35; 0x35 bcd-> pushes 35)
  • Skills — reusing the same mechanism as the desktop MOGWAI engine, the device now declares 'GPIO' and 'I2C' as available skills, queryable with skills (returns the full list as a MOGList) and hasSkill (tests for a specific one, e.g. if ('I2C' hasSkill) then { ... }). mogwai.assertSkill is not implemented yet
  • Flags — named on/off state markers, reusing the same mechanism as the desktop MOGWAI engine: flag.set/flag.clear to activate/deactivate a named flag, flag.isSet/flag.isClear to test its state (e.g. if ('MY_FLAG' flag.isSet) then { ... }). Volatile — reset on every new program run, not persisted across reboots. Anticipates the future .mog library system, where a flag can act as a simple guard against loading the same library twice within a single run

Updated

  • Naming convention: primitives that interact directly with the console (user input or display) are now prefixed with user for clarity — nano.select is renamed nano.user.select, and nano.view is renamed nano.user.view. Primitives that only exchange data with the device, with no console interaction of their own, keep their existing names (nano.connect, nano.scan, nano.run, etc.)
  • Network protocol: replaced the JSON + Base64 message format with a lightweight delimiter-based one — fields (source, function, parameters) are now joined with a single ASCII Record Separator character (0x1E) rather than serialized to JSON and Base64-encoded. This eliminates the allocation overhead of JSON serialization/deserialization plus Base64 encoding/decoding on every network message, which was found to cause heap fragmentation and, under sustained high-frequency traffic, an outright OutOfMemoryException. nanoFramework.Json remains a device dependency — it's still used to persist local configuration (currently just the device name) to flash — but it's no longer involved in the network protocol itself. This is a breaking wire protocol change — a device and MOGWAI NANO Studio must be on matching versions; an old Studio cannot talk to a new device's firmware or vice versa.

Fixed

  • EvalResult.ToString() threw a NullReferenceException when Informations was null on certain error paths, which could crash the device's execution dispatcher instead of reporting the original error cleanly
  • The outgoing message queue (TcpServer.EnqueueMessage/SenderLoop) had no upper bound — a program producing console/debug output faster than the network could send it (e.g. a tight forever loop with console.print) could grow the queue indefinitely and exhaust available memory. The queue is now capped, dropping the oldest pending message to make room for new ones once full