# FastBee Mobile App

FastBee mobile app is built with **UniApp** cross-platform framework, supporting WeChat Mini Program, Android, iOS, and H5 from a single codebase.

::: tip Source Code

* Mobile App: <https://gitee.com/beecue/fastbee-app>
* Platform: <https://gitee.com/beecue/fastbee>
  :::

## Supported Platforms

| Platform | Status | Notes |
|----------|:------:|-------|
| WeChat Mini Program | ✓ | Recommended, most complete |
| Android | ✓ | Wap2App packaging |
| iOS | ✓ | Wap2App packaging |
| H5 | ✓ | Browser-based |

## Core Features

### Device Provisioning (Wi-Fi Config)

* Single device provisioning (all platforms) and multi-device (WeChat only)
* Device creates hotspot; mobile sends Wi-Fi credentials via web service
* Device hotspot address: `192.168.4.1`

### QR Code Device Binding

* Scan device QR code (containing device number and product ID) to bind to user account
* Supports batch scanning and manual input

### Real-time Data Monitoring

* MQTT over WebSocket for real-time data push
* Property, function, and event data displayed live
* Thing model data charts

### Device Management

* Device list, online status monitoring
* Remote control (property set, function invoke)
* Device sharing with other users

### Other Features

* Chinese / English i18n switching
* Weather forecast (Seniverse API)
* Video monitoring (WeChat Mini Program requires permission)
* Login / Registration / Profile

## Tech Stack

| Component | Technology |
|-----------|-----------|
| Framework | UniApp |
| UI | uView 2.0 |
| State | Vuex |
| Charts | uChart 2.0 (canvas2d mode) |
| Real-time | MQTT over WebSocket / WXS |
| IDE | HBuilderX 3.3+ |

## MQTT Connection

Mobile uses WebSocket to connect to MQTT Broker:

| Protocol | Port | Use Case |
|----------|------|----------|
| ws | 8083 | H5 / Android / iOS (unencrypted) |
| wss | 8084 | H5 / Android / iOS (encrypted) |
| wxs | 8084 | WeChat Mini Program only |

## Quick Start

### Prerequisites

1. Install [HBuilderX](https://www.dcloud.io/hbuilderx.html) (v3.3+)
2. Install Node.js and run `npm install`
3. Deploy and start FastBee backend

### Configure Server Address

Edit `env.config.js`:

```js
// Development
const devBaseUrl = 'http://localhost:8080'
const devMqttUrl = 'ws://ServerIP:8083/mqtt'

// Production
const prodBaseUrl = 'https://your-domain.com'
const prodMqttUrl = 'wss://your-domain.com:8084/mqtt'
```

### Run on WeChat Mini Program

1. HBuilderX → **Run → WeChat Developer Tools**
2. Preview and debug in WeChat DevTools
3. Provisioning requires real device testing

### Run on H5

1. HBuilderX → **Run → Browser**

### Build App

1. HBuilderX → **Release → Native App (Wap2App)**
2. Package Android APK and iOS separately

## Project Structure

```
├─ apis/              API modules
├─ common/            Utils, filters, MQTT tools
├─ components/        Component library (easycom)
├─ locale/            i18n language files
├─ pages/             Main pages (home, trend, profile)
├─ pagesA/            Sub-package A
├─ pagesB/            Sub-package B
├─ pages_player/      Player pages
├─ store/             Vuex state management
├─ env.config.js      Server address config
├─ manifest.json      Platform configurations
└─ pages.json         Route configuration
```

## Notes

* WeChat provisioning requires location permission in `manifest.json` and real device testing
* WeChat video monitoring requires official category permission
* Use wss (encrypted) in production
* Be aware of protocol differences across platforms (WS/WSS/WXS)
