Fix ack + cleanup
This commit is contained in:
@@ -7,77 +7,10 @@ export interface DeviceProps {
|
|||||||
device: Device;
|
device: Device;
|
||||||
}
|
}
|
||||||
|
|
||||||
// const cleanupListeners = (connection: IConnection): void => {
|
|
||||||
// connection.onMeshPacket.cancelAll();
|
|
||||||
// connection.onDeviceStatus.cancelAll();
|
|
||||||
// connection.onMyNodeInfo.cancelAll();
|
|
||||||
// connection.onUserPacket.cancelAll();
|
|
||||||
// connection.onPositionPacket.cancelAll();
|
|
||||||
// connection.onNodeInfoPacket.cancelAll();
|
|
||||||
// connection.onAdminPacket.cancelAll();
|
|
||||||
// connection.onMeshHeartbeat.cancelAll();
|
|
||||||
// connection.onTextPacket.cancelAll();
|
|
||||||
// };
|
|
||||||
|
|
||||||
export const DeviceWrapper = ({
|
export const DeviceWrapper = ({
|
||||||
children,
|
children,
|
||||||
device,
|
device,
|
||||||
}: DeviceProps): JSX.Element => {
|
}: DeviceProps): JSX.Element => {
|
||||||
// const fetchConfig = useCallback(async (): Promise<void> => {
|
|
||||||
// /**
|
|
||||||
// * Get Config
|
|
||||||
// */
|
|
||||||
// await device.connection?.getConfig(
|
|
||||||
// Protobuf.AdminMessage_ConfigType.DEVICE_CONFIG
|
|
||||||
// );
|
|
||||||
// await device.connection?.getConfig(
|
|
||||||
// Protobuf.AdminMessage_ConfigType.WIFI_CONFIG
|
|
||||||
// );
|
|
||||||
// await device.connection?.getConfig(
|
|
||||||
// Protobuf.AdminMessage_ConfigType.POSITION_CONFIG
|
|
||||||
// );
|
|
||||||
// await device.connection?.getConfig(
|
|
||||||
// Protobuf.AdminMessage_ConfigType.DISPLAY_CONFIG
|
|
||||||
// );
|
|
||||||
// await device.connection?.getConfig(
|
|
||||||
// Protobuf.AdminMessage_ConfigType.LORA_CONFIG
|
|
||||||
// );
|
|
||||||
// await device.connection?.getConfig(
|
|
||||||
// Protobuf.AdminMessage_ConfigType.POWER_CONFIG
|
|
||||||
// );
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Get Module Config
|
|
||||||
// */
|
|
||||||
// await device.connection?.getModuleConfig(
|
|
||||||
// Protobuf.AdminMessage_ModuleConfigType.MQTT_CONFIG
|
|
||||||
// );
|
|
||||||
// await device.connection?.getModuleConfig(
|
|
||||||
// Protobuf.AdminMessage_ModuleConfigType.SERIAL_CONFIG
|
|
||||||
// );
|
|
||||||
// await device.connection?.getModuleConfig(
|
|
||||||
// Protobuf.AdminMessage_ModuleConfigType.EXTNOTIF_CONFIG
|
|
||||||
// );
|
|
||||||
// await device.connection?.getModuleConfig(
|
|
||||||
// Protobuf.AdminMessage_ModuleConfigType.STOREFORWARD_CONFIG
|
|
||||||
// );
|
|
||||||
// await device.connection?.getModuleConfig(
|
|
||||||
// Protobuf.AdminMessage_ModuleConfigType.RANGETEST_CONFIG
|
|
||||||
// );
|
|
||||||
// await device.connection?.getModuleConfig(
|
|
||||||
// Protobuf.AdminMessage_ModuleConfigType.TELEMETRY_CONFIG
|
|
||||||
// );
|
|
||||||
// await device.connection?.getModuleConfig(
|
|
||||||
// Protobuf.AdminMessage_ModuleConfigType.CANNEDMSG_CONFIG
|
|
||||||
// );
|
|
||||||
// }, [device.connection]);
|
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// if (device.ready) {
|
|
||||||
// void fetchConfig();
|
|
||||||
// }
|
|
||||||
// }, [device.ready, fetchConfig]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DeviceContext.Provider value={device}>{children}</DeviceContext.Provider>
|
<DeviceContext.Provider value={device}>{children}</DeviceContext.Provider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -331,7 +331,6 @@ export const useDeviceStore = create<DeviceState>((set, get) => ({
|
|||||||
// ).getTime();
|
// ).getTime();
|
||||||
// }
|
// }
|
||||||
} else {
|
} else {
|
||||||
console.log("PUSH333333333333333333333");
|
|
||||||
device.nodes.push({
|
device.nodes.push({
|
||||||
data: Protobuf.NodeInfo.create({
|
data: Protobuf.NodeInfo.create({
|
||||||
num: position.packet.from,
|
num: position.packet.from,
|
||||||
|
|||||||
@@ -20,33 +20,17 @@ export interface ChannelChatProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const ChannelChat = ({ channel }: ChannelChatProps): JSX.Element => {
|
export const ChannelChat = ({ channel }: ChannelChatProps): JSX.Element => {
|
||||||
const { nodes, connection } = useDevice();
|
const { nodes, connection, ackMessage } = useDevice();
|
||||||
const [currentMessage, setCurrentMessage] = useState("");
|
const [currentMessage, setCurrentMessage] = useState("");
|
||||||
|
|
||||||
const sendMessage = (): void => {
|
const sendMessage = (): void => {
|
||||||
console.log("SENDING TEXT");
|
|
||||||
|
|
||||||
void connection?.sendText(
|
void connection?.sendText(
|
||||||
currentMessage,
|
currentMessage,
|
||||||
undefined,
|
undefined,
|
||||||
true,
|
true,
|
||||||
channel.config.index, //maybe channel.config.index--
|
channel.config.index, //maybe channel.config.index--
|
||||||
(id) => {
|
(id) => {
|
||||||
// console.log(`Chat Index, ${chatIndex}`);
|
ackMessage(channel.config.index, id), console.log("Got Ack");
|
||||||
// console.log(`Chat Index --, ${chatIndex--}`);
|
|
||||||
|
|
||||||
// console.log(
|
|
||||||
// `Chat Index computed, ${isChannel ? chatIndex-- : chatIndex}`,
|
|
||||||
// );
|
|
||||||
|
|
||||||
// dispatch(
|
|
||||||
// ackMessage({
|
|
||||||
// chatIndex: channel.config.index,
|
|
||||||
// messageId: id,
|
|
||||||
// }),
|
|
||||||
// );
|
|
||||||
|
|
||||||
console.log("Message Sent");
|
|
||||||
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user