__CAPGO_KEEP_2__

MQTTの始め方

GitHub

AI-Assisted Setupを使用してプラグインをインストールできます。AIツールにCapgoスキルを追加するには、以下のコマンドを実行してください。

ターミナル画面
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

次に、以下のプロンプトを使用してください。

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-mqtt` plugin in my project.

Manual Setupを使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。

ターミナル画面
bun add @capgo/capacitor-mqtt
bunx cap sync
import { MqttBridge } from '@capgo/capacitor-mqtt';

現在の契約のソース定義を参照してください。

import { MqttBridge } from '@capgo/capacitor-mqtt';
await MqttBridge.connect({} as {
serverURI: string;
port: number;
clientId: string;
username: string;
password: string;
setCleanSession: boolean;
connectionTimeout: number;
keepAliveInterval: number;
setAutomaticReconnect: boolean;
setLastWill?: {
willTopic: string;
willPayload: string;
willQoS: number;
setRetained: boolean;
};
});

現在の契約のソース定義を参照してください。

import { MqttBridge } from '@capgo/capacitor-mqtt';
await MqttBridge.disconnect();

現在の契約のソース定義を参照してください。

import { MqttBridge } from '@capgo/capacitor-mqtt';
await MqttBridge.subscribe({} as { topic: string; qos: number });

See the source definitions for the current contract.

import { MqttBridge } from '@capgo/capacitor-mqtt';
await MqttBridge.publish({} as { topic: string; payload: string; qos: number; retained: boolean });
export type onConnectionLostListener = (x: { connectionStatus: string; reasonCode: number; message: string }) => void;
export type onConnectCompleteListener = (x: { reconnected: boolean; serverURI: string }) => void;
export type onMessageArrivedListener = (x: { topic: string; message: string }) => void;

このページはプラグインから生成されています。 src/definitions.ts.再度、パブリック API がアップストリームで変更されたときは、再度同期を実行してください。

「Getting Started」から続けてください。

「Getting Started」から続けてください。

「Getting Started」を使用してダッシュボードと __CAPGO_KEEP_0__ の作業を計画している場合、__CAPGO_KEEP_0__ を使用して接続してください。 「@__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-mqtt」を使用して、@__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-mqtt のネイティブ機能を使用します。 「@API/__CAPGO_KEEP_1__-mqtt」 「@capgo/capacitor-mqtt」の実装詳細については、「capgo Overview」を参照してください。 for the native capability in Using @capgo/capacitor-mqtt, 「API Overview」 「API Overview」 概要 概要の実装詳細について API キー 概要の実装詳細について、API キー、 デバイス 概要の実装詳細についてデバイス